Skip to content

Commit 10fa63a

Browse files
author
SDKAuto
committed
CodeGen from PR 31123 in Azure/azure-rest-api-specs
Merge f69181a233b48f9d2533358d46fe5cd8ba22796b into ae38b76a7e681922a05b0b1e4d44cc725eb94802
1 parent ba26689 commit 10fa63a

File tree

100 files changed

+23224
-40618
lines changed

Some content is hidden

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

100 files changed

+23224
-40618
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": "2fe69d119831d6d0b94c8e1d377e6f7c52c10d0c",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/search/Azure.Search",
5+
"@azure-tools/typespec-python": "0.38.3"
6+
}

sdk/search/azure-search-documents/apiview-properties.json

Lines changed: 284 additions & 0 deletions
Large diffs are not rendered by default.
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: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
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 SearchServiceClientConfiguration
18+
from ._configuration import SearchClientConfiguration
1719
from ._serialization import Deserializer, Serializer
1820
from .operations import (
19-
AliasesOperations,
2021
DataSourcesOperations,
22+
DocumentsOperations,
2123
IndexersOperations,
2224
IndexesOperations,
23-
SearchServiceClientOperationsMixin,
25+
SearchClientOperationsMixin,
2426
SkillsetsOperations,
2527
SynonymMapsOperations,
2628
)
2729

30+
if TYPE_CHECKING:
31+
from azure.core.credentials import TokenCredential
2832

29-
class SearchServiceClient(SearchServiceClientOperationsMixin): # pylint: disable=too-many-instance-attributes
30-
"""Client that can be used to manage and query indexes and documents, as well as manage other
31-
resources, on a search service.
33+
34+
class SearchClient(SearchClientOperationsMixin): # pylint: disable=too-many-instance-attributes
35+
"""Client that can be used to manage and query indexes and documents, as well as
36+
manage other resources, on a search service.
3237
3338
:ivar data_sources: DataSourcesOperations operations
34-
:vartype data_sources: azure.search.documents.indexes.operations.DataSourcesOperations
39+
:vartype data_sources: azure.search.documents.operations.DataSourcesOperations
3540
:ivar indexers: IndexersOperations operations
36-
:vartype indexers: azure.search.documents.indexes.operations.IndexersOperations
41+
:vartype indexers: azure.search.documents.operations.IndexersOperations
3742
:ivar skillsets: SkillsetsOperations operations
38-
:vartype skillsets: azure.search.documents.indexes.operations.SkillsetsOperations
43+
:vartype skillsets: azure.search.documents.operations.SkillsetsOperations
3944
:ivar synonym_maps: SynonymMapsOperations operations
40-
:vartype synonym_maps: azure.search.documents.indexes.operations.SynonymMapsOperations
45+
:vartype synonym_maps: azure.search.documents.operations.SynonymMapsOperations
4146
:ivar indexes: IndexesOperations operations
42-
:vartype indexes: azure.search.documents.indexes.operations.IndexesOperations
43-
:ivar aliases: AliasesOperations operations
44-
:vartype aliases: azure.search.documents.indexes.operations.AliasesOperations
45-
:param endpoint: The endpoint URL of the search service. Required.
47+
:vartype indexes: azure.search.documents.operations.IndexesOperations
48+
:ivar documents: DocumentsOperations operations
49+
:vartype documents: azure.search.documents.operations.DocumentsOperations
50+
:param endpoint: Service host. Required.
4651
:type endpoint: str
47-
:keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding
48-
this default value may result in unsupported behavior.
52+
:param credential: Credential used to authenticate requests to the service. Is either a key
53+
credential type or a token credential type. Required.
54+
:type credential: ~azure.core.credentials.AzureKeyCredential or
55+
~azure.core.credentials.TokenCredential
56+
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
57+
Note that overriding this default value may result in unsupported behavior.
4958
:paramtype api_version: str
5059
"""
5160

52-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
53-
self, endpoint: str, **kwargs: Any
54-
) -> None:
61+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
5562
_endpoint = "{endpoint}"
56-
self._config = SearchServiceClientConfiguration(endpoint=endpoint, **kwargs)
63+
self._config = SearchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
5764
_policies = kwargs.pop("policies", None)
5865
if _policies is None:
5966
_policies = [
@@ -73,24 +80,23 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
7380
]
7481
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
7582

76-
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
77-
self._serialize = Serializer(client_models)
78-
self._deserialize = Deserializer(client_models)
83+
self._serialize = Serializer()
84+
self._deserialize = Deserializer()
7985
self._serialize.client_side_validation = False
8086
self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize)
8187
self.indexers = IndexersOperations(self._client, self._config, self._serialize, self._deserialize)
8288
self.skillsets = SkillsetsOperations(self._client, self._config, self._serialize, self._deserialize)
8389
self.synonym_maps = SynonymMapsOperations(self._client, self._config, self._serialize, self._deserialize)
8490
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
85-
self.aliases = AliasesOperations(self._client, self._config, self._serialize, self._deserialize)
91+
self.documents = DocumentsOperations(self._client, self._config, self._serialize, self._deserialize)
8692

87-
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
93+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
8894
"""Runs the network request through the client's chained policies.
8995
9096
>>> from azure.core.rest import HttpRequest
9197
>>> request = HttpRequest("GET", "https://www.example.org/")
9298
<HttpRequest [GET], url: 'https://www.example.org/'>
93-
>>> response = client._send_request(request)
99+
>>> response = client.send_request(request)
94100
<HttpResponse: 200 OK>
95101
96102
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
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)