Skip to content

Commit f10c54f

Browse files
author
SDKAuto
committed
CodeGen from PR 31123 in Azure/azure-rest-api-specs
Merge 0c98405fdf8f502af169bcc936a54f5194ea33c1 into 70eec0726034ed22734168f3cd3d2b641dbc5723
1 parent 9e5dd05 commit f10c54f

File tree

104 files changed

+6229
-42831
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

+6229
-42831
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": "a3a1fc3e99483b3325ba6a8b80b868ef4727fa9f",
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.39.1"
6+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.ErrorAdditionalInfo": "Search.ErrorAdditionalInfo",
8+
"azure.search.documents.models.ErrorDetail": "Search.ErrorDetail",
9+
"azure.search.documents.models.ErrorResponse": "Search.ErrorResponse",
10+
"azure.search.documents.models.FacetResult": "Search.FacetResult",
11+
"azure.search.documents.models.IndexAction": "Search.IndexAction",
12+
"azure.search.documents.models.IndexBatch": "Search.IndexBatch",
13+
"azure.search.documents.models.IndexDocumentsResult": "Search.IndexDocumentsResult",
14+
"azure.search.documents.models.IndexingResult": "Search.IndexingResult",
15+
"azure.search.documents.models.LookupDocument": "Search.LookupDocument",
16+
"azure.search.documents.models.QueryAnswerResult": "Search.QueryAnswerResult",
17+
"azure.search.documents.models.QueryCaptionResult": "Search.QueryCaptionResult",
18+
"azure.search.documents.models.SearchDocumentsResult": "Search.SearchDocumentsResult",
19+
"azure.search.documents.models.SearchRequest": "Search.SearchRequest",
20+
"azure.search.documents.models.SearchResult": "Search.SearchResult",
21+
"azure.search.documents.models.SuggestDocumentsResult": "Search.SuggestDocumentsResult",
22+
"azure.search.documents.models.SuggestRequest": "Search.SuggestRequest",
23+
"azure.search.documents.models.SuggestResult": "Search.SuggestResult",
24+
"azure.search.documents.models.VectorQuery": "Search.VectorQuery",
25+
"azure.search.documents.models.VectorizableTextQuery": "Search.VectorizableTextQuery",
26+
"azure.search.documents.models.VectorizedQuery": "Search.VectorizedQuery",
27+
"azure.search.documents.models.QueryType": "Search.QueryType",
28+
"azure.search.documents.models.ScoringStatistics": "Search.ScoringStatistics",
29+
"azure.search.documents.models.SearchMode": "Search.SearchMode",
30+
"azure.search.documents.models.SemanticErrorMode": "Search.SemanticErrorMode",
31+
"azure.search.documents.models.QueryAnswerType": "Search.QueryAnswerType",
32+
"azure.search.documents.models.QueryCaptionType": "Search.QueryCaptionType",
33+
"azure.search.documents.models.VectorQueryKind": "Search.VectorQueryKind",
34+
"azure.search.documents.models.VectorFilterMode": "Search.VectorFilterMode",
35+
"azure.search.documents.models.SemanticErrorReason": "Search.SemanticErrorReason",
36+
"azure.search.documents.models.SemanticSearchResultsType": "Search.SemanticSearchResultsType",
37+
"azure.search.documents.models.IndexActionType": "Search.IndexActionType",
38+
"azure.search.documents.models.AutocompleteMode": "Search.AutocompleteMode",
39+
"azure.search.documents.SearchClient.documents.count": "Search.Documents.count",
40+
"azure.search.documents.SearchClient.documents.search_get": "Search.Documents.searchGet",
41+
"azure.search.documents.SearchClient.documents.search_post": "Search.Documents.searchPost",
42+
"azure.search.documents.SearchClient.documents.get": "Search.Documents.get",
43+
"azure.search.documents.SearchClient.documents.suggest_get": "Search.Documents.suggestGet",
44+
"azure.search.documents.SearchClient.documents.suggest_post": "Search.Documents.suggestPost",
45+
"azure.search.documents.SearchClient.documents.index": "Search.Documents.index",
46+
"azure.search.documents.SearchClient.documents.autocomplete_get": "Search.Documents.autocompleteGet",
47+
"azure.search.documents.SearchClient.documents.autocomplete_post": "Search.Documents.autocompletePost"
48+
}
49+
}
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: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
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 "2025-03-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 "2024-07-01".
38+
Note that overriding this default value may result in unsupported behavior.
3239
:paramtype api_version: str
3340
"""
3441

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)
42+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
43+
_endpoint = "{endpoint}"
44+
self._config = SearchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
4045
_policies = kwargs.pop("policies", None)
4146
if _policies is None:
4247
_policies = [
@@ -56,19 +61,18 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
5661
]
5762
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
5863

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)
64+
self._serialize = Serializer()
65+
self._deserialize = Deserializer()
6266
self._serialize.client_side_validation = False
6367
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)
6468

65-
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
69+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
6670
"""Runs the network request through the client's chained policies.
6771
6872
>>> from azure.core.rest import HttpRequest
6973
>>> request = HttpRequest("GET", "https://www.example.org/")
7074
<HttpRequest [GET], url: 'https://www.example.org/'>
71-
>>> response = client._send_request(request)
75+
>>> response = client.send_request(request)
7276
<HttpResponse: 200 OK>
7377
7478
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -83,7 +87,6 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
8387
request_copy = deepcopy(request)
8488
path_format_arguments = {
8589
"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"),
8790
}
8891

8992
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 "2024-07-01".
33+
Note that overriding this default value may result in unsupported behavior.
34+
:paramtype api_version: str
35+
"""
36+
37+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
38+
api_version: str = kwargs.pop("api_version", "2024-07-01")
39+
40+
if endpoint is None:
41+
raise ValueError("Parameter 'endpoint' must not be None.")
42+
if credential is None:
43+
raise ValueError("Parameter 'credential' must not be None.")
44+
45+
self.endpoint = endpoint
46+
self.credential = credential
47+
self.api_version = api_version
48+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://search.azure.com/.default"])
49+
kwargs.setdefault("sdk_moniker", "search-documents/{}".format(VERSION))
50+
self.polling_interval = kwargs.get("polling_interval", 30)
51+
self._configure(**kwargs)
52+
53+
def _infer_policy(self, **kwargs):
54+
if isinstance(self.credential, AzureKeyCredential):
55+
return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs)
56+
if hasattr(self.credential, "get_token"):
57+
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
58+
raise TypeError(f"Unsupported credential: {self.credential}")
59+
60+
def _configure(self, **kwargs: Any) -> None:
61+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
62+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
63+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
64+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
65+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
66+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
67+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
68+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
69+
self.authentication_policy = kwargs.get("authentication_policy")
70+
if self.credential and not self.authentication_policy:
71+
self.authentication_policy = self._infer_policy(**kwargs)

sdk/search/azure-search-documents/azure/search/documents/_generated/__init__.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)