Skip to content

Commit 4eb5d2c

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

File tree

105 files changed

+19285
-40945
lines changed

Some content is hidden

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

105 files changed

+19285
-40945
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.Service",
5+
"@azure-tools/typespec-python": "0.39.1"
6+
}

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

Lines changed: 242 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: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,63 @@
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,
2122
IndexersOperations,
2223
IndexesOperations,
23-
SearchServiceClientOperationsMixin,
24+
SearchClientOperationsMixin,
2425
SkillsetsOperations,
2526
SynonymMapsOperations,
2627
)
2728

29+
if TYPE_CHECKING:
30+
from azure.core.credentials import TokenCredential
2831

29-
class SearchServiceClient(SearchServiceClientOperationsMixin): # pylint: disable=too-many-instance-attributes
32+
33+
class SearchClient(SearchClientOperationsMixin):
3034
"""Client that can be used to manage and query indexes and documents, as well as manage other
3135
resources, on a search service.
3236
3337
:ivar data_sources: DataSourcesOperations operations
34-
:vartype data_sources: azure.search.documents.indexes.operations.DataSourcesOperations
38+
:vartype data_sources: azure.search.documents.operations.DataSourcesOperations
3539
:ivar indexers: IndexersOperations operations
36-
:vartype indexers: azure.search.documents.indexes.operations.IndexersOperations
40+
:vartype indexers: azure.search.documents.operations.IndexersOperations
3741
:ivar skillsets: SkillsetsOperations operations
38-
:vartype skillsets: azure.search.documents.indexes.operations.SkillsetsOperations
42+
:vartype skillsets: azure.search.documents.operations.SkillsetsOperations
3943
:ivar synonym_maps: SynonymMapsOperations operations
40-
:vartype synonym_maps: azure.search.documents.indexes.operations.SynonymMapsOperations
44+
:vartype synonym_maps: azure.search.documents.operations.SynonymMapsOperations
4145
: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.
46+
:vartype indexes: azure.search.documents.operations.IndexesOperations
47+
:param endpoint: Service host. Required.
4648
:type endpoint: str
47-
:keyword api_version: Api Version. Default value is "2025-03-01-preview". Note that overriding
48-
this default value may result in unsupported behavior.
49+
:param credential: Credential used to authenticate requests to the service. Is either a key
50+
credential type or a token credential type. Required.
51+
:type credential: ~azure.core.credentials.AzureKeyCredential or
52+
~azure.core.credentials.TokenCredential
53+
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
54+
Note that overriding this default value may result in unsupported behavior.
4955
:paramtype api_version: str
5056
"""
5157

52-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
53-
self, endpoint: str, **kwargs: Any
54-
) -> None:
58+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
5559
_endpoint = "{endpoint}"
56-
self._config = SearchServiceClientConfiguration(endpoint=endpoint, **kwargs)
60+
self._config = SearchClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
5761
_policies = kwargs.pop("policies", None)
5862
if _policies is None:
5963
_policies = [
@@ -73,24 +77,22 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
7377
]
7478
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
7579

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)
80+
self._serialize = Serializer()
81+
self._deserialize = Deserializer()
7982
self._serialize.client_side_validation = False
8083
self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize)
8184
self.indexers = IndexersOperations(self._client, self._config, self._serialize, self._deserialize)
8285
self.skillsets = SkillsetsOperations(self._client, self._config, self._serialize, self._deserialize)
8386
self.synonym_maps = SynonymMapsOperations(self._client, self._config, self._serialize, self._deserialize)
8487
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
85-
self.aliases = AliasesOperations(self._client, self._config, self._serialize, self._deserialize)
8688

87-
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
89+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
8890
"""Runs the network request through the client's chained policies.
8991
9092
>>> from azure.core.rest import HttpRequest
9193
>>> request = HttpRequest("GET", "https://www.example.org/")
9294
<HttpRequest [GET], url: 'https://www.example.org/'>
93-
>>> response = client._send_request(request)
95+
>>> response = client.send_request(request)
9496
<HttpResponse: 200 OK>
9597
9698
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)