Skip to content

Commit 4702aac

Browse files
author
SDKAuto
committed
CodeGen from PR 31462 in Azure/azure-rest-api-specs
Merge 6e8da2bf660c40e4ffe4c2ff83686ad205398675 into 0c98405fdf8f502af169bcc936a54f5194ea33c1
1 parent 966f882 commit 4702aac

File tree

104 files changed

+7171
-42249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7171
-42249
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include *.md
2-
include azure/__init__.py
3-
include azure/search/__init__.py
42
include LICENSE
3+
include azure/search/documents/py.typed
54
recursive-include tests *.py
65
recursive-include samples *.py *.md
7-
include azure/search/documents/py.typed
6+
include azure/__init__.py
7+
include azure/search/__init__.py
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "b07620e90797e507a7400b1bb134b74bbda71b29",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/search/Azure.Search.Index",
5+
"@azure-tools/typespec-python": "0.38.4"
6+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"CrossLanguagePackageId": "Search",
3+
"CrossLanguageDefinitionId": {
4+
"azure.search.documents.models.AutocompleteItem": "Search.AutocompleteItem",
5+
"azure.search.documents.models.AutocompleteRequest": "Search.AutocompleteRequest",
6+
"azure.search.documents.models.AutocompleteResult": "Search.AutocompleteResult",
7+
"azure.search.documents.models.DebugInfo": "Search.DebugInfo",
8+
"azure.search.documents.models.DocumentDebugInfo": "Search.DocumentDebugInfo",
9+
"azure.search.documents.models.ErrorAdditionalInfo": "Search.ErrorAdditionalInfo",
10+
"azure.search.documents.models.ErrorDetail": "Search.ErrorDetail",
11+
"azure.search.documents.models.ErrorResponse": "Search.ErrorResponse",
12+
"azure.search.documents.models.FacetResult": "Search.FacetResult",
13+
"azure.search.documents.models.HybridSearch": "Search.HybridSearch",
14+
"azure.search.documents.models.IndexAction": "Search.IndexAction",
15+
"azure.search.documents.models.IndexBatch": "Search.IndexBatch",
16+
"azure.search.documents.models.IndexDocumentsResult": "Search.IndexDocumentsResult",
17+
"azure.search.documents.models.IndexingResult": "Search.IndexingResult",
18+
"azure.search.documents.models.LookupDocument": "Search.LookupDocument",
19+
"azure.search.documents.models.QueryAnswerResult": "Search.QueryAnswerResult",
20+
"azure.search.documents.models.QueryCaptionResult": "Search.QueryCaptionResult",
21+
"azure.search.documents.models.QueryResultDocumentRerankerInput": "Search.QueryResultDocumentRerankerInput",
22+
"azure.search.documents.models.QueryResultDocumentSemanticField": "Search.QueryResultDocumentSemanticField",
23+
"azure.search.documents.models.QueryResultDocumentSubscores": "Search.QueryResultDocumentSubscores",
24+
"azure.search.documents.models.QueryRewritesDebugInfo": "Search.QueryRewritesDebugInfo",
25+
"azure.search.documents.models.QueryRewritesValuesDebugInfo": "Search.QueryRewritesValuesDebugInfo",
26+
"azure.search.documents.models.SearchDocumentsResult": "Search.SearchDocumentsResult",
27+
"azure.search.documents.models.SearchRequest": "Search.SearchRequest",
28+
"azure.search.documents.models.SearchResult": "Search.SearchResult",
29+
"azure.search.documents.models.VectorThreshold": "Search.VectorThreshold",
30+
"azure.search.documents.models.SearchScoreThreshold": "Search.SearchScoreThreshold",
31+
"azure.search.documents.models.SemanticDebugInfo": "Search.SemanticDebugInfo",
32+
"azure.search.documents.models.SingleVectorFieldResult": "Search.SingleVectorFieldResult",
33+
"azure.search.documents.models.SuggestDocumentsResult": "Search.SuggestDocumentsResult",
34+
"azure.search.documents.models.SuggestRequest": "Search.SuggestRequest",
35+
"azure.search.documents.models.SuggestResult": "Search.SuggestResult",
36+
"azure.search.documents.models.TextResult": "Search.TextResult",
37+
"azure.search.documents.models.VectorQuery": "Search.VectorQuery",
38+
"azure.search.documents.models.VectorizableImageBinaryQuery": "Search.VectorizableImageBinaryQuery",
39+
"azure.search.documents.models.VectorizableImageUrlQuery": "Search.VectorizableImageUrlQuery",
40+
"azure.search.documents.models.VectorizableTextQuery": "Search.VectorizableTextQuery",
41+
"azure.search.documents.models.VectorizedQuery": "Search.VectorizedQuery",
42+
"azure.search.documents.models.VectorsDebugInfo": "Search.VectorsDebugInfo",
43+
"azure.search.documents.models.VectorSimilarityThreshold": "Search.VectorSimilarityThreshold",
44+
"azure.search.documents.models.QueryType": "Search.QueryType",
45+
"azure.search.documents.models.ScoringStatistics": "Search.ScoringStatistics",
46+
"azure.search.documents.models.QueryDebugMode": "Search.QueryDebugMode",
47+
"azure.search.documents.models.SearchMode": "Search.SearchMode",
48+
"azure.search.documents.models.QueryLanguage": "Search.QueryLanguage",
49+
"azure.search.documents.models.QuerySpellerType": "Search.QuerySpellerType",
50+
"azure.search.documents.models.SemanticErrorMode": "Search.SemanticErrorMode",
51+
"azure.search.documents.models.QueryAnswerType": "Search.QueryAnswerType",
52+
"azure.search.documents.models.QueryCaptionType": "Search.QueryCaptionType",
53+
"azure.search.documents.models.QueryRewritesType": "Search.QueryRewritesType",
54+
"azure.search.documents.models.VectorThresholdKind": "Search.VectorThresholdKind",
55+
"azure.search.documents.models.VectorQueryKind": "Search.VectorQueryKind",
56+
"azure.search.documents.models.VectorFilterMode": "Search.VectorFilterMode",
57+
"azure.search.documents.models.HybridCountAndFacetMode": "Search.HybridCountAndFacetMode",
58+
"azure.search.documents.models.SemanticFieldState": "Search.SemanticFieldState",
59+
"azure.search.documents.models.SemanticErrorReason": "Search.SemanticErrorReason",
60+
"azure.search.documents.models.SemanticSearchResultsType": "Search.SemanticSearchResultsType",
61+
"azure.search.documents.models.SemanticQueryRewritesResultType": "Search.SemanticQueryRewritesResultType",
62+
"azure.search.documents.models.IndexActionType": "Search.IndexActionType",
63+
"azure.search.documents.models.AutocompleteMode": "Search.AutocompleteMode",
64+
"azure.search.documents.SearchClient.documents.count": "Search.Documents.count",
65+
"azure.search.documents.SearchClient.documents.search_get": "Search.Documents.searchGet",
66+
"azure.search.documents.SearchClient.documents.search_post": "Search.Documents.searchPost",
67+
"azure.search.documents.SearchClient.documents.get": "Search.Documents.get",
68+
"azure.search.documents.SearchClient.documents.suggest_get": "Search.Documents.suggestGet",
69+
"azure.search.documents.SearchClient.documents.suggest_post": "Search.Documents.suggestPost",
70+
"azure.search.documents.SearchClient.documents.index": "Search.Documents.index",
71+
"azure.search.documents.SearchClient.documents.autocomplete_get": "Search.Documents.autocompleteGet",
72+
"azure.search.documents.SearchClient.documents.autocomplete_post": "Search.Documents.autocompletePost"
73+
}
74+
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
# ------------------------------------
2-
# Copyright (c) Microsoft Corporation.
3-
# Licensed under the MIT License.
4-
# ------------------------------------
5-
# pylint:disable=missing-docstring
6-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
# ------------------------------------
2-
# Copyright (c) Microsoft Corporation.
3-
# Licensed under the MIT License.
4-
# ------------------------------------
5-
# pylint:disable=missing-docstring
6-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,32 @@
1+
# coding=utf-8
12
# --------------------------------------------------------------------------
2-
#
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
#
5-
# The MIT License (MIT)
6-
#
7-
# Permission is hereby granted, free of charge, to any person obtaining a copy
8-
# of this software and associated documentation files (the ""Software""), to
9-
# deal in the Software without restriction, including without limitation the
10-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11-
# sell copies of the Software, and to permit persons to whom the Software is
12-
# furnished to do so, subject to the following conditions:
13-
#
14-
# The above copyright notice and this permission notice shall be included in
15-
# all copies or substantial portions of the Software.
16-
#
17-
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23-
# IN THE SOFTWARE.
24-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
257
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
269

27-
from ._index_documents_batch import IndexDocumentsBatch
28-
from ._search_documents_error import RequestEntityTooLargeError
29-
from ._search_client import SearchClient, SearchItemPaged
30-
from ._search_indexing_buffered_sender import SearchIndexingBufferedSender
31-
from ._api_versions import ApiVersion
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import SearchClient # type: ignore
3216
from ._version import VERSION
3317

3418
__version__ = VERSION
3519

20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
3626

37-
__all__ = (
38-
"ApiVersion",
39-
"IndexDocumentsBatch",
27+
__all__ = [
4028
"SearchClient",
41-
"SearchItemPaged",
42-
"SearchIndexingBufferedSender",
43-
"RequestEntityTooLargeError",
44-
)
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()

sdk/search/azure-search-documents/azure/search/documents/_api_versions.py

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3-
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.5, generator: @autorest/[email protected])
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
46
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
57
# --------------------------------------------------------------------------
68

79
from copy import deepcopy
8-
from typing import Any
10+
from typing import Any, TYPE_CHECKING, Union
911
from typing_extensions import Self
1012

1113
from azure.core import PipelineClient
14+
from azure.core.credentials import AzureKeyCredential
1215
from azure.core.pipeline import policies
1316
from azure.core.rest import HttpRequest, HttpResponse
1417

15-
from . import models as _models
16-
from ._configuration import SearchIndexClientConfiguration
18+
from ._configuration import SearchClientConfiguration
1719
from ._serialization import Deserializer, Serializer
1820
from .operations import DocumentsOperations
1921

22+
if TYPE_CHECKING:
23+
from azure.core.credentials import TokenCredential
2024

21-
class SearchIndexClient:
25+
26+
class SearchClient:
2227
"""Client that can be used to query an index and upload, merge, or delete documents.
2328
2429
:ivar documents: DocumentsOperations operations
2530
:vartype documents: azure.search.documents.operations.DocumentsOperations
26-
:param endpoint: The endpoint URL of the search service. Required.
31+
:param endpoint: Service host. Required.
2732
:type endpoint: str
28-
:param index_name: The name of the index. Required.
29-
:type index_name: str
30-
:keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding
31-
this default value may result in unsupported behavior.
33+
:param credential: Credential used to authenticate requests to the service. Is either a key
34+
credential type or a token credential type. Required.
35+
:type credential: ~azure.core.credentials.AzureKeyCredential or
36+
~azure.core.credentials.TokenCredential
37+
:keyword api_version: The API version to use for this operation. Default value is
38+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
39+
behavior.
3240
:paramtype api_version: str
3341
"""
3442

35-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
36-
self, endpoint: str, index_name: str, **kwargs: Any
37-
) -> None:
38-
_endpoint = "{endpoint}/indexes('{indexName}')"
39-
self._config = SearchIndexClientConfiguration(endpoint=endpoint, index_name=index_name, **kwargs)
43+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
44+
_endpoint = "{endpoint}"
45+
self._config = SearchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
4046
_policies = kwargs.pop("policies", None)
4147
if _policies is None:
4248
_policies = [
@@ -56,19 +62,18 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
5662
]
5763
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
5864

59-
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
60-
self._serialize = Serializer(client_models)
61-
self._deserialize = Deserializer(client_models)
65+
self._serialize = Serializer()
66+
self._deserialize = Deserializer()
6267
self._serialize.client_side_validation = False
6368
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)
6469

65-
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
70+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
6671
"""Runs the network request through the client's chained policies.
6772
6873
>>> from azure.core.rest import HttpRequest
6974
>>> request = HttpRequest("GET", "https://www.example.org/")
7075
<HttpRequest [GET], url: 'https://www.example.org/'>
71-
>>> response = client._send_request(request)
76+
>>> response = client.send_request(request)
7277
<HttpResponse: 200 OK>
7378
7479
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -83,7 +88,6 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
8388
request_copy = deepcopy(request)
8489
path_format_arguments = {
8590
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
86-
"indexName": self._serialize.url("self._config.index_name", self._config.index_name, "str"),
8791
}
8892

8993
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING, Union
10+
11+
from azure.core.credentials import AzureKeyCredential
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class SearchClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for SearchClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param endpoint: Service host. Required.
27+
:type endpoint: str
28+
:param credential: Credential used to authenticate requests to the service. Is either a key
29+
credential type or a token credential type. Required.
30+
:type credential: ~azure.core.credentials.AzureKeyCredential or
31+
~azure.core.credentials.TokenCredential
32+
:keyword api_version: The API version to use for this operation. Default value is
33+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
34+
behavior.
35+
:paramtype api_version: str
36+
"""
37+
38+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
39+
api_version: str = kwargs.pop("api_version", "2024-11-01-preview")
40+
41+
if endpoint is None:
42+
raise ValueError("Parameter 'endpoint' must not be None.")
43+
if credential is None:
44+
raise ValueError("Parameter 'credential' must not be None.")
45+
46+
self.endpoint = endpoint
47+
self.credential = credential
48+
self.api_version = api_version
49+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://search.azure.com/.default"])
50+
kwargs.setdefault("sdk_moniker", "search-documents/{}".format(VERSION))
51+
self.polling_interval = kwargs.get("polling_interval", 30)
52+
self._configure(**kwargs)
53+
54+
def _infer_policy(self, **kwargs):
55+
if isinstance(self.credential, AzureKeyCredential):
56+
return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs)
57+
if hasattr(self.credential, "get_token"):
58+
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
59+
raise TypeError(f"Unsupported credential: {self.credential}")
60+
61+
def _configure(self, **kwargs: Any) -> None:
62+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
63+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
64+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
65+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
66+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
67+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
68+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
69+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
70+
self.authentication_policy = kwargs.get("authentication_policy")
71+
if self.credential and not self.authentication_policy:
72+
self.authentication_policy = self._infer_policy(**kwargs)

0 commit comments

Comments
 (0)