Skip to content

Commit 9f993b4

Browse files
author
SDKAuto
committed
CodeGen from PR 15007 in Azure/azure-rest-api-specs
Merge e98221e59c3b1b8f6ec54a662d3c735bd2eeee00 into 3cf8aa9
1 parent f897769 commit 9f993b4

18 files changed

+390
-120
lines changed

sdk/advisor/azure-mgmt-advisor/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include _meta.json
12
recursive-include tests *.py *.yaml
23
include *.md
34
include azure/__init__.py
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"autorest": "3.4.2",
3+
"use": [
4+
"@autorest/[email protected]",
5+
"@autorest/[email protected]"
6+
],
7+
"commit": "532e2ea87d651e2888ffa86dc3a5ec7402c4d393",
8+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9+
"autorest_command": "autorest specification/advisor/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/[email protected] --use=@autorest/[email protected] --version=3.4.2",
10+
"readme": "specification/advisor/resource-manager/readme.md"
11+
}

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from typing import Any, Optional
1717

1818
from azure.core.credentials import TokenCredential
19+
from azure.core.pipeline.transport import HttpRequest, HttpResponse
1920

2021
from ._configuration import AdvisorManagementClientConfiguration
2122
from .operations import RecommendationMetadataOperations
@@ -75,6 +76,24 @@ def __init__(
7576
self.suppressions = SuppressionsOperations(
7677
self._client, self._config, self._serialize, self._deserialize)
7778

79+
def _send_request(self, http_request, **kwargs):
80+
# type: (HttpRequest, Any) -> HttpResponse
81+
"""Runs the network request through the client's chained policies.
82+
83+
:param http_request: The network request you want to make. Required.
84+
:type http_request: ~azure.core.pipeline.transport.HttpRequest
85+
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
86+
:return: The response of your network call. Does not do error handling on your response.
87+
:rtype: ~azure.core.pipeline.transport.HttpResponse
88+
"""
89+
path_format_arguments = {
90+
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
91+
}
92+
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
93+
stream = kwargs.pop("stream", True)
94+
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
95+
return pipeline_response.http_response
96+
7897
def close(self):
7998
# type: () -> None
8099
self._client.close()
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"chosen_version": "2020-01-01",
3+
"total_api_version_list": ["2020-01-01"],
4+
"client": {
5+
"name": "AdvisorManagementClient",
6+
"filename": "_advisor_management_client",
7+
"description": "REST APIs for Azure Advisor.",
8+
"base_url": "\u0027https://management.azure.com\u0027",
9+
"custom_base_url": null,
10+
"azure_arm": true,
11+
"has_lro_operations": false,
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\": [\"AdvisorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}",
14+
"async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AdvisorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}"
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 Azure subscription ID.",
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 Azure subscription ID.",
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=None, # type: Optional[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: Optional[str] = None,",
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_default_policy_type": "BearerTokenCredentialPolicy",
95+
"credential_default_policy_type_has_async_version": true,
96+
"credential_key_header_name": null,
97+
"sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
98+
"async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
99+
},
100+
"operation_groups": {
101+
"recommendation_metadata": "RecommendationMetadataOperations",
102+
"configurations": "ConfigurationsOperations",
103+
"recommendations": "RecommendationsOperations",
104+
"operations": "Operations",
105+
"suppressions": "SuppressionsOperations"
106+
}
107+
}

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "9.0.0"
9+
VERSION = "9.0.0b1"

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/_advisor_management_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from typing import Any, Optional, TYPE_CHECKING
1010

11+
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
1112
from azure.mgmt.core import AsyncARMPipelineClient
1213
from msrest import Deserializer, Serializer
1314

@@ -72,6 +73,23 @@ def __init__(
7273
self.suppressions = SuppressionsOperations(
7374
self._client, self._config, self._serialize, self._deserialize)
7475

76+
async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
77+
"""Runs the network request through the client's chained policies.
78+
79+
:param http_request: The network request you want to make. Required.
80+
:type http_request: ~azure.core.pipeline.transport.HttpRequest
81+
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
82+
:return: The response of your network call. Does not do error handling on your response.
83+
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
84+
"""
85+
path_format_arguments = {
86+
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
87+
}
88+
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
89+
stream = kwargs.pop("stream", True)
90+
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
91+
return pipeline_response.http_response
92+
7593
async def close(self) -> None:
7694
await self._client.close()
7795

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_configurations_operations.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:
4343

4444
def list_by_subscription(
4545
self,
46-
**kwargs
46+
**kwargs: Any
4747
) -> AsyncIterable["_models.ConfigurationListResult"]:
4848
"""Retrieve Azure Advisor configurations.
4949
@@ -100,7 +100,7 @@ async def get_next(next_link=None):
100100
response = pipeline_response.http_response
101101

102102
if response.status_code not in [200]:
103-
error = self._deserialize(_models.ArmErrorResponse, response)
103+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
104104
map_error(status_code=response.status_code, response=response, error_map=error_map)
105105
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
106106

@@ -115,7 +115,7 @@ async def create_in_subscription(
115115
self,
116116
configuration_name: Union[str, "_models.ConfigurationName"],
117117
config_contract: "_models.ConfigData",
118-
**kwargs
118+
**kwargs: Any
119119
) -> "_models.ConfigData":
120120
"""Create/Overwrite Azure Advisor configuration.
121121
@@ -166,7 +166,7 @@ async def create_in_subscription(
166166

167167
if response.status_code not in [200]:
168168
map_error(status_code=response.status_code, response=response, error_map=error_map)
169-
error = self._deserialize(_models.ArmErrorResponse, response)
169+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
170170
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
171171

172172
deserialized = self._deserialize('ConfigData', pipeline_response)
@@ -180,7 +180,7 @@ async def create_in_subscription(
180180
def list_by_resource_group(
181181
self,
182182
resource_group: str,
183-
**kwargs
183+
**kwargs: Any
184184
) -> AsyncIterable["_models.ConfigurationListResult"]:
185185
"""Retrieve Azure Advisor configurations.
186186
@@ -239,7 +239,7 @@ async def get_next(next_link=None):
239239
response = pipeline_response.http_response
240240

241241
if response.status_code not in [200]:
242-
error = self._deserialize(_models.ArmErrorResponse, response)
242+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
243243
map_error(status_code=response.status_code, response=response, error_map=error_map)
244244
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
245245

@@ -255,7 +255,7 @@ async def create_in_resource_group(
255255
configuration_name: Union[str, "_models.ConfigurationName"],
256256
resource_group: str,
257257
config_contract: "_models.ConfigData",
258-
**kwargs
258+
**kwargs: Any
259259
) -> "_models.ConfigData":
260260
"""Create/Overwrite Azure Advisor configuration.
261261
@@ -308,7 +308,7 @@ async def create_in_resource_group(
308308

309309
if response.status_code not in [200]:
310310
map_error(status_code=response.status_code, response=response, error_map=error_map)
311-
error = self._deserialize(_models.ArmErrorResponse, response)
311+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
312312
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
313313

314314
deserialized = self._deserialize('ConfigData', pipeline_response)

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_operations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None:
4343

4444
def list(
4545
self,
46-
**kwargs
46+
**kwargs: Any
4747
) -> AsyncIterable["_models.OperationEntityListResult"]:
4848
"""Lists all the available Advisor REST API operations.
4949
@@ -93,8 +93,9 @@ async def get_next(next_link=None):
9393
response = pipeline_response.http_response
9494

9595
if response.status_code not in [200]:
96+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
9697
map_error(status_code=response.status_code, response=response, error_map=error_map)
97-
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
98+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
9899

99100
return pipeline_response
100101

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendation_metadata_operations.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Code generated by Microsoft (R) AutoRest Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8-
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
8+
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
99
import warnings
1010

1111
from azure.core.async_paging import AsyncItemPaged, AsyncList
@@ -44,22 +44,24 @@ def __init__(self, client, config, serializer, deserializer) -> None:
4444
async def get(
4545
self,
4646
name: str,
47-
**kwargs
48-
) -> Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"]:
47+
**kwargs: Any
48+
) -> "_models.MetadataEntity":
4949
"""Gets the metadata entity.
5050
5151
Gets the metadata entity.
5252
5353
:param name: Name of metadata entity.
5454
:type name: str
5555
:keyword callable cls: A custom type or function that will be passed the direct response
56-
:return: MetadataEntity or ARMErrorResponseBody, or the result of cls(response)
57-
:rtype: ~azure.mgmt.advisor.models.MetadataEntity or ~azure.mgmt.advisor.models.ARMErrorResponseBody
56+
:return: MetadataEntity, or the result of cls(response)
57+
:rtype: ~azure.mgmt.advisor.models.MetadataEntity
5858
:raises: ~azure.core.exceptions.HttpResponseError
5959
"""
60-
cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"]]
60+
cls = kwargs.pop('cls', None) # type: ClsType["_models.MetadataEntity"]
6161
error_map = {
62-
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
62+
401: ClientAuthenticationError,
63+
409: ResourceExistsError,
64+
404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ARMErrorResponseBody, response), error_format=ARMErrorFormat),
6365
}
6466
error_map.update(kwargs.pop('error_map', {}))
6567
api_version = "2020-01-01"
@@ -84,15 +86,12 @@ async def get(
8486
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
8587
response = pipeline_response.http_response
8688

87-
if response.status_code not in [200, 404]:
89+
if response.status_code not in [200]:
8890
map_error(status_code=response.status_code, response=response, error_map=error_map)
89-
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
90-
91-
if response.status_code == 200:
92-
deserialized = self._deserialize('MetadataEntity', pipeline_response)
91+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
92+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
9393

94-
if response.status_code == 404:
95-
deserialized = self._deserialize('ARMErrorResponseBody', pipeline_response)
94+
deserialized = self._deserialize('MetadataEntity', pipeline_response)
9695

9796
if cls:
9897
return cls(pipeline_response, deserialized, {})
@@ -102,7 +101,7 @@ async def get(
102101

103102
def list(
104103
self,
105-
**kwargs
104+
**kwargs: Any
106105
) -> AsyncIterable["_models.MetadataEntityListResult"]:
107106
"""Gets the list of metadata entities.
108107
@@ -154,8 +153,9 @@ async def get_next(next_link=None):
154153
response = pipeline_response.http_response
155154

156155
if response.status_code not in [200]:
156+
error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response)
157157
map_error(status_code=response.status_code, response=response, error_map=error_map)
158-
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
158+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
159159

160160
return pipeline_response
161161

0 commit comments

Comments
 (0)