Skip to content

Commit 1bb065a

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

File tree

106 files changed

+23336
-40527
lines changed

Some content is hidden

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

106 files changed

+23336
-40527
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.Service",
5+
"@azure-tools/typespec-python": "0.38.4"
6+
}

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

Lines changed: 280 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: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
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,
21+
AliasesOperationsOperations,
2022
DataSourcesOperations,
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
33+
34+
class SearchClient(SearchClientOperationsMixin): # pylint: disable=too-many-instance-attributes
3035
"""Client that can be used to manage and query indexes and documents, as well as manage other
3136
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 aliases_operations: AliasesOperationsOperations operations
49+
:vartype aliases_operations: azure.search.documents.operations.AliasesOperationsOperations
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
57+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
58+
behavior.
4959
:paramtype api_version: str
5060
"""
5161

52-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
53-
self, endpoint: str, **kwargs: Any
54-
) -> None:
62+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
5563
_endpoint = "{endpoint}"
56-
self._config = SearchServiceClientConfiguration(endpoint=endpoint, **kwargs)
64+
self._config = SearchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
5765
_policies = kwargs.pop("policies", None)
5866
if _policies is None:
5967
_policies = [
@@ -73,24 +81,25 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
7381
]
7482
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
7583

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)
84+
self._serialize = Serializer()
85+
self._deserialize = Deserializer()
7986
self._serialize.client_side_validation = False
8087
self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize)
8188
self.indexers = IndexersOperations(self._client, self._config, self._serialize, self._deserialize)
8289
self.skillsets = SkillsetsOperations(self._client, self._config, self._serialize, self._deserialize)
8390
self.synonym_maps = SynonymMapsOperations(self._client, self._config, self._serialize, self._deserialize)
8491
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
85-
self.aliases = AliasesOperations(self._client, self._config, self._serialize, self._deserialize)
92+
self.aliases_operations = AliasesOperationsOperations(
93+
self._client, self._config, self._serialize, self._deserialize
94+
)
8695

87-
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
96+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
8897
"""Runs the network request through the client's chained policies.
8998
9099
>>> from azure.core.rest import HttpRequest
91100
>>> request = HttpRequest("GET", "https://www.example.org/")
92101
<HttpRequest [GET], url: 'https://www.example.org/'>
93-
>>> response = client._send_request(request)
102+
>>> response = client.send_request(request)
94103
<HttpResponse: 200 OK>
95104
96105
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
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)

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)