Skip to content

Commit d2c6d27

Browse files
authored
provide a separate method for getting just names (Azure#11739)
* provide a separate method for getting just names
1 parent 537a145 commit d2c6d27

File tree

4 files changed

+135
-19
lines changed

4 files changed

+135
-19
lines changed

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_search_index_client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def analyze_text(self, index_name, analyze_request, **kwargs):
266266

267267
@distributed_trace
268268
def get_synonym_maps(self, **kwargs):
269-
# type: (**Any) -> List[Dict[Any, Any]]
269+
# type: (**Any) -> List[SynonymMap]
270270
"""List the Synonym Maps in an Azure Search service.
271271
272272
:return: List of synonym maps
@@ -287,6 +287,20 @@ def get_synonym_maps(self, **kwargs):
287287
result = self._client.synonym_maps.list(**kwargs)
288288
return [unpack_synonyms(x) for x in result.synonym_maps]
289289

290+
@distributed_trace
291+
def get_synonym_map_names(self, **kwargs):
292+
# type: (**Any) -> List[str]
293+
"""List the Synonym Map names in an Azure Search service.
294+
295+
:return: List of synonym maps
296+
:rtype: list[str]
297+
:raises: ~azure.core.exceptions.HttpResponseError
298+
299+
"""
300+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
301+
result = self._client.synonym_maps.list(**kwargs)
302+
return [x.name for x in result.synonym_maps]
303+
290304
@distributed_trace
291305
def get_synonym_map(self, name, **kwargs):
292306
# type: (str, **Any) -> SynonymMap

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_search_indexer_client.py

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
if TYPE_CHECKING:
2424
# pylint:disable=unused-import,ungrouped-imports
2525
from ._generated.models import SearchIndexer, SearchIndexerStatus
26-
from typing import Any, Dict, Optional, Sequence
26+
from typing import Any, Optional, Sequence
2727
from azure.core.credentials import AzureKeyCredential
2828

2929

30-
class SearchIndexerClient(HeadersMixin):
30+
class SearchIndexerClient(HeadersMixin): # pylint: disable=R0904
3131
"""A client to interact with Azure search service Indexers.
3232
3333
"""
@@ -114,7 +114,7 @@ def get_indexer(self, name, **kwargs):
114114
:param name: The name of the indexer to retrieve.
115115
:type name: str
116116
:return: The SearchIndexer that is fetched.
117-
:rtype: ~azure.search.documents.SearchIndexer
117+
:rtype: ~azure.search.documents.indexes.models.SearchIndexer
118118
119119
.. admonition:: Example:
120120
@@ -135,7 +135,7 @@ def get_indexers(self, **kwargs):
135135
"""Lists all indexers available for a search service.
136136
137137
:return: List of all the SearchIndexers.
138-
:rtype: `list[dict]`
138+
:rtype: `list[~azure.search.documents.indexes.models.SearchIndexer]`
139139
140140
.. admonition:: Example:
141141
@@ -150,6 +150,27 @@ def get_indexers(self, **kwargs):
150150
result = self._client.indexers.list(**kwargs)
151151
return result.indexers
152152

153+
@distributed_trace
154+
def get_indexer_names(self, **kwargs):
155+
# type: (**Any) -> Sequence[str]
156+
"""Lists all indexer names available for a search service.
157+
158+
:return: List of all the SearchIndexers.
159+
:rtype: `list[str]`
160+
161+
.. admonition:: Example:
162+
163+
.. literalinclude:: ../samples/sample_indexer_operations.py
164+
:start-after: [START list_indexer]
165+
:end-before: [END list_indexer]
166+
:language: python
167+
:dedent: 4
168+
:caption: List all the SearchIndexers
169+
"""
170+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
171+
result = self._client.indexers.list(**kwargs)
172+
return [x.name for x in result.indexers]
173+
153174
@distributed_trace
154175
def delete_indexer(self, indexer, **kwargs):
155176
# type: (Union[str, SearchIndexer], **Any) -> None
@@ -351,6 +372,19 @@ def get_data_source_connections(self, **kwargs):
351372
result = self._client.data_sources.list(**kwargs)
352373
return [unpack_search_indexer_data_source(x) for x in result.data_sources]
353374

375+
@distributed_trace
376+
def get_data_source_connection_names(self, **kwargs):
377+
# type: (**Any) -> Sequence[str]
378+
"""Lists all data source connection names available for a search service.
379+
380+
:return: List of all the data source connection names.
381+
:rtype: `list[str]`
382+
383+
"""
384+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
385+
result = self._client.data_sources.list(**kwargs)
386+
return [x.name for x in result.data_sources]
387+
354388
@distributed_trace
355389
def delete_data_source_connection(self, data_source_connection, **kwargs):
356390
# type: (Union[str, SearchIndexerDataSourceConnection], **Any) -> None
@@ -393,7 +427,7 @@ def get_skillsets(self, **kwargs):
393427
"""List the SearchIndexerSkillsets in an Azure Search service.
394428
395429
:return: List of SearchIndexerSkillsets
396-
:rtype: list[dict]
430+
:rtype: list[~azure.search.documents.indexes.models.SearchIndexerSkillset]
397431
:raises: ~azure.core.exceptions.HttpResponseError
398432
399433
.. admonition:: Example:
@@ -410,6 +444,20 @@ def get_skillsets(self, **kwargs):
410444
result = self._client.skillsets.list(**kwargs)
411445
return result.skillsets
412446

447+
@distributed_trace
448+
def get_skillset_names(self, **kwargs):
449+
# type: (**Any) -> List[str]
450+
"""List the SearchIndexerSkillset names in an Azure Search service.
451+
452+
:return: List of SearchIndexerSkillset names
453+
:rtype: list[str]
454+
:raises: ~azure.core.exceptions.HttpResponseError
455+
456+
"""
457+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
458+
result = self._client.skillsets.list(**kwargs)
459+
return [x.name for x in result.skillsets]
460+
413461
@distributed_trace
414462
def get_skillset(self, name, **kwargs):
415463
# type: (str, **Any) -> SearchIndexerSkillset
@@ -418,7 +466,7 @@ def get_skillset(self, name, **kwargs):
418466
:param name: The name of the SearchIndexerSkillset to get
419467
:type name: str
420468
:return: The retrieved SearchIndexerSkillset
421-
:rtype: dict
469+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
422470
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`
423471
424472
.. admonition:: Example:
@@ -479,7 +527,7 @@ def create_skillset(self, name, skills, description, **kwargs):
479527
:param description: A description for the SearchIndexerSkillset
480528
:type description: Optional[str]
481529
:return: The created SearchIndexerSkillset
482-
:rtype: dict
530+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
483531
484532
.. admonition:: Example:
485533
@@ -517,7 +565,7 @@ def create_or_update_skillset(self, name, **kwargs):
517565
:keyword match_condition: The match condition to use upon the etag
518566
:type match_condition: ~azure.core.MatchConditions
519567
:return: The created or updated SearchIndexerSkillset
520-
:rtype: dict
568+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
521569
522570
If a `skillset` is passed in, any optional `skills`, or
523571
`description` parameter values will override it.

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/aio/_search_index_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,20 @@ async def get_synonym_maps(self, **kwargs):
291291
result = await self._client.synonym_maps.list(**kwargs)
292292
return [unpack_synonyms(x) for x in result.synonym_maps]
293293

294+
@distributed_trace_async
295+
async def get_synonym_map_names(self, **kwargs):
296+
# type: (**Any) -> List[str]
297+
"""List the Synonym Map names in an Azure Search service.
298+
299+
:return: List of synonym map names
300+
:rtype: list[str]
301+
:raises: ~azure.core.exceptions.HttpResponseError
302+
303+
"""
304+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
305+
result = await self._client.synonym_maps.list(**kwargs)
306+
return [x.name for x in result.synonym_maps]
307+
294308
@distributed_trace_async
295309
async def get_synonym_map(self, name, **kwargs):
296310
# type: (str, **Any) -> SynonymMap

sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/aio/_search_indexer_client.py

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
if TYPE_CHECKING:
2424
# pylint:disable=unused-import,ungrouped-imports
2525
from .._generated.models import SearchIndexer, SearchIndexerStatus
26-
from typing import Any, Dict, Optional, Sequence
26+
from typing import Any, Optional, Sequence
2727
from azure.core.credentials import AzureKeyCredential
2828

2929

30-
class SearchIndexerClient(HeadersMixin):
30+
class SearchIndexerClient(HeadersMixin): # pylint: disable=R0904
3131
"""A client to interact with Azure search service Indexers.
3232
3333
"""
@@ -67,7 +67,7 @@ async def create_indexer(self, indexer, **kwargs):
6767
:param indexer: The definition of the indexer to create.
6868
:type indexer: ~azure.search.documents.SearchIndexer
6969
:return: The created SearchIndexer
70-
:rtype: dict
70+
:rtype: ~azure.search.documents.indexes.models.SearchIndexer
7171
7272
.. admonition:: Example:
7373
@@ -92,7 +92,7 @@ async def create_or_update_indexer(self, indexer, name=None, **kwargs):
9292
:param indexer: The definition of the indexer to create or update.
9393
:type indexer: ~azure.search.documents.SearchIndexer
9494
:return: The created SearchIndexer
95-
:rtype: dict
95+
:rtype: ~azure.search.documents.indexes.models.SearchIndexer
9696
"""
9797
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
9898
error_map, access_condition = get_access_conditions(
@@ -114,7 +114,7 @@ async def get_indexer(self, name, **kwargs):
114114
:param name: The name of the indexer to retrieve.
115115
:type name: str
116116
:return: The SearchIndexer that is fetched.
117-
:rtype: dict
117+
:rtype: ~azure.search.documents.indexes.models.SearchIndexer
118118
119119
.. admonition:: Example:
120120
@@ -135,7 +135,7 @@ async def get_indexers(self, **kwargs):
135135
"""Lists all indexers available for a search service.
136136
137137
:return: List of all the SearchIndexers.
138-
:rtype: `list[dict]`
138+
:rtype: `list[~azure.search.documents.indexes.models.SearchIndexer]`
139139
140140
.. admonition:: Example:
141141
@@ -150,6 +150,19 @@ async def get_indexers(self, **kwargs):
150150
result = await self._client.indexers.list(**kwargs)
151151
return result.indexers
152152

153+
@distributed_trace_async
154+
async def get_indexer_names(self, **kwargs):
155+
# type: (**Any) -> Sequence[str]
156+
"""Lists all indexer names available for a search service.
157+
158+
:return: List of all the SearchIndexer names.
159+
:rtype: `list[str]`
160+
161+
"""
162+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
163+
result = await self._client.indexers.list(**kwargs)
164+
return [x.name for x in result.indexers]
165+
153166
@distributed_trace_async
154167
async def delete_indexer(self, indexer, **kwargs):
155168
# type: (Union[str, SearchIndexer], **Any) -> None
@@ -384,13 +397,26 @@ async def get_data_source_connections(self, **kwargs):
384397
result = await self._client.data_sources.list(**kwargs)
385398
return [unpack_search_indexer_data_source(x) for x in result.data_sources]
386399

400+
@distributed_trace_async
401+
async def get_data_source_connection_names(self, **kwargs):
402+
# type: (**Any) -> Sequence[str]
403+
"""Lists all data source connection names available for a search service.
404+
405+
:return: List of all the data source connection names.
406+
:rtype: `list[str]`
407+
408+
"""
409+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
410+
result = await self._client.data_sources.list(**kwargs)
411+
return [x.name for x in result.data_sources]
412+
387413
@distributed_trace_async
388414
async def get_skillsets(self, **kwargs):
389415
# type: (**Any) -> List[SearchIndexerSkillset]
390416
"""List the SearchIndexerSkillsets in an Azure Search service.
391417
392418
:return: List of SearchIndexerSkillsets
393-
:rtype: list[dict]
419+
:rtype: list[~azure.search.documents.indexes.models.SearchIndexerSkillset]
394420
:raises: ~azure.core.exceptions.HttpResponseError
395421
396422
.. admonition:: Example:
@@ -407,6 +433,20 @@ async def get_skillsets(self, **kwargs):
407433
result = await self._client.skillsets.list(**kwargs)
408434
return result.skillsets
409435

436+
@distributed_trace_async
437+
async def get_skillset_names(self, **kwargs):
438+
# type: (**Any) -> List[str]
439+
"""List the SearchIndexerSkillset names in an Azure Search service.
440+
441+
:return: List of SearchIndexerSkillset names
442+
:rtype: list[str]
443+
:raises: ~azure.core.exceptions.HttpResponseError
444+
445+
"""
446+
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
447+
result = await self._client.skillsets.list(**kwargs)
448+
return [x.name for x in result.skillsets]
449+
410450
@distributed_trace_async
411451
async def get_skillset(self, name, **kwargs):
412452
# type: (str, **Any) -> SearchIndexerSkillset
@@ -415,7 +455,7 @@ async def get_skillset(self, name, **kwargs):
415455
:param name: The name of the SearchIndexerSkillset to get
416456
:type name: str
417457
:return: The retrieved SearchIndexerSkillset
418-
:rtype: dict
458+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
419459
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`
420460
421461
.. admonition:: Example:
@@ -476,7 +516,7 @@ async def create_skillset(self, name, skills, description, **kwargs):
476516
:param description: A description for the SearchIndexerSkillset
477517
:type description: Optional[str]
478518
:return: The created SearchIndexerSkillset
479-
:rtype: dict
519+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
480520
481521
.. admonition:: Example:
482522
@@ -514,7 +554,7 @@ async def create_or_update_skillset(self, name, **kwargs):
514554
:keyword match_condition: The match condition to use upon the etag
515555
:type match_condition: ~azure.core.MatchConditions
516556
:return: The created or updated SearchIndexerSkillset
517-
:rtype: dict
557+
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
518558
519559
If a `skillset` is passed in, any optional `skills`, or
520560
`description` parameter values will override it.

0 commit comments

Comments
 (0)