Skip to content

Commit cc1d092

Browse files
author
SDKAuto
committed
CodeGen from PR 33973 in Azure/azure-rest-api-specs
Merge c5980e617228448f4c3624b42ce6dc93388995ce into abe6b63e998a3995d1c28d2a1f8c0a6950a79b72
1 parent 9712d82 commit cc1d092

24 files changed

+449
-356
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Computeschedule Management Client Library.
4-
This package has been tested with Python 3.8+.
4+
This package has been tested with Python 3.9+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
@@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For
1212

1313
### Prerequisites
1414

15-
- Python 3.8+ is required to use this package.
15+
- Python 3.9+ is required to use this package.
1616
- [Azure subscription](https://azure.microsoft.com/free/)
1717

1818
### Install the package
@@ -24,7 +24,7 @@ pip install azure-identity
2424

2525
### Authentication
2626

27-
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables.
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.
2828

2929
- `AZURE_CLIENT_ID` for Azure client ID.
3030
- `AZURE_TENANT_ID` for Azure tenant ID.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "b6075dbc2321933382ea91c787ee62c6bdb87e5d",
2+
"commit": "1a8dcbc31c561409f253e5f7a924ff577b583da7",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/computeschedule/ComputeSchedule.Management",
5-
"@azure-tools/typespec-python": "0.37.3"
5+
"@azure-tools/typespec-python": "0.43.0"
66
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"CrossLanguagePackageId": "Microsoft.ComputeSchedule",
3+
"CrossLanguageDefinitionId": {
4+
"azure.mgmt.computeschedule.models.CancelOperationsRequest": "Microsoft.ComputeSchedule.CancelOperationsRequest",
5+
"azure.mgmt.computeschedule.models.CancelOperationsResponse": "Microsoft.ComputeSchedule.CancelOperationsResponse",
6+
"azure.mgmt.computeschedule.models.DeallocateResourceOperationResponse": "Microsoft.ComputeSchedule.DeallocateResourceOperationResponse",
7+
"azure.mgmt.computeschedule.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo",
8+
"azure.mgmt.computeschedule.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail",
9+
"azure.mgmt.computeschedule.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse",
10+
"azure.mgmt.computeschedule.models.ExecuteDeallocateRequest": "Microsoft.ComputeSchedule.ExecuteDeallocateRequest",
11+
"azure.mgmt.computeschedule.models.ExecuteHibernateRequest": "Microsoft.ComputeSchedule.ExecuteHibernateRequest",
12+
"azure.mgmt.computeschedule.models.ExecuteStartRequest": "Microsoft.ComputeSchedule.ExecuteStartRequest",
13+
"azure.mgmt.computeschedule.models.ExecutionParameters": "Microsoft.ComputeSchedule.ExecutionParameters",
14+
"azure.mgmt.computeschedule.models.GetOperationErrorsRequest": "Microsoft.ComputeSchedule.GetOperationErrorsRequest",
15+
"azure.mgmt.computeschedule.models.GetOperationErrorsResponse": "Microsoft.ComputeSchedule.GetOperationErrorsResponse",
16+
"azure.mgmt.computeschedule.models.GetOperationStatusRequest": "Microsoft.ComputeSchedule.GetOperationStatusRequest",
17+
"azure.mgmt.computeschedule.models.GetOperationStatusResponse": "Microsoft.ComputeSchedule.GetOperationStatusResponse",
18+
"azure.mgmt.computeschedule.models.HibernateResourceOperationResponse": "Microsoft.ComputeSchedule.HibernateResourceOperationResponse",
19+
"azure.mgmt.computeschedule.models.Operation": "Azure.ResourceManager.CommonTypes.Operation",
20+
"azure.mgmt.computeschedule.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay",
21+
"azure.mgmt.computeschedule.models.OperationErrorDetails": "Microsoft.ComputeSchedule.OperationErrorDetails",
22+
"azure.mgmt.computeschedule.models.OperationErrorsResult": "Microsoft.ComputeSchedule.OperationErrorsResult",
23+
"azure.mgmt.computeschedule.models.ResourceOperation": "Microsoft.ComputeSchedule.ResourceOperation",
24+
"azure.mgmt.computeschedule.models.ResourceOperationDetails": "Microsoft.ComputeSchedule.ResourceOperationDetails",
25+
"azure.mgmt.computeschedule.models.ResourceOperationError": "Microsoft.ComputeSchedule.ResourceOperationError",
26+
"azure.mgmt.computeschedule.models.Resources": "Microsoft.ComputeSchedule.Resources",
27+
"azure.mgmt.computeschedule.models.RetryPolicy": "Microsoft.ComputeSchedule.RetryPolicy",
28+
"azure.mgmt.computeschedule.models.Schedule": "Microsoft.ComputeSchedule.Schedule",
29+
"azure.mgmt.computeschedule.models.StartResourceOperationResponse": "Microsoft.ComputeSchedule.StartResourceOperationResponse",
30+
"azure.mgmt.computeschedule.models.SubmitDeallocateRequest": "Microsoft.ComputeSchedule.SubmitDeallocateRequest",
31+
"azure.mgmt.computeschedule.models.SubmitHibernateRequest": "Microsoft.ComputeSchedule.SubmitHibernateRequest",
32+
"azure.mgmt.computeschedule.models.SubmitStartRequest": "Microsoft.ComputeSchedule.SubmitStartRequest",
33+
"azure.mgmt.computeschedule.models.Origin": "Azure.ResourceManager.CommonTypes.Origin",
34+
"azure.mgmt.computeschedule.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType",
35+
"azure.mgmt.computeschedule.models.ResourceOperationType": "Microsoft.ComputeSchedule.ResourceOperationType",
36+
"azure.mgmt.computeschedule.models.DeadlineType": "Microsoft.ComputeSchedule.DeadlineType",
37+
"azure.mgmt.computeschedule.models.OperationState": "Microsoft.ComputeSchedule.OperationState",
38+
"azure.mgmt.computeschedule.models.OptimizationPreference": "Microsoft.ComputeSchedule.OptimizationPreference",
39+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.operations.list": "Azure.ResourceManager.Operations.list",
40+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_submit_deallocate": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesSubmitDeallocate",
41+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_submit_hibernate": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesSubmitHibernate",
42+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_submit_start": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesSubmitStart",
43+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_execute_deallocate": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesExecuteDeallocate",
44+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_execute_hibernate": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesExecuteHibernate",
45+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_execute_start": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesExecuteStart",
46+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_get_operation_status": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesGetOperationStatus",
47+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_cancel_operations": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesCancelOperations",
48+
"azure.mgmt.computeschedule.ComputeScheduleMgmtClient.scheduled_actions.virtual_machines_get_operation_errors": "Microsoft.ComputeSchedule.ScheduledActions.virtualMachinesGetOperationErrors"
49+
}
50+
}

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import Any, TYPE_CHECKING
10+
from typing import Any, Optional, TYPE_CHECKING, cast
1111
from typing_extensions import Self
1212

1313
from azure.core.pipeline import policies
1414
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.core.settings import settings
1516
from azure.mgmt.core import ARMPipelineClient
1617
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
18+
from azure.mgmt.core.tools import get_arm_endpoints
1719

1820
from ._configuration import ComputeScheduleMgmtClientConfiguration
1921
from ._serialization import Deserializer, Serializer
@@ -34,24 +36,30 @@ class ComputeScheduleMgmtClient:
3436
:type credential: ~azure.core.credentials.TokenCredential
3537
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
3638
:type subscription_id: str
37-
:param base_url: Service host. Default value is "https://management.azure.com".
39+
:param base_url: Service host. Default value is None.
3840
:type base_url: str
3941
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
4042
Note that overriding this default value may result in unsupported behavior.
4143
:paramtype api_version: str
4244
"""
4345

4446
def __init__(
45-
self,
46-
credential: "TokenCredential",
47-
subscription_id: str,
48-
base_url: str = "https://management.azure.com",
49-
**kwargs: Any
47+
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
5048
) -> None:
5149
_endpoint = "{endpoint}"
50+
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
51+
_endpoints = get_arm_endpoints(_cloud)
52+
if not base_url:
53+
base_url = _endpoints["resource_manager"]
54+
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
5255
self._config = ComputeScheduleMgmtClientConfiguration(
53-
credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs
56+
credential=credential,
57+
subscription_id=subscription_id,
58+
base_url=cast(str, base_url),
59+
credential_scopes=credential_scopes,
60+
**kwargs
5461
)
62+
5563
_policies = kwargs.pop("policies", None)
5664
if _policies is None:
5765
_policies = [
@@ -70,7 +78,7 @@ def __init__(
7078
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
7179
self._config.http_logging_policy,
7280
]
73-
self._client: ARMPipelineClient = ARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
81+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs)
7482

7583
self._serialize = Serializer()
7684
self._deserialize = Deserializer()

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

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
# Licensed under the MIT License. See License.txt in the project root for
6-
# license information.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# Code generated by Microsoft (R) Python Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
78
# --------------------------------------------------------------------------
89
# pylint: disable=protected-access, broad-except
910

@@ -21,18 +22,14 @@
2122
from datetime import datetime, date, time, timedelta, timezone
2223
from json import JSONEncoder
2324
import xml.etree.ElementTree as ET
25+
from collections.abc import MutableMapping
2426
from typing_extensions import Self
2527
import isodate
2628
from azure.core.exceptions import DeserializationError
2729
from azure.core import CaseInsensitiveEnumMeta
2830
from azure.core.pipeline import PipelineResponse
2931
from azure.core.serialization import _Null
3032

31-
if sys.version_info >= (3, 9):
32-
from collections.abc import MutableMapping
33-
else:
34-
from typing import MutableMapping
35-
3633
_LOGGER = logging.getLogger(__name__)
3734

3835
__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"]
@@ -347,7 +344,7 @@ def _get_model(module_name: str, model_name: str):
347344
_UNSET = object()
348345

349346

350-
class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object
347+
class _MyMutableMapping(MutableMapping[str, typing.Any]):
351348
def __init__(self, data: typing.Dict[str, typing.Any]) -> None:
352349
self._data = data
353350

@@ -373,50 +370,97 @@ def __ne__(self, other: typing.Any) -> bool:
373370
return not self.__eq__(other)
374371

375372
def keys(self) -> typing.KeysView[str]:
373+
"""
374+
:returns: a set-like object providing a view on D's keys
375+
:rtype: ~typing.KeysView
376+
"""
376377
return self._data.keys()
377378

378379
def values(self) -> typing.ValuesView[typing.Any]:
380+
"""
381+
:returns: an object providing a view on D's values
382+
:rtype: ~typing.ValuesView
383+
"""
379384
return self._data.values()
380385

381386
def items(self) -> typing.ItemsView[str, typing.Any]:
387+
"""
388+
:returns: set-like object providing a view on D's items
389+
:rtype: ~typing.ItemsView
390+
"""
382391
return self._data.items()
383392

384393
def get(self, key: str, default: typing.Any = None) -> typing.Any:
394+
"""
395+
Get the value for key if key is in the dictionary, else default.
396+
:param str key: The key to look up.
397+
:param any default: The value to return if key is not in the dictionary. Defaults to None
398+
:returns: D[k] if k in D, else d.
399+
:rtype: any
400+
"""
385401
try:
386402
return self[key]
387403
except KeyError:
388404
return default
389405

390406
@typing.overload
391-
def pop(self, key: str) -> typing.Any: ...
407+
def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ
392408

393409
@typing.overload
394-
def pop(self, key: str, default: _T) -> _T: ...
410+
def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs
395411

396412
@typing.overload
397-
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
413+
def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs
398414

399415
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
416+
"""
417+
Removes specified key and return the corresponding value.
418+
:param str key: The key to pop.
419+
:param any default: The value to return if key is not in the dictionary
420+
:returns: The value corresponding to the key.
421+
:rtype: any
422+
:raises KeyError: If key is not found and default is not given.
423+
"""
400424
if default is _UNSET:
401425
return self._data.pop(key)
402426
return self._data.pop(key, default)
403427

404428
def popitem(self) -> typing.Tuple[str, typing.Any]:
429+
"""
430+
Removes and returns some (key, value) pair
431+
:returns: The (key, value) pair.
432+
:rtype: tuple
433+
:raises KeyError: if D is empty.
434+
"""
405435
return self._data.popitem()
406436

407437
def clear(self) -> None:
438+
"""
439+
Remove all items from D.
440+
"""
408441
self._data.clear()
409442

410-
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
443+
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ
444+
"""
445+
Updates D from mapping/iterable E and F.
446+
:param any args: Either a mapping object or an iterable of key-value pairs.
447+
"""
411448
self._data.update(*args, **kwargs)
412449

413450
@typing.overload
414451
def setdefault(self, key: str, default: None = None) -> None: ...
415452

416453
@typing.overload
417-
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
454+
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs
418455

419456
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
457+
"""
458+
Same as calling D.get(k, d), and setting D[k]=d if k not found
459+
:param str key: The key to look up.
460+
:param any default: The value to set if key is not in the dictionary
461+
:returns: D[k] if k in D, else d.
462+
:rtype: any
463+
"""
420464
if default is _UNSET:
421465
return self._data.setdefault(key)
422466
return self._data.setdefault(key, default)
@@ -597,7 +641,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
597641
cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items())
598642
cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}")
599643

600-
return super().__new__(cls) # pylint: disable=no-value-for-parameter
644+
return super().__new__(cls)
601645

602646
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
603647
for base in cls.__bases__:
@@ -633,7 +677,7 @@ def _deserialize(cls, data, exist_discriminators):
633677
discriminator_value = data.find(xml_name).text # pyright: ignore
634678
else:
635679
discriminator_value = data.get(discriminator._rest_name)
636-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
680+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
637681
return mapped_cls._deserialize(data, exist_discriminators)
638682

639683
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
@@ -910,6 +954,19 @@ def _failsafe_deserialize(
910954
return None
911955

912956

957+
def _failsafe_deserialize_xml(
958+
deserializer: typing.Any,
959+
value: typing.Any,
960+
) -> typing.Any:
961+
try:
962+
return _deserialize_xml(deserializer, value)
963+
except DeserializationError:
964+
_LOGGER.warning(
965+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
966+
)
967+
return None
968+
969+
913970
class _RestField:
914971
def __init__(
915972
self,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# ------------------------------------
2-
# Copyright (c) Microsoft Corporation.
3-
# Licensed under the MIT License.
4-
# ------------------------------------
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------------
56
"""Customize generated code here.
67
78
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize

0 commit comments

Comments
 (0)