Skip to content

Commit

Permalink
Add Search Service stats API (#10371)
Browse files Browse the repository at this point in the history
* add generated API

* move _credential.py up one level

* add SearchServiceClient

* minor edits to existing tests

* rename test_live -> test_index_live

* add live tests

* restore accidentally removed snippet

* use correct odata.metadata=minimal

* re-record service live tests

* update unit test too
  • Loading branch information
bryevdv authored Mar 19, 2020
1 parent 334e327 commit 3488ccc
Show file tree
Hide file tree
Showing 85 changed files with 17,993 additions and 1,002 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@

__version__ = VERSION

from ._credential import SearchApiKeyCredential

from ._index import (
AutocompleteQuery,
IndexAction,
IndexDocumentsBatch,
IndexingResult,
SearchApiKeyCredential,
SearchIndexClient,
SearchQuery,
SearchItemPaged,
SuggestQuery,
odata,
)

from ._service import SearchServiceClient

__all__ = (
"AutocompleteQuery",
"IndexAction",
Expand All @@ -50,6 +53,7 @@
"SearchIndexClient",
"SearchItemPaged",
"SearchQuery",
"SearchServiceClient",
"SuggestQuery",
"odata",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from ._credential import SearchApiKeyCredential # pylint: disable=unused-import
from ._index_documents_batch import IndexDocumentsBatch # pylint: disable=unused-import
from ._search_index_client import ( # pylint: disable=unused-import
odata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from typing import Any, Union
from ._credential import SearchApiKeyCredential
from .. import SearchApiKeyCredential


def odata(statement, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from typing import Any, Union
from .._credential import SearchApiKeyCredential
from ... import SearchApiKeyCredential


class SearchIndexClient(object):
Expand All @@ -33,7 +33,6 @@ class SearchIndexClient(object):
:type credential: SearchApiKeyCredential
.. admonition:: Example:
.. literalinclude:: ../samples/async_samples/sample_authentication_async.py
:start-after: [START create_search_client_with_key_async]
:end-before: [END create_search_client_with_key_async]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from ._search_service_client import SearchServiceClient # pylint: disable=unused-import
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._search_service_client import SearchServiceClient
__all__ = ['SearchServiceClient']
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

VERSION = "unknown"

class SearchServiceClientConfiguration(Configuration):
"""Configuration for SearchServiceClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: The endpoint URL of the search service.
:type endpoint: str
"""

def __init__(
self,
endpoint, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
super(SearchServiceClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.api_version = "2019-05-06-Preview"
kwargs.setdefault('sdk_moniker', 'searchserviceclient/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

from ._configuration import SearchServiceClientConfiguration
from .operations import DataSourcesOperations
from .operations import IndexersOperations
from .operations import SkillsetsOperations
from .operations import SynonymMapsOperations
from .operations import IndexesOperations
from .operations import SearchServiceClientOperationsMixin
from . import models


class SearchServiceClient(SearchServiceClientOperationsMixin):
"""Client that can be used to manage and query indexes and documents, as well as manage other resources, on a search service.
:ivar data_sources: DataSourcesOperations operations
:vartype data_sources: search_service_client.operations.DataSourcesOperations
:ivar indexers: IndexersOperations operations
:vartype indexers: search_service_client.operations.IndexersOperations
:ivar skillsets: SkillsetsOperations operations
:vartype skillsets: search_service_client.operations.SkillsetsOperations
:ivar synonym_maps: SynonymMapsOperations operations
:vartype synonym_maps: search_service_client.operations.SynonymMapsOperations
:ivar indexes: IndexesOperations operations
:vartype indexes: search_service_client.operations.IndexesOperations
:param endpoint: The endpoint URL of the search service.
:type endpoint: str
"""

def __init__(
self,
endpoint, # type: str
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{endpoint}'
self._config = SearchServiceClientConfiguration(endpoint, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.data_sources = DataSourcesOperations(
self._client, self._config, self._serialize, self._deserialize)
self.indexers = IndexersOperations(
self._client, self._config, self._serialize, self._deserialize)
self.skillsets = SkillsetsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.synonym_maps = SynonymMapsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.indexes = IndexesOperations(
self._client, self._config, self._serialize, self._deserialize)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> SearchServiceClient
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._search_service_client_async import SearchServiceClient
__all__ = ['SearchServiceClient']
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

VERSION = "unknown"

class SearchServiceClientConfiguration(Configuration):
"""Configuration for SearchServiceClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: The endpoint URL of the search service.
:type endpoint: str
"""

def __init__(
self,
endpoint: str,
**kwargs: Any
) -> None:
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
super(SearchServiceClientConfiguration, self).__init__(**kwargs)

self.endpoint = endpoint
self.api_version = "2019-05-06-Preview"
kwargs.setdefault('sdk_moniker', 'searchserviceclient/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs: Any
) -> None:
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

from ._configuration_async import SearchServiceClientConfiguration
from .operations_async import DataSourcesOperations
from .operations_async import IndexersOperations
from .operations_async import SkillsetsOperations
from .operations_async import SynonymMapsOperations
from .operations_async import IndexesOperations
from .operations_async import SearchServiceClientOperationsMixin
from .. import models


class SearchServiceClient(SearchServiceClientOperationsMixin):
"""Client that can be used to manage and query indexes and documents, as well as manage other resources, on a search service.
:ivar data_sources: DataSourcesOperations operations
:vartype data_sources: search_service_client.aio.operations_async.DataSourcesOperations
:ivar indexers: IndexersOperations operations
:vartype indexers: search_service_client.aio.operations_async.IndexersOperations
:ivar skillsets: SkillsetsOperations operations
:vartype skillsets: search_service_client.aio.operations_async.SkillsetsOperations
:ivar synonym_maps: SynonymMapsOperations operations
:vartype synonym_maps: search_service_client.aio.operations_async.SynonymMapsOperations
:ivar indexes: IndexesOperations operations
:vartype indexes: search_service_client.aio.operations_async.IndexesOperations
:param endpoint: The endpoint URL of the search service.
:type endpoint: str
"""

def __init__(
self,
endpoint: str,
**kwargs: Any
) -> None:
base_url = '{endpoint}'
self._config = SearchServiceClientConfiguration(endpoint, **kwargs)
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.data_sources = DataSourcesOperations(
self._client, self._config, self._serialize, self._deserialize)
self.indexers = IndexersOperations(
self._client, self._config, self._serialize, self._deserialize)
self.skillsets = SkillsetsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.synonym_maps = SynonymMapsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.indexes = IndexesOperations(
self._client, self._config, self._serialize, self._deserialize)

async def close(self) -> None:
await self._client.close()

async def __aenter__(self) -> "SearchServiceClient":
await self._client.__aenter__()
return self

async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6257, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._data_sources_operations_async import DataSourcesOperations
from ._indexers_operations_async import IndexersOperations
from ._skillsets_operations_async import SkillsetsOperations
from ._synonym_maps_operations_async import SynonymMapsOperations
from ._indexes_operations_async import IndexesOperations
from ._search_service_client_operations_async import SearchServiceClientOperationsMixin

__all__ = [
'DataSourcesOperations',
'IndexersOperations',
'SkillsetsOperations',
'SynonymMapsOperations',
'IndexesOperations',
'SearchServiceClientOperationsMixin',
]
Loading

0 comments on commit 3488ccc

Please sign in to comment.