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

Search: Add normalizer property to AnalyzeText. #20485

Merged
merged 4 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -7,12 +7,10 @@
# --------------------------------------------------------------------------

from ._search_client import SearchClient

__all__ = ["SearchClient"]
__all__ = ['SearchClient']

try:
from ._patch import patch_sdk # type: ignore

patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

VERSION = "unknown"


class SearchClientConfiguration(Configuration):
"""Configuration for SearchClient.

Expand Down Expand Up @@ -46,31 +45,20 @@ def __init__(
self.endpoint = endpoint
self.index_name = index_name
self.api_version = "2021-04-30-Preview"
kwargs.setdefault("sdk_moniker", "search-documents/{}".format(VERSION))
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self, **kwargs # type: Any
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.http_logging_policy = kwargs.get(
"http_logging_policy"
) or policies.HttpLoggingPolicy(**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")
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.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**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
Expand Up @@ -40,20 +40,17 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
base_url = "{endpoint}/indexes('{indexName}')"
base_url = '{endpoint}/indexes(\'{indexName}\')'
self._config = SearchClientConfiguration(endpoint, index_name, **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)
}
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.documents = DocumentsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self._client, self._config, self._serialize, self._deserialize)

def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
Expand All @@ -66,20 +63,12 @@ def _send_request(self, http_request, **kwargs):
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
path_format_arguments = {
"endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
),
"indexName": self._serialize.url(
"self._config.index_name", self._config.index_name, "str"
),
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
}
http_request.url = self._client.format_url(
http_request.url, **path_format_arguments
)
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(
http_request, stream=stream, **kwargs
)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

def close(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
# --------------------------------------------------------------------------

from ._search_client import SearchClient

__all__ = ["SearchClient"]
__all__ = ['SearchClient']
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

VERSION = "unknown"


class SearchClientConfiguration(Configuration):
"""Configuration for SearchClient.

Expand All @@ -26,7 +25,12 @@ class SearchClientConfiguration(Configuration):
:type index_name: str
"""

def __init__(self, endpoint: str, index_name: str, **kwargs: Any) -> None:
def __init__(
self,
endpoint: str,
index_name: str,
**kwargs: Any
) -> None:
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if index_name is None:
Expand All @@ -36,30 +40,19 @@ def __init__(self, endpoint: str, index_name: str, **kwargs: Any) -> None:
self.endpoint = endpoint
self.index_name = index_name
self.api_version = "2021-04-30-Preview"
kwargs.setdefault("sdk_moniker", "search-documents/{}".format(VERSION))
kwargs.setdefault('sdk_moniker', 'search-documents/{}'.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.http_logging_policy = kwargs.get(
"http_logging_policy"
) or policies.HttpLoggingPolicy(**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")
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.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**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
Expand Up @@ -28,27 +28,25 @@ class SearchClient(object):
:type index_name: str
"""

def __init__(self, endpoint: str, index_name: str, **kwargs: Any) -> None:
base_url = "{endpoint}/indexes('{indexName}')"
def __init__(
self,
endpoint: str,
index_name: str,
**kwargs: Any
) -> None:
base_url = '{endpoint}/indexes(\'{indexName}\')'
self._config = SearchClientConfiguration(endpoint, index_name, **kwargs)
self._client = AsyncPipelineClient(
base_url=base_url, config=self._config, **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)
}
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.documents = DocumentsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self._client, self._config, self._serialize, self._deserialize)

async def _send_request(
self, http_request: HttpRequest, **kwargs: Any
) -> AsyncHttpResponse:
async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
"""Runs the network request through the client's chained policies.

:param http_request: The network request you want to make. Required.
Expand All @@ -58,20 +56,12 @@ async def _send_request(
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
"""
path_format_arguments = {
"endpoint": self._serialize.url(
"self._config.endpoint", self._config.endpoint, "str", skip_quote=True
),
"indexName": self._serialize.url(
"self._config.index_name", self._config.index_name, "str"
),
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
'indexName': self._serialize.url("self._config.index_name", self._config.index_name, 'str'),
}
http_request.url = self._client.format_url(
http_request.url, **path_format_arguments
)
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = await self._client._pipeline.run(
http_request, stream=stream, **kwargs
)
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

async def close(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
from ._documents_operations import DocumentsOperations

__all__ = [
"DocumentsOperations",
'DocumentsOperations',
]
Loading