Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide a separate method for getting just names #11739

Merged
merged 2 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def analyze_text(self, index_name, analyze_request, **kwargs):

@distributed_trace
def get_synonym_maps(self, **kwargs):
# type: (**Any) -> List[Dict[Any, Any]]
# type: (**Any) -> List[SynonymMap]
"""List the Synonym Maps in an Azure Search service.

:return: List of synonym maps
Expand All @@ -287,6 +287,20 @@ def get_synonym_maps(self, **kwargs):
result = self._client.synonym_maps.list(**kwargs)
return [unpack_synonyms(x) for x in result.synonym_maps]

@distributed_trace
def get_synonym_map_names(self, **kwargs):
# type: (**Any) -> List[str]
"""List the Synonym Map names in an Azure Search service.

:return: List of synonym maps
:rtype: list[str]
:raises: ~azure.core.exceptions.HttpResponseError

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = self._client.synonym_maps.list(**kwargs)
return [x.name for x in result.synonym_maps]

@distributed_trace
def get_synonym_map(self, name, **kwargs):
# type: (str, **Any) -> SynonymMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from ._generated.models import SearchIndexer, SearchIndexerStatus
from typing import Any, Dict, Optional, Sequence
from typing import Any, Optional, Sequence
from azure.core.credentials import AzureKeyCredential


class SearchIndexerClient(HeadersMixin):
class SearchIndexerClient(HeadersMixin): # pylint: disable=R0904
"""A client to interact with Azure search service Indexers.

"""
Expand Down Expand Up @@ -114,7 +114,7 @@ def get_indexer(self, name, **kwargs):
:param name: The name of the indexer to retrieve.
:type name: str
:return: The SearchIndexer that is fetched.
:rtype: ~azure.search.documents.SearchIndexer
:rtype: ~azure.search.documents.indexes.models.SearchIndexer

.. admonition:: Example:

Expand All @@ -135,7 +135,7 @@ def get_indexers(self, **kwargs):
"""Lists all indexers available for a search service.

:return: List of all the SearchIndexers.
:rtype: `list[dict]`
:rtype: `list[~azure.search.documents.indexes.models.SearchIndexer]`

.. admonition:: Example:

Expand All @@ -150,6 +150,27 @@ def get_indexers(self, **kwargs):
result = self._client.indexers.list(**kwargs)
return result.indexers

@distributed_trace
def get_indexer_names(self, **kwargs):
# type: (**Any) -> Sequence[str]
"""Lists all indexer names available for a search service.

:return: List of all the SearchIndexers.
:rtype: `list[str]`

.. admonition:: Example:

.. literalinclude:: ../samples/sample_indexer_operations.py
:start-after: [START list_indexer]
:end-before: [END list_indexer]
:language: python
:dedent: 4
:caption: List all the SearchIndexers
"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = self._client.indexers.list(**kwargs)
return [x.name for x in result.indexers]

@distributed_trace
def delete_indexer(self, indexer, **kwargs):
# type: (Union[str, SearchIndexer], **Any) -> None
Expand Down Expand Up @@ -351,6 +372,19 @@ def get_data_source_connections(self, **kwargs):
result = self._client.data_sources.list(**kwargs)
return [unpack_search_indexer_data_source(x) for x in result.data_sources]

@distributed_trace
def get_data_source_connection_names(self, **kwargs):
# type: (**Any) -> Sequence[str]
"""Lists all data source connection names available for a search service.

:return: List of all the data source connection names.
:rtype: `list[str]`

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = self._client.data_sources.list(**kwargs)
return [x.name for x in result.data_sources]

@distributed_trace
def delete_data_source_connection(self, data_source_connection, **kwargs):
# type: (Union[str, SearchIndexerDataSourceConnection], **Any) -> None
Expand Down Expand Up @@ -393,7 +427,7 @@ def get_skillsets(self, **kwargs):
"""List the SearchIndexerSkillsets in an Azure Search service.

:return: List of SearchIndexerSkillsets
:rtype: list[dict]
:rtype: list[~azure.search.documents.indexes.models.SearchIndexerSkillset]
:raises: ~azure.core.exceptions.HttpResponseError

.. admonition:: Example:
Expand All @@ -410,6 +444,20 @@ def get_skillsets(self, **kwargs):
result = self._client.skillsets.list(**kwargs)
return result.skillsets

@distributed_trace
def get_skillset_names(self, **kwargs):
# type: (**Any) -> List[str]
"""List the SearchIndexerSkillset names in an Azure Search service.

:return: List of SearchIndexerSkillset names
:rtype: list[str]
:raises: ~azure.core.exceptions.HttpResponseError

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = self._client.skillsets.list(**kwargs)
return [x.name for x in result.skillsets]

@distributed_trace
def get_skillset(self, name, **kwargs):
# type: (str, **Any) -> SearchIndexerSkillset
Expand All @@ -418,7 +466,7 @@ def get_skillset(self, name, **kwargs):
:param name: The name of the SearchIndexerSkillset to get
:type name: str
:return: The retrieved SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`

.. admonition:: Example:
Expand Down Expand Up @@ -479,7 +527,7 @@ def create_skillset(self, name, skills, description, **kwargs):
:param description: A description for the SearchIndexerSkillset
:type description: Optional[str]
:return: The created SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset

.. admonition:: Example:

Expand Down Expand Up @@ -517,7 +565,7 @@ def create_or_update_skillset(self, name, **kwargs):
:keyword match_condition: The match condition to use upon the etag
:type match_condition: ~azure.core.MatchConditions
:return: The created or updated SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset

If a `skillset` is passed in, any optional `skills`, or
`description` parameter values will override it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ async def get_synonym_maps(self, **kwargs):
result = await self._client.synonym_maps.list(**kwargs)
return [unpack_synonyms(x) for x in result.synonym_maps]

@distributed_trace_async
async def get_synonym_map_names(self, **kwargs):
# type: (**Any) -> List[str]
"""List the Synonym Map names in an Azure Search service.

:return: List of synonym map names
:rtype: list[str]
:raises: ~azure.core.exceptions.HttpResponseError

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = await self._client.synonym_maps.list(**kwargs)
return [x.name for x in result.synonym_maps]

@distributed_trace_async
async def get_synonym_map(self, name, **kwargs):
# type: (str, **Any) -> SynonymMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from .._generated.models import SearchIndexer, SearchIndexerStatus
from typing import Any, Dict, Optional, Sequence
from typing import Any, Optional, Sequence
from azure.core.credentials import AzureKeyCredential


class SearchIndexerClient(HeadersMixin):
class SearchIndexerClient(HeadersMixin): # pylint: disable=R0904
"""A client to interact with Azure search service Indexers.

"""
Expand Down Expand Up @@ -67,7 +67,7 @@ async def create_indexer(self, indexer, **kwargs):
:param indexer: The definition of the indexer to create.
:type indexer: ~azure.search.documents.SearchIndexer
:return: The created SearchIndexer
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexer

.. admonition:: Example:

Expand All @@ -92,7 +92,7 @@ async def create_or_update_indexer(self, indexer, name=None, **kwargs):
:param indexer: The definition of the indexer to create or update.
:type indexer: ~azure.search.documents.SearchIndexer
:return: The created SearchIndexer
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexer
"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
error_map, access_condition = get_access_conditions(
Expand All @@ -114,7 +114,7 @@ async def get_indexer(self, name, **kwargs):
:param name: The name of the indexer to retrieve.
:type name: str
:return: The SearchIndexer that is fetched.
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexer

.. admonition:: Example:

Expand All @@ -135,7 +135,7 @@ async def get_indexers(self, **kwargs):
"""Lists all indexers available for a search service.

:return: List of all the SearchIndexers.
:rtype: `list[dict]`
:rtype: `list[~azure.search.documents.indexes.models.SearchIndexer]`

.. admonition:: Example:

Expand All @@ -150,6 +150,19 @@ async def get_indexers(self, **kwargs):
result = await self._client.indexers.list(**kwargs)
return result.indexers

@distributed_trace_async
async def get_indexer_names(self, **kwargs):
# type: (**Any) -> Sequence[str]
"""Lists all indexer names available for a search service.

:return: List of all the SearchIndexer names.
:rtype: `list[str]`

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = await self._client.indexers.list(**kwargs)
return [x.name for x in result.indexers]

@distributed_trace_async
async def delete_indexer(self, indexer, **kwargs):
# type: (Union[str, SearchIndexer], **Any) -> None
Expand Down Expand Up @@ -384,13 +397,26 @@ async def get_data_source_connections(self, **kwargs):
result = await self._client.data_sources.list(**kwargs)
return [unpack_search_indexer_data_source(x) for x in result.data_sources]

@distributed_trace_async
async def get_data_source_connection_names(self, **kwargs):
# type: (**Any) -> Sequence[str]
"""Lists all data source connection names available for a search service.

:return: List of all the data source connection names.
:rtype: `list[str]`

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = await self._client.data_sources.list(**kwargs)
return [x.name for x in result.data_sources]

@distributed_trace_async
async def get_skillsets(self, **kwargs):
# type: (**Any) -> List[SearchIndexerSkillset]
"""List the SearchIndexerSkillsets in an Azure Search service.

:return: List of SearchIndexerSkillsets
:rtype: list[dict]
:rtype: list[~azure.search.documents.indexes.models.SearchIndexerSkillset]
:raises: ~azure.core.exceptions.HttpResponseError

.. admonition:: Example:
Expand All @@ -407,6 +433,20 @@ async def get_skillsets(self, **kwargs):
result = await self._client.skillsets.list(**kwargs)
return result.skillsets

@distributed_trace_async
async def get_skillset_names(self, **kwargs):
# type: (**Any) -> List[str]
"""List the SearchIndexerSkillset names in an Azure Search service.

:return: List of SearchIndexerSkillset names
:rtype: list[str]
:raises: ~azure.core.exceptions.HttpResponseError

"""
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers"))
result = await self._client.skillsets.list(**kwargs)
return [x.name for x in result.skillsets]

@distributed_trace_async
async def get_skillset(self, name, **kwargs):
# type: (str, **Any) -> SearchIndexerSkillset
Expand All @@ -415,7 +455,7 @@ async def get_skillset(self, name, **kwargs):
:param name: The name of the SearchIndexerSkillset to get
:type name: str
:return: The retrieved SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`

.. admonition:: Example:
Expand Down Expand Up @@ -476,7 +516,7 @@ async def create_skillset(self, name, skills, description, **kwargs):
:param description: A description for the SearchIndexerSkillset
:type description: Optional[str]
:return: The created SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset

.. admonition:: Example:

Expand Down Expand Up @@ -514,7 +554,7 @@ async def create_or_update_skillset(self, name, **kwargs):
:keyword match_condition: The match condition to use upon the etag
:type match_condition: ~azure.core.MatchConditions
:return: The created or updated SearchIndexerSkillset
:rtype: dict
:rtype: ~azure.search.documents.indexes.models.SearchIndexerSkillset

If a `skillset` is passed in, any optional `skills`, or
`description` parameter values will override it.
Expand Down