Skip to content

Commit 48e6720

Browse files
azclibotrakshith91
authored andcommitted
code and test (Azure#23663)
Co-authored-by: PythonSdkPipelines <PythonSdkPipelines>
1 parent fb009b7 commit 48e6720

38 files changed

Lines changed: 4345 additions & 5033 deletions

sdk/cognitiveservices/azure-mgmt-cognitiveservices/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 13.1.0 (2022-03-25)
4+
5+
**Features**
6+
7+
- Added operation AccountsOperations.list_models
8+
- Model AccountProperties has a new parameter deletion_date
9+
- Model AccountProperties has a new parameter dynamic_throttling_enabled
10+
- Model AccountProperties has a new parameter scheduled_purge_date
11+
- Model DeploymentScaleSettings has a new parameter active_capacity
12+
313
## 13.0.0 (2021-11-15)
414

515
**Features**
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"autorest": "3.4.5",
2+
"autorest": "3.7.2",
33
"use": [
4-
"@autorest/python@5.8.4",
5-
"@autorest/modelerfour@4.19.2"
4+
"@autorest/python@5.12.0",
5+
"@autorest/modelerfour@4.19.3"
66
],
7-
"commit": "e0b5060d30138df66bd64bf0ca6b2010be18717f",
7+
"commit": "5dad3b83d0926768ede15ed41895d5f38defd512",
88
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9-
"autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5",
9+
"autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2",
1010
"readme": "specification/cognitiveservices/resource-manager/readme.md"
1111
}

sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__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__ = ['CognitiveServicesManagementClient']
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/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py

Lines changed: 54 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,20 @@
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 CognitiveServicesManagementClientConfiguration
18+
from .operations import AccountsOperations, CognitiveServicesManagementClientOperationsMixin, CommitmentPlansOperations, CommitmentTiersOperations, DeletedAccountsOperations, DeploymentsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceSkusOperations
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
19-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
20-
21-
from ._configuration import CognitiveServicesManagementClientConfiguration
22-
from .operations import AccountsOperations
23-
from .operations import DeletedAccountsOperations
24-
from .operations import ResourceSkusOperations
25-
from .operations import Operations
26-
from .operations import CognitiveServicesManagementClientOperationsMixin
27-
from .operations import CommitmentTiersOperations
28-
from .operations import PrivateEndpointConnectionsOperations
29-
from .operations import PrivateLinkResourcesOperations
30-
from .operations import DeploymentsOperations
31-
from .operations import CommitmentPlansOperations
32-
from . import models
33-
3423

3524
class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin):
3625
"""Cognitive Services Management Client.
@@ -46,9 +35,11 @@ class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperati
4635
:ivar commitment_tiers: CommitmentTiersOperations operations
4736
:vartype commitment_tiers: azure.mgmt.cognitiveservices.operations.CommitmentTiersOperations
4837
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
49-
:vartype private_endpoint_connections: azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations
38+
:vartype private_endpoint_connections:
39+
azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations
5040
:ivar private_link_resources: PrivateLinkResourcesOperations operations
51-
:vartype private_link_resources: azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations
41+
:vartype private_link_resources:
42+
azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations
5243
:ivar deployments: DeploymentsOperations operations
5344
:vartype deployments: azure.mgmt.cognitiveservices.operations.DeploymentsOperations
5445
:ivar commitment_plans: CommitmentPlansOperations operations
@@ -57,64 +48,62 @@ class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperati
5748
:type credential: ~azure.core.credentials.TokenCredential
5849
:param subscription_id: The ID of the target subscription.
5950
:type subscription_id: str
60-
:param str base_url: Service URL
61-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
51+
:param base_url: Service URL. Default value is 'https://management.azure.com'.
52+
:type base_url: str
53+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
54+
Retry-After header is present.
6255
"""
6356

6457
def __init__(
6558
self,
66-
credential, # type: "TokenCredential"
67-
subscription_id, # type: str
68-
base_url=None, # type: Optional[str]
69-
**kwargs # type: Any
70-
):
71-
# type: (...) -> None
72-
if not base_url:
73-
base_url = 'https://management.azure.com'
74-
self._config = CognitiveServicesManagementClientConfiguration(credential, subscription_id, **kwargs)
59+
credential: "TokenCredential",
60+
subscription_id: str,
61+
base_url: str = "https://management.azure.com",
62+
**kwargs: Any
63+
) -> None:
64+
self._config = CognitiveServicesManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
7565
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
7666

7767
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
7868
self._serialize = Serializer(client_models)
79-
self._serialize.client_side_validation = False
8069
self._deserialize = Deserializer(client_models)
81-
82-
self.accounts = AccountsOperations(
83-
self._client, self._config, self._serialize, self._deserialize)
84-
self.deleted_accounts = DeletedAccountsOperations(
85-
self._client, self._config, self._serialize, self._deserialize)
86-
self.resource_skus = ResourceSkusOperations(
87-
self._client, self._config, self._serialize, self._deserialize)
88-
self.operations = Operations(
89-
self._client, self._config, self._serialize, self._deserialize)
90-
self.commitment_tiers = CommitmentTiersOperations(
91-
self._client, self._config, self._serialize, self._deserialize)
92-
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(
93-
self._client, self._config, self._serialize, self._deserialize)
94-
self.private_link_resources = PrivateLinkResourcesOperations(
95-
self._client, self._config, self._serialize, self._deserialize)
96-
self.deployments = DeploymentsOperations(
97-
self._client, self._config, self._serialize, self._deserialize)
98-
self.commitment_plans = CommitmentPlansOperations(
99-
self._client, self._config, self._serialize, self._deserialize)
100-
101-
def _send_request(self, http_request, **kwargs):
102-
# type: (HttpRequest, Any) -> HttpResponse
70+
self._serialize.client_side_validation = False
71+
self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize)
72+
self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize)
73+
self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize)
74+
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
75+
self.commitment_tiers = CommitmentTiersOperations(self._client, self._config, self._serialize, self._deserialize)
76+
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
77+
self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize)
78+
self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize)
79+
self.commitment_plans = CommitmentPlansOperations(self._client, self._config, self._serialize, self._deserialize)
80+
81+
82+
def _send_request(
83+
self,
84+
request, # type: HttpRequest
85+
**kwargs: Any
86+
) -> HttpResponse:
10387
"""Runs the network request through the client's chained policies.
10488
105-
:param http_request: The network request you want to make. Required.
106-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
107-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
89+
>>> from azure.core.rest import HttpRequest
90+
>>> request = HttpRequest("GET", "https://www.example.org/")
91+
<HttpRequest [GET], url: 'https://www.example.org/'>
92+
>>> response = client._send_request(request)
93+
<HttpResponse: 200 OK>
94+
95+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
96+
97+
:param request: The network request you want to make. Required.
98+
:type request: ~azure.core.rest.HttpRequest
99+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
108100
:return: The response of your network call. Does not do error handling on your response.
109-
:rtype: ~azure.core.pipeline.transport.HttpResponse
101+
:rtype: ~azure.core.rest.HttpResponse
110102
"""
111-
path_format_arguments = {
112-
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
113-
}
114-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
115-
stream = kwargs.pop("stream", True)
116-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
117-
return pipeline_response.http_response
103+
104+
request_copy = deepcopy(request)
105+
request_copy.url = self._client.format_url(request_copy.url)
106+
return self._client.send_request(request_copy, **kwargs)
118107

119108
def close(self):
120109
# type: () -> None

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

Lines changed: 9 additions & 12 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,20 +33,19 @@ class CognitiveServicesManagementClientConfiguration(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(CognitiveServicesManagementClientConfiguration, 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(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs)
4845

4946
self.credential = credential
5047
self.subscription_id = subscription_id
51-
self.api_version = "2021-10-01"
48+
self.api_version = "2022-03-01"
5249
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
5350
kwargs.setdefault('sdk_moniker', 'mgmt-cognitiveservices/{}'.format(VERSION))
5451
self._configure(**kwargs)
@@ -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)

0 commit comments

Comments
 (0)