10
10
from azure .core .paging import ItemPaged
11
11
12
12
from ._generated import SearchServiceClient as _SearchServiceClient
13
- from ._generated .models import SynonymMap
13
+ from ._generated .models import SynonymMap as _SynonymMap
14
14
from ._utils import (
15
15
delistize_flags_for_index ,
16
16
listize_flags_for_index ,
17
17
listize_synonyms ,
18
+ pack_search_resource_encryption_key ,
18
19
get_access_conditions ,
19
20
normalize_endpoint ,
20
21
)
@@ -275,7 +276,7 @@ def get_synonym_maps(self, **kwargs):
275
276
"""List the Synonym Maps in an Azure Search service.
276
277
277
278
:return: List of synonym maps
278
- :rtype: list[dict ]
279
+ :rtype: list[~azure.search.documents.indexes.models.SynonymMap ]
279
280
:raises: ~azure.core.exceptions.HttpResponseError
280
281
281
282
.. admonition:: Example:
@@ -290,17 +291,17 @@ def get_synonym_maps(self, **kwargs):
290
291
"""
291
292
kwargs ["headers" ] = self ._merge_client_headers (kwargs .get ("headers" ))
292
293
result = self ._client .synonym_maps .list (** kwargs )
293
- return [listize_synonyms (x ) for x in result .as_dict ()[ " synonym_maps" ] ]
294
+ return [listize_synonyms (x ) for x in result .synonym_maps ]
294
295
295
296
@distributed_trace
296
297
def get_synonym_map (self , name , ** kwargs ):
297
- # type: (str, **Any) -> dict
298
+ # type: (str, **Any) -> SynonymMap
298
299
"""Retrieve a named Synonym Map in an Azure Search service
299
300
300
301
:param name: The name of the Synonym Map to get
301
302
:type name: str
302
303
:return: The retrieved Synonym Map
303
- :rtype: dict
304
+ :rtype: :class:`~azure.search.documents.indexes.models.SynonymMap`
304
305
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`
305
306
306
307
.. admonition:: Example:
@@ -315,7 +316,7 @@ def get_synonym_map(self, name, **kwargs):
315
316
"""
316
317
kwargs ["headers" ] = self ._merge_client_headers (kwargs .get ("headers" ))
317
318
result = self ._client .synonym_maps .get (name , ** kwargs )
318
- return listize_synonyms (result . as_dict () )
319
+ return listize_synonyms (result )
319
320
320
321
@distributed_trace
321
322
def delete_synonym_map (self , synonym_map , ** kwargs ):
@@ -356,15 +357,15 @@ def delete_synonym_map(self, synonym_map, **kwargs):
356
357
357
358
@distributed_trace
358
359
def create_synonym_map (self , name , synonyms , ** kwargs ):
359
- # type: (str, Sequence[str], **Any) -> dict
360
+ # type: (str, Sequence[str], **Any) -> SynonymMap
360
361
"""Create a new Synonym Map in an Azure Search service
361
362
362
363
:param name: The name of the Synonym Map to create
363
364
:type name: str
364
365
:param synonyms: The list of synonyms in SOLR format
365
366
:type synonyms: List[str]
366
367
:return: The created Synonym Map
367
- :rtype: dict
368
+ :rtype: ~azure.search.documents.indexes.models.SynonymMap
368
369
369
370
.. admonition:: Example:
370
371
@@ -378,13 +379,13 @@ def create_synonym_map(self, name, synonyms, **kwargs):
378
379
"""
379
380
kwargs ["headers" ] = self ._merge_client_headers (kwargs .get ("headers" ))
380
381
solr_format_synonyms = "\n " .join (synonyms )
381
- synonym_map = SynonymMap (name = name , synonyms = solr_format_synonyms )
382
+ synonym_map = _SynonymMap (name = name , synonyms = solr_format_synonyms )
382
383
result = self ._client .synonym_maps .create (synonym_map , ** kwargs )
383
- return listize_synonyms (result . as_dict () )
384
+ return listize_synonyms (result )
384
385
385
386
@distributed_trace
386
387
def create_or_update_synonym_map (self , synonym_map , synonyms = None , ** kwargs ):
387
- # type: (Union[str, SynonymMap], Optional[Sequence[str]], **Any) -> dict
388
+ # type: (Union[str, SynonymMap], Optional[Sequence[str]], **Any) -> SynonymMap
388
389
"""Create a new Synonym Map in an Azure Search service, or update an
389
390
existing one.
390
391
@@ -395,7 +396,7 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs):
395
396
:keyword match_condition: The match condition to use upon the etag
396
397
:type match_condition: ~azure.core.MatchConditions
397
398
:return: The created or updated Synonym Map
398
- :rtype: dict
399
+ :rtype: ~azure.search.documents.indexes.models.SynonymMap
399
400
400
401
"""
401
402
kwargs ["headers" ] = self ._merge_client_headers (kwargs .get ("headers" ))
@@ -407,17 +408,18 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs):
407
408
name = synonym_map .name
408
409
if synonyms :
409
410
synonym_map .synonyms = "\n " .join (synonyms )
411
+ synonym_map .encryption_key = pack_search_resource_encryption_key (synonym_map .encryption_key )
410
412
except AttributeError :
411
413
name = synonym_map
412
414
solr_format_synonyms = "\n " .join (synonyms )
413
- synonym_map = SynonymMap (name = name , synonyms = solr_format_synonyms )
415
+ synonym_map = _SynonymMap (name = name , synonyms = solr_format_synonyms )
414
416
result = self ._client .synonym_maps .create_or_update (
415
417
synonym_map_name = name ,
416
418
synonym_map = synonym_map ,
417
419
error_map = error_map ,
418
420
** kwargs
419
421
)
420
- return listize_synonyms (result . as_dict () )
422
+ return listize_synonyms (result )
421
423
422
424
@distributed_trace
423
425
def get_service_statistics (self , ** kwargs ):
0 commit comments