Skip to content

Commit d38a8af

Browse files
[AutoRelease] t2-computeschedule-2025-01-10-50036(can only be merged by SDK owner) (Azure#39105)
* code and test * Update CHANGELOG.md for new model properties --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <[email protected]>
1 parent 79263aa commit d38a8af

File tree

45 files changed

+626
-964
lines changed

Some content is hidden

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

45 files changed

+626
-964
lines changed

sdk/computeschedule/azure-mgmt-computeschedule/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+
## 1.0.0 (2025-01-20)
4+
5+
### Features Added
6+
7+
- Model `OperationErrorDetails` added property `timestamp`
8+
- Model `OperationErrorDetails` added property `azure_operation_name`
9+
- Model `ResourceOperationDetails` added property `timezone`
10+
- Model `Schedule` added property `deadline`
11+
- Model `Schedule` added property `timezone`
12+
313
## 1.0.0b1 (2024-09-26)
414

515
### Other Changes
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "4883fa5dbf6f2c9093fac8ce334547e9dfac68fa",
2+
"commit": "b6075dbc2321933382ea91c787ee62c6bdb87e5d",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/computeschedule/ComputeSchedule.Management",
5-
"@azure-tools/typespec-python": "0.33.0"
5+
"@azure-tools/typespec-python": "0.37.3"
66
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import ComputeScheduleMgmtClient
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 ComputeScheduleMgmtClient # type: ignore
1016
from ._version import VERSION
1117

1218
__version__ = VERSION
1319

1420
try:
1521
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
22+
from ._patch import *
1723
except ImportError:
1824
_patch_all = []
1925
from ._patch import patch_sdk as _patch_sdk
2026

2127
__all__ = [
2228
"ComputeScheduleMgmtClient",
2329
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2531

2632
_patch_sdk()

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
from .operations import Operations, ScheduledActionsOperations
2121

2222
if TYPE_CHECKING:
23-
# pylint: disable=unused-import,ungrouped-imports
2423
from azure.core.credentials import TokenCredential
2524

2625

27-
class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-keyword
26+
class ComputeScheduleMgmtClient:
2827
"""Microsoft.ComputeSchedule Resource Provider management API.
2928
3029
:ivar operations: Operations operations
@@ -37,9 +36,8 @@ class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-k
3736
:type subscription_id: str
3837
:param base_url: Service host. Default value is "https://management.azure.com".
3938
:type base_url: str
40-
:keyword api_version: The API version to use for this operation. Default value is
41-
"2024-08-15-preview". Note that overriding this default value may result in unsupported
42-
behavior.
39+
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
40+
Note that overriding this default value may result in unsupported behavior.
4341
:paramtype api_version: str
4442
"""
4543

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from ._version import VERSION
1515

1616
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1817
from azure.core.credentials import TokenCredential
1918

2019

21-
class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes
2221
"""Configuration for ComputeScheduleMgmtClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
@@ -30,9 +29,8 @@ class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instan
3029
:type subscription_id: str
3130
:param base_url: Service host. Default value is "https://management.azure.com".
3231
:type base_url: str
33-
:keyword api_version: The API version to use for this operation. Default value is
34-
"2024-08-15-preview". Note that overriding this default value may result in unsupported
35-
behavior.
32+
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
33+
Note that overriding this default value may result in unsupported behavior.
3634
:paramtype api_version: str
3735
"""
3836

@@ -43,7 +41,7 @@ def __init__(
4341
base_url: str = "https://management.azure.com",
4442
**kwargs: Any
4543
) -> None:
46-
api_version: str = kwargs.pop("api_version", "2024-08-15-preview")
44+
api_version: str = kwargs.pop("api_version", "2024-10-01")
4745

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

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_model_base.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# pylint: disable=too-many-lines
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
45
# Licensed under the MIT License. See License.txt in the project root for
56
# license information.
67
# --------------------------------------------------------------------------
7-
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
8+
# pylint: disable=protected-access, broad-except
89

910
import copy
1011
import calendar
@@ -573,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
573574
def copy(self) -> "Model":
574575
return Model(self.__dict__)
575576

576-
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument
577+
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
577578
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
578579
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
579580
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
@@ -584,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
584585
annotations = {
585586
k: v
586587
for mro_class in mros
587-
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
588-
for k, v in mro_class.__annotations__.items() # pylint: disable=no-member
588+
if hasattr(mro_class, "__annotations__")
589+
for k, v in mro_class.__annotations__.items()
589590
}
590591
for attr, rf in attr_to_rest_field.items():
591592
rf._module = cls.__module__
@@ -600,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
600601

601602
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
602603
for base in cls.__bases__:
603-
if hasattr(base, "__mapping__"): # pylint: disable=no-member
604-
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
604+
if hasattr(base, "__mapping__"):
605+
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore
605606

606607
@classmethod
607608
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
@@ -612,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField
612613

613614
@classmethod
614615
def _deserialize(cls, data, exist_discriminators):
615-
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
616+
if not hasattr(cls, "__mapping__"):
616617
return cls(data)
617618
discriminator = cls._get_discriminator(exist_discriminators)
618619
if discriminator is None:
@@ -632,11 +633,11 @@ def _deserialize(cls, data, exist_discriminators):
632633
discriminator_value = data.find(xml_name).text # pyright: ignore
633634
else:
634635
discriminator_value = data.get(discriminator._rest_name)
635-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
636+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
636637
return mapped_cls._deserialize(data, exist_discriminators)
637638

638639
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
639-
"""Return a dict that can be JSONify using json.dump.
640+
"""Return a dict that can be turned into json using json.dump.
640641
641642
:keyword bool exclude_readonly: Whether to remove the readonly properties.
642643
:returns: A dict JSON compatible object
@@ -733,7 +734,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An
733734
)
734735

735736

736-
def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912
737+
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches
737738
annotation: typing.Any,
738739
module: typing.Optional[str],
739740
rf: typing.Optional["_RestField"] = None,
@@ -753,7 +754,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915,
753754
except AttributeError:
754755
model_name = annotation
755756
if module is not None:
756-
annotation = _get_model(module, model_name)
757+
annotation = _get_model(module, model_name) # type: ignore
757758

758759
try:
759760
if module and _is_model(annotation):
@@ -893,6 +894,22 @@ def _deserialize(
893894
return _deserialize_with_callable(deserializer, value)
894895

895896

897+
def _failsafe_deserialize(
898+
deserializer: typing.Any,
899+
value: typing.Any,
900+
module: typing.Optional[str] = None,
901+
rf: typing.Optional["_RestField"] = None,
902+
format: typing.Optional[str] = None,
903+
) -> typing.Any:
904+
try:
905+
return _deserialize(deserializer, value, module, rf, format)
906+
except DeserializationError:
907+
_LOGGER.warning(
908+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
909+
)
910+
return None
911+
912+
896913
class _RestField:
897914
def __init__(
898915
self,

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore
227227
:param datetime.timedelta offset: offset in timedelta format
228228
"""
229229

230-
def __init__(self, offset):
230+
def __init__(self, offset) -> None:
231231
self.__offset = offset
232232

233233
def utcoffset(self, dt):
@@ -310,7 +310,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
310310
return ET.Element(tag)
311311

312312

313-
class Model(object):
313+
class Model:
314314
"""Mixin for all client request body/response body models to support
315315
serialization and deserialization.
316316
"""
@@ -507,7 +507,6 @@ def _flatten_subtype(cls, key, objects):
507507
def _classify(cls, response, objects):
508508
"""Check the class _subtype_map for any child classes.
509509
We want to ignore any inherited _subtype_maps.
510-
Remove the polymorphic key from the initial data.
511510
512511
:param dict response: The initial data
513512
:param dict objects: The class objects
@@ -519,7 +518,7 @@ def _classify(cls, response, objects):
519518

520519
if not isinstance(response, ET.Element):
521520
rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1]
522-
subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None)
521+
subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None)
523522
else:
524523
subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response)
525524
if subtype_value:
@@ -564,7 +563,7 @@ def _decode_attribute_map_key(key):
564563
return key.replace("\\.", ".")
565564

566565

567-
class Serializer(object): # pylint: disable=too-many-public-methods
566+
class Serializer: # pylint: disable=too-many-public-methods
568567
"""Request object model serializer."""
569568

570569
basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
@@ -599,7 +598,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
599598
"multiple": lambda x, y: x % y != 0,
600599
}
601600

602-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
601+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
603602
self.serialize_type = {
604603
"iso-8601": Serializer.serialize_iso,
605604
"rfc-1123": Serializer.serialize_rfc,
@@ -1442,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
14421441
return children[0]
14431442

14441443

1445-
class Deserializer(object):
1444+
class Deserializer:
14461445
"""Response object model deserializer.
14471446
14481447
:param dict classes: Class type dictionary for deserializing complex types.
@@ -1453,7 +1452,7 @@ class Deserializer(object):
14531452

14541453
valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")
14551454

1456-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
1455+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
14571456
self.deserialize_type = {
14581457
"iso-8601": Deserializer.deserialize_iso,
14591458
"rfc-1123": Deserializer.deserialize_rfc,
@@ -1684,17 +1683,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None):
16841683
subtype = getattr(response, "_subtype_map", {})
16851684
try:
16861685
readonly = [
1687-
k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access
1686+
k
1687+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1688+
if v.get("readonly")
16881689
]
16891690
const = [
1690-
k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access
1691+
k
1692+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1693+
if v.get("constant")
16911694
]
16921695
kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const}
16931696
response_obj = response(**kwargs)
16941697
for attr in readonly:
16951698
setattr(response_obj, attr, attrs.get(attr))
16961699
if additional_properties:
1697-
response_obj.additional_properties = additional_properties
1700+
response_obj.additional_properties = additional_properties # type: ignore
16981701
return response_obj
16991702
except TypeError as err:
17001703
msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_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 = "1.0.0b1"
9+
VERSION = "1.0.0"

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/aio/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import ComputeScheduleMgmtClient
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 ComputeScheduleMgmtClient # type: ignore
1016

1117
try:
1218
from ._patch import __all__ as _patch_all
13-
from ._patch import * # pylint: disable=unused-wildcard-import
19+
from ._patch import *
1420
except ImportError:
1521
_patch_all = []
1622
from ._patch import patch_sdk as _patch_sdk
1723

1824
__all__ = [
1925
"ComputeScheduleMgmtClient",
2026
]
21-
__all__.extend([p for p in _patch_all if p not in __all__])
27+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2228

2329
_patch_sdk()

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/aio/_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
from .operations import Operations, ScheduledActionsOperations
2121

2222
if TYPE_CHECKING:
23-
# pylint: disable=unused-import,ungrouped-imports
2423
from azure.core.credentials_async import AsyncTokenCredential
2524

2625

27-
class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-keyword
26+
class ComputeScheduleMgmtClient:
2827
"""Microsoft.ComputeSchedule Resource Provider management API.
2928
3029
:ivar operations: Operations operations
@@ -38,9 +37,8 @@ class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-k
3837
:type subscription_id: str
3938
:param base_url: Service host. Default value is "https://management.azure.com".
4039
:type base_url: str
41-
:keyword api_version: The API version to use for this operation. Default value is
42-
"2024-08-15-preview". Note that overriding this default value may result in unsupported
43-
behavior.
40+
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
41+
Note that overriding this default value may result in unsupported behavior.
4442
:paramtype api_version: str
4543
"""
4644

0 commit comments

Comments
 (0)