Skip to content

Commit 3ed9aac

Browse files
[AutoRelease] t2-maintenance-2023-10-20-10018(can only be merged by SDK owner) (Azure#32596)
* code and test * Update CHANGELOG.md --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <[email protected]>
1 parent 592bd93 commit 3ed9aac

File tree

63 files changed

+618
-162
lines changed

Some content is hidden

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

63 files changed

+618
-162
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 2.2.0b1 (2023-10-22)
4+
5+
### Features Added
6+
7+
- Added operation ApplyUpdatesOperations.create_or_update_or_cancel
8+
39
## 2.1.0 (2023-08-18)
410

511
### Features Added

sdk/maintenance/azure-mgmt-maintenance/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,3 @@ Code samples for this package can be found at:
5959
If you encounter any bugs or have suggestions, please file an issue in the
6060
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
6161
section of the project.
62-
63-
64-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-maintenance%2FREADME.png)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "3731ac6150dcb22856183e9f1ca49eb912459f83",
2+
"commit": "e6d90862a97c4f04f0c26a8869602bbfd8b10280",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.9.7",
55
"use": [
6-
"@autorest/python@6.6.0",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.7.1",
7+
"@autorest/modelerfour@4.26.2"
88
],
9-
"autorest_command": "autorest specification/maintenance/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/maintenance/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
1010
"readme": "specification/maintenance/resource-manager/readme.md"
1111
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class MaintenanceManagementClientConfiguration(Configuration): # pylint: disabl
3030
:param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure
3131
subscription. The subscription ID forms part of the URI for every service call. Required.
3232
:type subscription_id: str
33-
:keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this
34-
default value may result in unsupported behavior.
33+
:keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding
34+
this default value may result in unsupported behavior.
3535
:paramtype api_version: str
3636
"""
3737

3838
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
3939
super(MaintenanceManagementClientConfiguration, self).__init__(**kwargs)
40-
api_version: str = kwargs.pop("api_version", "2023-04-01")
40+
api_version: str = kwargs.pop("api_version", "2023-09-01-preview")
4141

4242
if credential is None:
4343
raise ValueError("Parameter 'credential' must not be None.")

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version
7878
:type subscription_id: str
7979
:param base_url: Service URL. Default value is "https://management.azure.com".
8080
:type base_url: str
81-
:keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this
82-
default value may result in unsupported behavior.
81+
:keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding
82+
this default value may result in unsupported behavior.
8383
:paramtype api_version: str
8484
"""
8585

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_serialization.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
662662
_serialized.update(_new_attr) # type: ignore
663663
_new_attr = _new_attr[k] # type: ignore
664664
_serialized = _serialized[k]
665-
except ValueError:
666-
continue
665+
except ValueError as err:
666+
if isinstance(err, SerializationError):
667+
raise
667668

668669
except (AttributeError, KeyError, TypeError) as err:
669670
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
@@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):
741742
742743
:param data: The data to be serialized.
743744
:param str data_type: The type to be serialized from.
745+
:keyword bool skip_quote: Whether to skip quote the serialized result.
746+
Defaults to False.
744747
:rtype: str
745748
:raises: TypeError if serialization fails.
746749
:raises: ValueError if data is None
@@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
749752
# Treat the list aside, since we don't want to encode the div separator
750753
if data_type.startswith("["):
751754
internal_data_type = data_type[1:-1]
752-
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
753-
if not kwargs.get("skip_quote", False):
754-
data = [quote(str(d), safe="") for d in data]
755-
return str(self.serialize_iter(data, internal_data_type, **kwargs))
755+
do_quote = not kwargs.get("skip_quote", False)
756+
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))
756757

757758
# Not a list, regular serialization
758759
output = self.serialize_data(data, data_type, **kwargs)
@@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
891892
not be None or empty.
892893
:param str div: If set, this str will be used to combine the elements
893894
in the iterable into a combined string. Default is 'None'.
895+
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
896+
Defaults to False.
894897
:rtype: list, str
895898
"""
896899
if isinstance(data, str):
@@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
903906
for d in data:
904907
try:
905908
serialized.append(self.serialize_data(d, iter_type, **kwargs))
906-
except ValueError:
909+
except ValueError as err:
910+
if isinstance(err, SerializationError):
911+
raise
907912
serialized.append(None)
908913

914+
if kwargs.get("do_quote", False):
915+
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]
916+
909917
if div:
910918
serialized = ["" if s is None else str(s) for s in serialized]
911919
serialized = div.join(serialized)
@@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
950958
for key, value in attr.items():
951959
try:
952960
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
953-
except ValueError:
961+
except ValueError as err:
962+
if isinstance(err, SerializationError):
963+
raise
954964
serialized[self.serialize_unicode(key)] = None
955965

956966
if "xml" in serialization_ctxt:

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py

-14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
66
# --------------------------------------------------------------------------
77

8-
from typing import List, cast
9-
108
from azure.core.pipeline.transport import HttpRequest
119

1210

@@ -16,15 +14,3 @@ def _convert_request(request, files=None):
1614
if files:
1715
request.set_formdata_body(files)
1816
return request
19-
20-
21-
def _format_url_section(template, **kwargs):
22-
components = template.split("/")
23-
while components:
24-
try:
25-
return template.format(**kwargs)
26-
except KeyError as key:
27-
# Need the cast, as for some reasons "split" is typed as list[str | Any]
28-
formatted_components = cast(List[str], template.split("/"))
29-
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
30-
template = "/".join(components)

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

+1-1
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 = "2.1.0"
9+
VERSION = "2.2.0b1"

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class MaintenanceManagementClientConfiguration(Configuration): # pylint: disabl
3030
:param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure
3131
subscription. The subscription ID forms part of the URI for every service call. Required.
3232
:type subscription_id: str
33-
:keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this
34-
default value may result in unsupported behavior.
33+
:keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding
34+
this default value may result in unsupported behavior.
3535
:paramtype api_version: str
3636
"""
3737

3838
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
3939
super(MaintenanceManagementClientConfiguration, self).__init__(**kwargs)
40-
api_version: str = kwargs.pop("api_version", "2023-04-01")
40+
api_version: str = kwargs.pop("api_version", "2023-09-01-preview")
4141

4242
if credential is None:
4343
raise ValueError("Parameter 'credential' must not be None.")

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version
7878
:type subscription_id: str
7979
:param base_url: Service URL. Default value is "https://management.azure.com".
8080
:type base_url: str
81-
:keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this
82-
default value may result in unsupported behavior.
81+
:keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding
82+
this default value may result in unsupported behavior.
8383
:paramtype api_version: str
8484
"""
8585

sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py

+182-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# Code generated by Microsoft (R) AutoRest Code Generator.
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
9-
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
9+
from io import IOBase
10+
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
1011
import urllib.parse
1112

1213
from azure.core.async_paging import AsyncItemPaged, AsyncList
@@ -29,6 +30,7 @@
2930
from ... import models as _models
3031
from ..._vendor import _convert_request
3132
from ...operations._apply_updates_operations import (
33+
build_create_or_update_or_cancel_request,
3234
build_create_or_update_parent_request,
3335
build_create_or_update_request,
3436
build_get_parent_request,
@@ -229,6 +231,185 @@ async def get(
229231
"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"
230232
}
231233

234+
@overload
235+
async def create_or_update_or_cancel(
236+
self,
237+
resource_group_name: str,
238+
provider_name: str,
239+
resource_type: str,
240+
resource_name: str,
241+
apply_update_name: str,
242+
apply_update: _models.ApplyUpdate,
243+
*,
244+
content_type: str = "application/json",
245+
**kwargs: Any
246+
) -> _models.ApplyUpdate:
247+
"""Apply Updates to resource.
248+
249+
Apply maintenance updates to resource.
250+
251+
:param resource_group_name: Resource group name. Required.
252+
:type resource_group_name: str
253+
:param provider_name: Resource provider name. Required.
254+
:type provider_name: str
255+
:param resource_type: Resource type. Required.
256+
:type resource_type: str
257+
:param resource_name: Resource identifier. Required.
258+
:type resource_name: str
259+
:param apply_update_name: ApplyUpdate name. Required.
260+
:type apply_update_name: str
261+
:param apply_update: The ApplyUpdate. Required.
262+
:type apply_update: ~azure.mgmt.maintenance.models.ApplyUpdate
263+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
264+
Default value is "application/json".
265+
:paramtype content_type: str
266+
:keyword callable cls: A custom type or function that will be passed the direct response
267+
:return: ApplyUpdate or the result of cls(response)
268+
:rtype: ~azure.mgmt.maintenance.models.ApplyUpdate
269+
:raises ~azure.core.exceptions.HttpResponseError:
270+
"""
271+
272+
@overload
273+
async def create_or_update_or_cancel(
274+
self,
275+
resource_group_name: str,
276+
provider_name: str,
277+
resource_type: str,
278+
resource_name: str,
279+
apply_update_name: str,
280+
apply_update: IO,
281+
*,
282+
content_type: str = "application/json",
283+
**kwargs: Any
284+
) -> _models.ApplyUpdate:
285+
"""Apply Updates to resource.
286+
287+
Apply maintenance updates to resource.
288+
289+
:param resource_group_name: Resource group name. Required.
290+
:type resource_group_name: str
291+
:param provider_name: Resource provider name. Required.
292+
:type provider_name: str
293+
:param resource_type: Resource type. Required.
294+
:type resource_type: str
295+
:param resource_name: Resource identifier. Required.
296+
:type resource_name: str
297+
:param apply_update_name: ApplyUpdate name. Required.
298+
:type apply_update_name: str
299+
:param apply_update: The ApplyUpdate. Required.
300+
:type apply_update: IO
301+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
302+
Default value is "application/json".
303+
:paramtype content_type: str
304+
:keyword callable cls: A custom type or function that will be passed the direct response
305+
:return: ApplyUpdate or the result of cls(response)
306+
:rtype: ~azure.mgmt.maintenance.models.ApplyUpdate
307+
:raises ~azure.core.exceptions.HttpResponseError:
308+
"""
309+
310+
@distributed_trace_async
311+
async def create_or_update_or_cancel(
312+
self,
313+
resource_group_name: str,
314+
provider_name: str,
315+
resource_type: str,
316+
resource_name: str,
317+
apply_update_name: str,
318+
apply_update: Union[_models.ApplyUpdate, IO],
319+
**kwargs: Any
320+
) -> _models.ApplyUpdate:
321+
"""Apply Updates to resource.
322+
323+
Apply maintenance updates to resource.
324+
325+
:param resource_group_name: Resource group name. Required.
326+
:type resource_group_name: str
327+
:param provider_name: Resource provider name. Required.
328+
:type provider_name: str
329+
:param resource_type: Resource type. Required.
330+
:type resource_type: str
331+
:param resource_name: Resource identifier. Required.
332+
:type resource_name: str
333+
:param apply_update_name: ApplyUpdate name. Required.
334+
:type apply_update_name: str
335+
:param apply_update: The ApplyUpdate. Is either a ApplyUpdate type or a IO type. Required.
336+
:type apply_update: ~azure.mgmt.maintenance.models.ApplyUpdate or IO
337+
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
338+
Default value is None.
339+
:paramtype content_type: str
340+
:keyword callable cls: A custom type or function that will be passed the direct response
341+
:return: ApplyUpdate or the result of cls(response)
342+
:rtype: ~azure.mgmt.maintenance.models.ApplyUpdate
343+
:raises ~azure.core.exceptions.HttpResponseError:
344+
"""
345+
error_map = {
346+
401: ClientAuthenticationError,
347+
404: ResourceNotFoundError,
348+
409: ResourceExistsError,
349+
304: ResourceNotModifiedError,
350+
}
351+
error_map.update(kwargs.pop("error_map", {}) or {})
352+
353+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
354+
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
355+
356+
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
357+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
358+
cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None)
359+
360+
content_type = content_type or "application/json"
361+
_json = None
362+
_content = None
363+
if isinstance(apply_update, (IOBase, bytes)):
364+
_content = apply_update
365+
else:
366+
_json = self._serialize.body(apply_update, "ApplyUpdate")
367+
368+
request = build_create_or_update_or_cancel_request(
369+
resource_group_name=resource_group_name,
370+
provider_name=provider_name,
371+
resource_type=resource_type,
372+
resource_name=resource_name,
373+
apply_update_name=apply_update_name,
374+
subscription_id=self._config.subscription_id,
375+
api_version=api_version,
376+
content_type=content_type,
377+
json=_json,
378+
content=_content,
379+
template_url=self.create_or_update_or_cancel.metadata["url"],
380+
headers=_headers,
381+
params=_params,
382+
)
383+
request = _convert_request(request)
384+
request.url = self._client.format_url(request.url)
385+
386+
_stream = False
387+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
388+
request, stream=_stream, **kwargs
389+
)
390+
391+
response = pipeline_response.http_response
392+
393+
if response.status_code not in [200, 201]:
394+
map_error(status_code=response.status_code, response=response, error_map=error_map)
395+
error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response)
396+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
397+
398+
if response.status_code == 200:
399+
deserialized = self._deserialize("ApplyUpdate", pipeline_response)
400+
401+
if response.status_code == 201:
402+
deserialized = self._deserialize("ApplyUpdate", pipeline_response)
403+
404+
if cls:
405+
return cls(pipeline_response, deserialized, {}) # type: ignore
406+
407+
return deserialized # type: ignore
408+
409+
create_or_update_or_cancel.metadata = {
410+
"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"
411+
}
412+
232413
@distributed_trace_async
233414
async def create_or_update_parent(
234415
self,

0 commit comments

Comments
 (0)