Skip to content

Commit a2baeee

Browse files
author
SDKAuto
committed
CodeGen from PR 18082 in Azure/azure-rest-api-specs
Merge 9b7783ce0ebfc952c95ae3d619d57652aa0dbb85 into d0b5e99
1 parent 2f60187 commit a2baeee

30 files changed

+2950
-3120
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"autorest": "3.7.2",
3+
"use": [
4+
"@autorest/[email protected]",
5+
"@autorest/[email protected]"
6+
],
7+
"commit": "a61ca93647a0a3fb0ee8a00c15f04586c93348ff",
8+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9+
"autorest_command": "autorest specification/search/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.7.2",
10+
"readme": "specification/search/resource-manager/readme.md"
11+
}

sdk/search/azure-mgmt-search/azure/mgmt/search/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
__version__ = VERSION
1313
__all__ = ['SearchManagementClient']
1414

15-
try:
16-
from ._patch import patch_sdk # type: ignore
17-
patch_sdk()
18-
except ImportError:
19-
pass
15+
# `._patch.py` is used for handwritten extensions to the generated code
16+
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
17+
from ._patch import patch_sdk
18+
patch_sdk()

sdk/search/azure-mgmt-search/azure/mgmt/search/_configuration.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from typing import Any, TYPE_CHECKING
1010

1111
from azure.core.configuration import Configuration
1212
from azure.core.pipeline import policies
13-
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
13+
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1414

1515
from ._version import VERSION
1616

1717
if TYPE_CHECKING:
1818
# pylint: disable=unused-import,ungrouped-imports
19-
from typing import Any
20-
2119
from azure.core.credentials import TokenCredential
2220

2321

@@ -35,16 +33,15 @@ class SearchManagementClientConfiguration(Configuration):
3533

3634
def __init__(
3735
self,
38-
credential, # type: "TokenCredential"
39-
subscription_id, # type: str
40-
**kwargs # type: Any
41-
):
42-
# type: (...) -> None
36+
credential: "TokenCredential",
37+
subscription_id: str,
38+
**kwargs: Any
39+
) -> None:
40+
super(SearchManagementClientConfiguration, self).__init__(**kwargs)
4341
if credential is None:
4442
raise ValueError("Parameter 'credential' must not be None.")
4543
if subscription_id is None:
4644
raise ValueError("Parameter 'subscription_id' must not be None.")
47-
super(SearchManagementClientConfiguration, self).__init__(**kwargs)
4845

4946
self.credential = credential
5047
self.subscription_id = subscription_id
@@ -68,4 +65,4 @@ def _configure(
6865
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
6966
self.authentication_policy = kwargs.get('authentication_policy')
7067
if self.credential and not self.authentication_policy:
71-
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
68+
self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"chosen_version": "2020-08-01",
3+
"total_api_version_list": ["2020-08-01"],
4+
"client": {
5+
"name": "SearchManagementClient",
6+
"filename": "_search_management_client",
7+
"description": "Client that can be used to manage Azure Cognitive Search services and API keys.",
8+
"host_value": "\"https://management.azure.com\"",
9+
"parameterized_host_template": null,
10+
"azure_arm": true,
11+
"has_lro_operations": true,
12+
"client_side_validation": false,
13+
"sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SearchManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}",
14+
"async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SearchManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}"
15+
},
16+
"global_parameters": {
17+
"sync": {
18+
"credential": {
19+
"signature": "credential, # type: \"TokenCredential\"",
20+
"description": "Credential needed for the client to connect to Azure.",
21+
"docstring_type": "~azure.core.credentials.TokenCredential",
22+
"required": true
23+
},
24+
"subscription_id": {
25+
"signature": "subscription_id, # type: str",
26+
"description": "The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.",
27+
"docstring_type": "str",
28+
"required": true
29+
}
30+
},
31+
"async": {
32+
"credential": {
33+
"signature": "credential: \"AsyncTokenCredential\",",
34+
"description": "Credential needed for the client to connect to Azure.",
35+
"docstring_type": "~azure.core.credentials_async.AsyncTokenCredential",
36+
"required": true
37+
},
38+
"subscription_id": {
39+
"signature": "subscription_id: str,",
40+
"description": "The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.",
41+
"docstring_type": "str",
42+
"required": true
43+
}
44+
},
45+
"constant": {
46+
},
47+
"call": "credential, subscription_id",
48+
"service_client_specific": {
49+
"sync": {
50+
"api_version": {
51+
"signature": "api_version=None, # type: Optional[str]",
52+
"description": "API version to use if no profile is provided, or if missing in profile.",
53+
"docstring_type": "str",
54+
"required": false
55+
},
56+
"base_url": {
57+
"signature": "base_url=\"https://management.azure.com\", # type: str",
58+
"description": "Service URL",
59+
"docstring_type": "str",
60+
"required": false
61+
},
62+
"profile": {
63+
"signature": "profile=KnownProfiles.default, # type: KnownProfiles",
64+
"description": "A profile definition, from KnownProfiles to dict.",
65+
"docstring_type": "azure.profiles.KnownProfiles",
66+
"required": false
67+
}
68+
},
69+
"async": {
70+
"api_version": {
71+
"signature": "api_version: Optional[str] = None,",
72+
"description": "API version to use if no profile is provided, or if missing in profile.",
73+
"docstring_type": "str",
74+
"required": false
75+
},
76+
"base_url": {
77+
"signature": "base_url: str = \"https://management.azure.com\",",
78+
"description": "Service URL",
79+
"docstring_type": "str",
80+
"required": false
81+
},
82+
"profile": {
83+
"signature": "profile: KnownProfiles = KnownProfiles.default,",
84+
"description": "A profile definition, from KnownProfiles to dict.",
85+
"docstring_type": "azure.profiles.KnownProfiles",
86+
"required": false
87+
}
88+
}
89+
}
90+
},
91+
"config": {
92+
"credential": true,
93+
"credential_scopes": ["https://management.azure.com/.default"],
94+
"credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)",
95+
"credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)",
96+
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
97+
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
98+
},
99+
"operation_groups": {
100+
"operations": "Operations",
101+
"admin_keys": "AdminKeysOperations",
102+
"query_keys": "QueryKeysOperations",
103+
"services": "ServicesOperations",
104+
"private_link_resources": "PrivateLinkResourcesOperations",
105+
"private_endpoint_connections": "PrivateEndpointConnectionsOperations",
106+
"shared_private_link_resources": "SharedPrivateLinkResourcesOperations"
107+
}
108+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
#
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
#
6+
# The MIT License (MIT)
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the ""Software""), to
10+
# deal in the Software without restriction, including without limitation the
11+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12+
# sell copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24+
# IN THE SOFTWARE.
25+
#
26+
# --------------------------------------------------------------------------
27+
28+
# This file is used for handwritten extensions to the generated code. Example:
29+
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
30+
def patch_sdk():
31+
pass

sdk/search/azure-mgmt-search/azure/mgmt/search/_search_management_client.py

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,22 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, Optional, TYPE_CHECKING
1011

12+
from azure.core.rest import HttpRequest, HttpResponse
1113
from azure.mgmt.core import ARMPipelineClient
1214
from msrest import Deserializer, Serializer
1315

16+
from . import models
17+
from ._configuration import SearchManagementClientConfiguration
18+
from .operations import AdminKeysOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueryKeysOperations, ServicesOperations, SharedPrivateLinkResourcesOperations
19+
1420
if TYPE_CHECKING:
1521
# pylint: disable=unused-import,ungrouped-imports
16-
from typing import Any, Optional
17-
1822
from azure.core.credentials import TokenCredential
1923

20-
from ._configuration import SearchManagementClientConfiguration
21-
from .operations import Operations
22-
from .operations import AdminKeysOperations
23-
from .operations import QueryKeysOperations
24-
from .operations import ServicesOperations
25-
from .operations import PrivateLinkResourcesOperations
26-
from .operations import PrivateEndpointConnectionsOperations
27-
from .operations import SharedPrivateLinkResourcesOperations
28-
from . import models
29-
30-
31-
class SearchManagementClient(object):
24+
class SearchManagementClient:
3225
"""Client that can be used to manage Azure Cognitive Search services and API keys.
3326
3427
:ivar operations: Operations operations
@@ -42,49 +35,70 @@ class SearchManagementClient(object):
4235
:ivar private_link_resources: PrivateLinkResourcesOperations operations
4336
:vartype private_link_resources: azure.mgmt.search.operations.PrivateLinkResourcesOperations
4437
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
45-
:vartype private_endpoint_connections: azure.mgmt.search.operations.PrivateEndpointConnectionsOperations
38+
:vartype private_endpoint_connections:
39+
azure.mgmt.search.operations.PrivateEndpointConnectionsOperations
4640
:ivar shared_private_link_resources: SharedPrivateLinkResourcesOperations operations
47-
:vartype shared_private_link_resources: azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations
41+
:vartype shared_private_link_resources:
42+
azure.mgmt.search.operations.SharedPrivateLinkResourcesOperations
4843
:param credential: Credential needed for the client to connect to Azure.
4944
:type credential: ~azure.core.credentials.TokenCredential
50-
:param subscription_id: The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.
45+
:param subscription_id: The unique identifier for a Microsoft Azure subscription. You can
46+
obtain this value from the Azure Resource Manager API or the portal.
5147
:type subscription_id: str
52-
:param str base_url: Service URL
53-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
48+
:param base_url: Service URL. Default value is 'https://management.azure.com'.
49+
:type base_url: str
50+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
51+
Retry-After header is present.
5452
"""
5553

5654
def __init__(
5755
self,
58-
credential, # type: "TokenCredential"
59-
subscription_id, # type: str
60-
base_url=None, # type: Optional[str]
61-
**kwargs # type: Any
62-
):
63-
# type: (...) -> None
64-
if not base_url:
65-
base_url = 'https://management.azure.com'
66-
self._config = SearchManagementClientConfiguration(credential, subscription_id, **kwargs)
56+
credential: "TokenCredential",
57+
subscription_id: str,
58+
base_url: str = "https://management.azure.com",
59+
**kwargs: Any
60+
) -> None:
61+
self._config = SearchManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
6762
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
6863

6964
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
7065
self._serialize = Serializer(client_models)
71-
self._serialize.client_side_validation = False
7266
self._deserialize = Deserializer(client_models)
67+
self._serialize.client_side_validation = False
68+
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
69+
self.admin_keys = AdminKeysOperations(self._client, self._config, self._serialize, self._deserialize)
70+
self.query_keys = QueryKeysOperations(self._client, self._config, self._serialize, self._deserialize)
71+
self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize)
72+
self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize)
73+
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
74+
self.shared_private_link_resources = SharedPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize)
75+
76+
77+
def _send_request(
78+
self,
79+
request, # type: HttpRequest
80+
**kwargs: Any
81+
) -> HttpResponse:
82+
"""Runs the network request through the client's chained policies.
83+
84+
>>> from azure.core.rest import HttpRequest
85+
>>> request = HttpRequest("GET", "https://www.example.org/")
86+
<HttpRequest [GET], url: 'https://www.example.org/'>
87+
>>> response = client._send_request(request)
88+
<HttpResponse: 200 OK>
89+
90+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
91+
92+
:param request: The network request you want to make. Required.
93+
:type request: ~azure.core.rest.HttpRequest
94+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
95+
:return: The response of your network call. Does not do error handling on your response.
96+
:rtype: ~azure.core.rest.HttpResponse
97+
"""
7398

74-
self.operations = Operations(
75-
self._client, self._config, self._serialize, self._deserialize)
76-
self.admin_keys = AdminKeysOperations(
77-
self._client, self._config, self._serialize, self._deserialize)
78-
self.query_keys = QueryKeysOperations(
79-
self._client, self._config, self._serialize, self._deserialize)
80-
self.services = ServicesOperations(
81-
self._client, self._config, self._serialize, self._deserialize)
82-
self.private_link_resources = PrivateLinkResourcesOperations(
83-
self._client, self._config, self._serialize, self._deserialize)
84-
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(
85-
self._client, self._config, self._serialize, self._deserialize)
86-
self.shared_private_link_resources = SharedPrivateLinkResourcesOperations(
87-
self._client, self._config, self._serialize, self._deserialize)
99+
request_copy = deepcopy(request)
100+
request_copy.url = self._client.format_url(request_copy.url)
101+
return self._client.send_request(request_copy, **kwargs)
88102

89103
def close(self):
90104
# type: () -> None
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from azure.core.pipeline.transport import HttpRequest
9+
10+
def _convert_request(request, files=None):
11+
data = request.content if not files else None
12+
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
13+
if files:
14+
request.set_formdata_body(files)
15+
return request
16+
17+
def _format_url_section(template, **kwargs):
18+
components = template.split("/")
19+
while components:
20+
try:
21+
return template.format(**kwargs)
22+
except KeyError as key:
23+
formatted_components = template.split("/")
24+
components = [
25+
c for c in formatted_components if "{}".format(key.args[0]) not in c
26+
]
27+
template = "/".join(components)

0 commit comments

Comments
 (0)