diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/CHANGELOG.md b/sdk/resources/azure-mgmt-resource-subscriptions/CHANGELOG.md index 06957356f0af..a74308e14a76 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-resource-subscriptions/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0 (2026-07-20) + +### Other Changes + + - First GA + ## 1.0.0b2 (2026-05-21) ### Features Added diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/README.md b/sdk/resources/azure-mgmt-resource-subscriptions/README.md index c1744e8741c9..ac5f78b29bd9 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/README.md +++ b/sdk/resources/azure-mgmt-resource-subscriptions/README.md @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. +By default, [Microsoft Entra](https://learn.microsoft.com/entra/fundamentals/what-is-entra) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/_metadata.json b/sdk/resources/azure-mgmt-resource-subscriptions/_metadata.json index 7e658b783f97..4df7eacb4660 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/_metadata.json +++ b/sdk/resources/azure-mgmt-resource-subscriptions/_metadata.json @@ -3,8 +3,9 @@ "apiVersions": { "Microsoft.Resources": "2022-12-01" }, - "commit": "f34830624e2040e4777496c73aa7c6fe764f4bfc", + "commit": "cf49df24bee763924bb4d9abceebe4fd1916a6ad", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/resources/resource-manager/Microsoft.Resources/subscriptions", - "emitterVersion": "0.62.1" + "emitterVersion": "0.63.3", + "httpClientPythonVersion": "^0.34.2" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/api.md b/sdk/resources/azure-mgmt-resource-subscriptions/api.md new file mode 100644 index 000000000000..d838e0c56a21 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource-subscriptions/api.md @@ -0,0 +1,605 @@ +```py +namespace azure.mgmt.resource.subscriptions + + class azure.mgmt.resource.subscriptions.SubscriptionClient(_SubscriptionClientOperationsMixin): implements ContextManager + operations: Operations + subscriptions: SubscriptionsOperations + tenants: TenantsOperations + + def __init__( + self, + credential: TokenCredential, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + **kwargs: Any + ) -> None: ... + + @overload + def check_resource_name( + self, + resource_name_definition: Optional[ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + @overload + def check_resource_name( + self, + resource_name_definition: Optional[ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + @overload + def check_resource_name( + self, + resource_name_definition: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> HttpResponse: ... + + +namespace azure.mgmt.resource.subscriptions.aio + + class azure.mgmt.resource.subscriptions.aio.SubscriptionClient(_SubscriptionClientOperationsMixin): implements AsyncContextManager + operations: Operations + subscriptions: SubscriptionsOperations + tenants: TenantsOperations + + def __init__( + self, + credential: AsyncTokenCredential, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + **kwargs: Any + ) -> None: ... + + @overload + async def check_resource_name( + self, + resource_name_definition: Optional[ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + @overload + async def check_resource_name( + self, + resource_name_definition: Optional[ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + @overload + async def check_resource_name( + self, + resource_name_definition: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckResourceNameResult: ... + + async def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: ... + + +namespace azure.mgmt.resource.subscriptions.aio.operations + + class azure.mgmt.resource.subscriptions.aio.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[Operation]: ... + + + class azure.mgmt.resource.subscriptions.aio.operations.SubscriptionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def check_zone_peers( + self, + subscription_id: str, + parameters: CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @overload + async def check_zone_peers( + self, + subscription_id: str, + parameters: CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @overload + async def check_zone_peers( + self, + subscription_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @distributed_trace_async + async def get( + self, + subscription_id: str, + **kwargs: Any + ) -> Subscription: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[Subscription]: ... + + @distributed_trace + def list_locations( + self, + subscription_id: str, + *, + include_extended_locations: Optional[bool] = ..., + **kwargs: Any + ) -> AsyncItemPaged[Location]: ... + + + class azure.mgmt.resource.subscriptions.aio.operations.TenantsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[TenantIdDescription]: ... + + +namespace azure.mgmt.resource.subscriptions.models + + class azure.mgmt.resource.subscriptions.models.ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + INTERNAL = "Internal" + + + class azure.mgmt.resource.subscriptions.models.AvailabilityZoneMappings(_Model): + logical_zone: Optional[str] + physical_zone: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.AvailabilityZonePeers(_Model): + availability_zone: Optional[str] + peers: Optional[list[Peers]] + + @overload + def __init__( + self, + *, + peers: Optional[list[Peers]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.CheckResourceNameResult(_Model): + name: Optional[str] + status: Optional[Union[str, ResourceNameStatus]] + type: Optional[str] + + @overload + def __init__( + self, + *, + name: Optional[str] = ..., + status: Optional[Union[str, ResourceNameStatus]] = ..., + type: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.CheckZonePeersRequest(_Model): + location: Optional[str] + subscription_ids: Optional[list[str]] + + @overload + def __init__( + self, + *, + location: Optional[str] = ..., + subscription_ids: Optional[list[str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.CheckZonePeersResult(_Model): + availability_zone_peers: Optional[list[AvailabilityZonePeers]] + location: Optional[str] + subscription_id: Optional[str] + + @overload + def __init__( + self, + *, + availability_zone_peers: Optional[list[AvailabilityZonePeers]] = ..., + location: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.CloudError(_Model): + error: Optional[ErrorResponse] + + @overload + def __init__( + self, + *, + error: Optional[ErrorResponse] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.ErrorAdditionalInfo(_Model): + info: Optional[Any] + type: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.ErrorDetail(_Model): + additional_info: Optional[list[ErrorAdditionalInfo]] + code: Optional[str] + details: Optional[list[ErrorDetail]] + message: Optional[str] + target: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.ErrorResponse(_Model): + error: Optional[ErrorDetail] + + @overload + def __init__( + self, + *, + error: Optional[ErrorDetail] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.Location(_Model): + availability_zone_mappings: Optional[list[AvailabilityZoneMappings]] + display_name: Optional[str] + id: Optional[str] + metadata: Optional[LocationMetadata] + name: Optional[str] + regional_display_name: Optional[str] + subscription_id: Optional[str] + type: Optional[Union[str, LocationType]] + + @overload + def __init__( + self, + *, + availability_zone_mappings: Optional[list[AvailabilityZoneMappings]] = ..., + metadata: Optional[LocationMetadata] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.LocationMetadata(_Model): + geography: Optional[str] + geography_group: Optional[str] + home_location: Optional[str] + latitude: Optional[str] + longitude: Optional[str] + paired_region: Optional[list[PairedRegion]] + physical_location: Optional[str] + region_category: Optional[Union[str, RegionCategory]] + region_type: Optional[Union[str, RegionType]] + + @overload + def __init__( + self, + *, + paired_region: Optional[list[PairedRegion]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.LocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EDGE_ZONE = "EdgeZone" + REGION = "Region" + + + class azure.mgmt.resource.subscriptions.models.ManagedByTenant(_Model): + tenant_id: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.Operation(_Model): + action_type: Optional[Union[str, ActionType]] + display: Optional[OperationDisplay] + is_data_action: Optional[bool] + name: Optional[str] + origin: Optional[Union[str, Origin]] + + @overload + def __init__( + self, + *, + display: Optional[OperationDisplay] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.OperationDisplay(_Model): + description: Optional[str] + operation: Optional[str] + provider: Optional[str] + resource: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + SYSTEM = "system" + USER = "user" + USER_SYSTEM = "user,system" + + + class azure.mgmt.resource.subscriptions.models.PairedRegion(_Model): + id: Optional[str] + name: Optional[str] + subscription_id: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.Peers(_Model): + availability_zone: Optional[str] + subscription_id: Optional[str] + + + class azure.mgmt.resource.subscriptions.models.RegionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EXTENDED = "Extended" + OTHER = "Other" + RECOMMENDED = "Recommended" + + + class azure.mgmt.resource.subscriptions.models.RegionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + LOGICAL = "Logical" + PHYSICAL = "Physical" + + + class azure.mgmt.resource.subscriptions.models.ResourceName(_Model): + name: str + type: str + + @overload + def __init__( + self, + *, + name: str, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ALLOWED = "Allowed" + RESERVED = "Reserved" + + + class azure.mgmt.resource.subscriptions.models.SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + OFF = "Off" + ON = "On" + + + class azure.mgmt.resource.subscriptions.models.Subscription(_Model): + authorization_source: Optional[str] + display_name: Optional[str] + id: Optional[str] + managed_by_tenants: Optional[list[ManagedByTenant]] + state: Optional[Union[str, SubscriptionState]] + subscription_id: Optional[str] + subscription_policies: Optional[SubscriptionPolicies] + tags: Optional[dict[str, str]] + tenant_id: Optional[str] + + @overload + def __init__( + self, + *, + authorization_source: Optional[str] = ..., + managed_by_tenants: Optional[list[ManagedByTenant]] = ..., + subscription_policies: Optional[SubscriptionPolicies] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.resource.subscriptions.models.SubscriptionPolicies(_Model): + location_placement_id: Optional[str] + quota_id: Optional[str] + spending_limit: Optional[Union[str, SpendingLimit]] + + + class azure.mgmt.resource.subscriptions.models.SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + DELETED = "Deleted" + DISABLED = "Disabled" + ENABLED = "Enabled" + PAST_DUE = "PastDue" + WARNED = "Warned" + + + class azure.mgmt.resource.subscriptions.models.TenantCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + HOME = "Home" + MANAGED_BY = "ManagedBy" + PROJECTED_BY = "ProjectedBy" + + + class azure.mgmt.resource.subscriptions.models.TenantIdDescription(_Model): + country: Optional[str] + country_code: Optional[str] + default_domain: Optional[str] + display_name: Optional[str] + domains: Optional[list[str]] + id: Optional[str] + tenant_branding_logo_url: Optional[str] + tenant_category: Optional[Union[str, TenantCategory]] + tenant_id: Optional[str] + tenant_type: Optional[str] + + +namespace azure.mgmt.resource.subscriptions.operations + + class azure.mgmt.resource.subscriptions.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[Operation]: ... + + + class azure.mgmt.resource.subscriptions.operations.SubscriptionsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def check_zone_peers( + self, + subscription_id: str, + parameters: CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @overload + def check_zone_peers( + self, + subscription_id: str, + parameters: CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @overload + def check_zone_peers( + self, + subscription_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckZonePeersResult: ... + + @distributed_trace + def get( + self, + subscription_id: str, + **kwargs: Any + ) -> Subscription: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[Subscription]: ... + + @distributed_trace + def list_locations( + self, + subscription_id: str, + *, + include_extended_locations: Optional[bool] = ..., + **kwargs: Any + ) -> ItemPaged[Location]: ... + + + class azure.mgmt.resource.subscriptions.operations.TenantsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[TenantIdDescription]: ... + + +namespace azure.mgmt.resource.subscriptions.types + + class azure.mgmt.resource.subscriptions.types.CheckZonePeersRequest(TypedDict, total=False): + key "location": str + location: str + subscriptionIds: list[str] + subscription_ids: list[str] + + + class azure.mgmt.resource.subscriptions.types.ResourceName(TypedDict, total=False): + key "name": Required[str] + key "type": Required[str] + name: str + type: str + + +``` \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/api.metadata.yml b/sdk/resources/azure-mgmt-resource-subscriptions/api.metadata.yml new file mode 100644 index 000000000000..1af0f73cff5a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource-subscriptions/api.metadata.yml @@ -0,0 +1,3 @@ +apiMdSha256: 77adfa7da81eb7c9d2ab115c757bcb35c74f6516b0783872107815e3cb7c3c81 +parserVersion: 0.3.28 +pythonVersion: 3.13.14 diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/apiview-properties.json b/sdk/resources/azure-mgmt-resource-subscriptions/apiview-properties.json index 188708cd154f..436304e6956b 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/apiview-properties.json +++ b/sdk/resources/azure-mgmt-resource-subscriptions/apiview-properties.json @@ -45,5 +45,5 @@ "azure.mgmt.resource.subscriptions.SubscriptionClient.check_resource_name": "Microsoft.Resources.checkResourceName", "azure.mgmt.resource.subscriptions.aio.SubscriptionClient.check_resource_name": "Microsoft.Resources.checkResourceName" }, - "CrossLanguageVersion": "5a8d9878d973" + "CrossLanguageVersion": "252e52f83826" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_patch.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_patch.py index ea765788358a..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_patch.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + __all__: list[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/model_base.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/model_base.py index 4102784f9a85..0f2c5bdfe70f 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/model_base.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/model_base.py @@ -109,6 +109,29 @@ def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: return encoded +def _serialize_duration(td: timedelta, format: typing.Optional[str] = None): + """Serialize a timedelta to its wire representation. + + For the ``seconds``/``milliseconds`` encodings the value is converted to a + numeric value, otherwise it falls back to an ISO 8601 duration string. + + :param timedelta td: The timedelta to serialize. + :param str format: The duration encoding format. + :rtype: int or float or str + :return: serialized duration + """ + seconds = td.total_seconds() + if format == "duration-seconds-int": + return int(seconds) + if format == "duration-seconds-float": + return seconds + if format == "duration-milliseconds-int": + return int(seconds * 1000) + if format == "duration-milliseconds-float": + return seconds * 1000 + return _timedelta_as_isostr(td) + + def _serialize_datetime(o, format: typing.Optional[str] = None): if hasattr(o, "year") and hasattr(o, "hour"): if format == "rfc7231": @@ -301,6 +324,12 @@ def _deserialize_duration(attr): return isodate.parse_duration(attr) +def _deserialize_duration_numeric(attr, unit): + if isinstance(attr, timedelta): + return attr + return timedelta(**{unit: float(attr)}) + + def _deserialize_decimal(attr): if isinstance(attr, decimal.Decimal): return attr @@ -330,6 +359,10 @@ def _deserialize_int_as_str(attr): "unix-timestamp": _deserialize_datetime_unix_timestamp, "base64": _deserialize_bytes, "base64url": _deserialize_bytes_base64, + "duration-seconds-int": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-seconds-float": functools.partial(_deserialize_duration_numeric, unit="seconds"), + "duration-milliseconds-int": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), + "duration-milliseconds-float": functools.partial(_deserialize_duration_numeric, unit="milliseconds"), } @@ -425,21 +458,21 @@ def __ne__(self, other: typing.Any) -> bool: def keys(self) -> typing.KeysView[str]: """ - :returns: a set-like object providing a view on D's keys + :returns: a set-like object providing a view on the mapping's keys :rtype: ~typing.KeysView """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: """ - :returns: an object providing a view on D's values + :returns: an object providing a view on the mapping's values :rtype: ~typing.ValuesView """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: """ - :returns: set-like object providing a view on D's items + :returns: a set-like object providing a view on the mapping's items :rtype: ~typing.ItemsView """ return self._data.items() @@ -449,7 +482,7 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any: Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None - :returns: D[k] if k in D, else d. + :returns: The value for key if key is in the dictionary, else default. :rtype: any """ try: @@ -484,19 +517,19 @@ def popitem(self) -> tuple[str, typing.Any]: Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple - :raises KeyError: if D is empty. + :raises KeyError: if the dictionary is empty. """ return self._data.popitem() def clear(self) -> None: """ - Remove all items from D. + Remove all items from the dictionary. """ self._data.clear() def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ """ - Updates D from mapping/iterable E and F. + Update the dictionary from a mapping or an iterable of key-value pairs. :param any args: Either a mapping object or an iterable of key-value pairs. """ self._data.update(*args, **kwargs) @@ -509,10 +542,11 @@ def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: """ - Same as calling D.get(k, d), and setting D[k]=d if k not found + Return the value for key if key is in the dictionary; otherwise set the key to + default and return default. :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary - :returns: D[k] if k in D, else d. + :returns: The value for key if key is in the dictionary, else default. :rtype: any """ if default is _UNSET: @@ -564,7 +598,7 @@ def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-m pass # Last, try datetime.timedelta try: - return _timedelta_as_isostr(o) + return _serialize_duration(o, format) except AttributeError: # This will be raised when it hits value.total_seconds in the method above pass @@ -590,6 +624,239 @@ def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typin return _serialize(value, rf._format) +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param class Model(_MyMutableMapping): _is_model = True # label whether current class's _attr_to_rest_field has been calculated @@ -630,7 +897,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) super().__init__(dict_to_pass) - def _init_from_xml(self, element: ET.Element) -> dict[str, typing.Any]: + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: """Deserialize an XML element into a dict mapping rest field names to values. :param ET.Element element: The XML element to deserialize from. @@ -638,53 +907,89 @@ def _init_from_xml(self, element: ET.Element) -> dict[str, typing.Any]: :rtype: dict """ result: dict[str, typing.Any] = {} - model_meta = getattr(self, "_xml", {}) existed_attr_keys: list[str] = [] - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = _resolve_xml_ns(prop_meta, model_meta) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and element.get(xml_name) is not None: - existed_attr_keys.append(xml_name) - result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - _items_name = prop_meta.get("itemsName") - if _items_name: - xml_name = _items_name - _items_ns = prop_meta.get("itemsNs") - if _items_ns is not None: - xml_ns = _items_ns - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = element.findall(xml_name) # pyright: ignore - if len(items) > 0: + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: existed_attr_keys.append(xml_name) - result[rf._rest_name] = _deserialize(rf._type, items) - elif not rf._is_optional: + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: existed_attr_keys.append(xml_name) - result[rf._rest_name] = [] - continue - - # text element is primitive type - if prop_meta.get("text", False): - if element.text is not None: - result[rf._rest_name] = _deserialize(rf._type, element.text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = element.find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - result[rf._rest_name] = _deserialize(rf._type, item) + result[rf._rest_name] = _deserialize(rf._type, item) # rest thing is additional properties for e in element: @@ -717,6 +1022,9 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if not rf._rest_name_input: rf._rest_name_input = attr cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") return super().__new__(cls) @@ -1091,6 +1399,7 @@ def __init__( format: typing.Optional[str] = None, is_multipart_file_input: bool = False, xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ): self._type = type self._rest_name_input = name @@ -1103,6 +1412,7 @@ def __init__( self._format = format self._is_multipart_file_input = is_multipart_file_input self._xml = xml if xml is not None else {} + self._deserializer = deserializer @property def _class_type(self) -> typing.Any: @@ -1138,7 +1448,11 @@ def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin # Return the value from _data directly (it's been deserialized in place) return obj._data.get(self._rest_name) - deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) # For mutable types, store the deserialized value back in _data # so mutations directly affect _data @@ -1184,6 +1498,7 @@ def rest_field( format: typing.Optional[str] = None, is_multipart_file_input: bool = False, xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ) -> typing.Any: return _RestField( name=name, @@ -1193,6 +1508,7 @@ def rest_field( format=format, is_multipart_file_input=is_multipart_file_input, xml=xml, + deserializer=deserializer, ) @@ -1426,6 +1742,8 @@ def _deserialize_xml( value: str, ) -> typing.Any: element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) return _deserialize(deserializer, element) diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/serialization.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/serialization.py index 954bf7ebffa7..75906e2eb77f 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/serialization.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_utils/serialization.py @@ -520,6 +520,10 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "rfc-1123": Serializer.serialize_rfc, "unix-time": Serializer.serialize_unix, "duration": Serializer.serialize_duration, + "duration-seconds-int": Serializer.serialize_duration_seconds_int, + "duration-seconds-float": Serializer.serialize_duration_seconds_float, + "duration-milliseconds-int": Serializer.serialize_duration_milliseconds_int, + "duration-milliseconds-float": Serializer.serialize_duration_milliseconds_float, "date": Serializer.serialize_date, "time": Serializer.serialize_time, "decimal": Serializer.serialize_decimal, @@ -1109,6 +1113,61 @@ def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) + @staticmethod + def _serialize_duration_numeric(attr, scale, as_int): + """Serialize a TimeDelta into a numeric value scaled to the wire unit. + + :param TimeDelta attr: Object to be serialized. + :param int scale: Multiplier applied to total seconds (1 for seconds, 1000 for milliseconds). + :param bool as_int: Whether to truncate the result to an int. + :rtype: int or float + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + value = attr.total_seconds() * scale if isinstance(attr, datetime.timedelta) else attr + return int(value) if as_int else float(value) + + @staticmethod + def serialize_duration_seconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, True) + + @staticmethod + def serialize_duration_seconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of seconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1, False) + + @staticmethod + def serialize_duration_milliseconds_int(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into an integer number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: int + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, True) + + @staticmethod + def serialize_duration_milliseconds_float(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into a floating point number of milliseconds. + + :param TimeDelta attr: Object to be serialized. + :rtype: float + :return: serialized duration + """ + return Serializer._serialize_duration_numeric(attr, 1000, False) + @staticmethod def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. @@ -1381,6 +1440,10 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "rfc-1123": Deserializer.deserialize_rfc, "unix-time": Deserializer.deserialize_unix, "duration": Deserializer.deserialize_duration, + "duration-seconds-int": Deserializer.deserialize_duration_seconds, + "duration-seconds-float": Deserializer.deserialize_duration_seconds, + "duration-milliseconds-int": Deserializer.deserialize_duration_milliseconds, + "duration-milliseconds-float": Deserializer.deserialize_duration_milliseconds, "date": Deserializer.deserialize_date, "time": Deserializer.deserialize_time, "decimal": Deserializer.deserialize_decimal, @@ -1393,6 +1456,10 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: } self.deserialize_expected_types = { "duration": (isodate.Duration, datetime.timedelta), + "duration-seconds-int": (isodate.Duration, datetime.timedelta), + "duration-seconds-float": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-int": (isodate.Duration, datetime.timedelta), + "duration-milliseconds-float": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } self.dependencies: dict[str, type] = dict(classes) if classes else {} @@ -1405,7 +1472,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. @@ -1415,6 +1482,27 @@ def __call__(self, target_obj, response_data, content_type=None): :return: Deserialized object. :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) @@ -1933,6 +2021,48 @@ def deserialize_duration(attr): raise DeserializationError(msg) from err return duration + @staticmethod + def _deserialize_duration_numeric(attr, unit): + """Deserialize a numeric duration value into a TimeDelta object. + + :param float attr: response value to be deserialized. + :param str unit: The wire unit, used as the ``timedelta`` keyword + (``"seconds"`` or ``"milliseconds"``). + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = datetime.timedelta(**{unit: float(attr)}) # type: ignore + except (ValueError, OverflowError, TypeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_duration_seconds(attr): + """Deserialize a numeric number of seconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "seconds") + + @staticmethod + def deserialize_duration_milliseconds(attr): + """Deserialize a numeric number of milliseconds into a TimeDelta object. + + :param float attr: response value to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if value is invalid. + """ + return Deserializer._deserialize_duration_numeric(attr, "milliseconds") + @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_version.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_version.py index bbcd28b4aa67..0ec13ea52bbf 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_version.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0" diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/_patch.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/_patch.py index ea765788358a..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + __all__: list[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_operations.py index 0fc4dc0390d4..1bddb16a0981 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_operations.py @@ -31,7 +31,7 @@ from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models as _models +from ... import models as _models, types as _types from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer from ..._utils.utils import ClientMixinABC @@ -48,7 +48,6 @@ T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -JSON = MutableMapping[str, Any] List = list @@ -468,14 +467,19 @@ async def check_zone_peers( @overload async def check_zone_peers( - self, subscription_id: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + subscription_id: str, + parameters: _types.CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param parameters: The request body. Required. - :type parameters: JSON + :type parameters: ~azure.mgmt.resource.subscriptions.types.CheckZonePeersRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -504,16 +508,19 @@ async def check_zone_peers( @distributed_trace_async async def check_zone_peers( - self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, JSON, IO[bytes]], **kwargs: Any + self, + subscription_id: str, + parameters: Union[_models.CheckZonePeersRequest, _types.CheckZonePeersRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param parameters: The request body. Is one of the following types: CheckZonePeersRequest, - JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersRequest or JSON or - IO[bytes] + :param parameters: The request body. Is either a CheckZonePeersRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersRequest or + ~azure.mgmt.resource.subscriptions.types.CheckZonePeersRequest or IO[bytes] :return: CheckZonePeersResult. The CheckZonePeersResult is compatible with MutableMapping :rtype: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersResult :raises ~azure.core.exceptions.HttpResponseError: @@ -724,7 +731,11 @@ async def check_resource_name( @overload async def check_resource_name( - self, resource_name_definition: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any + self, + resource_name_definition: Optional[_types.ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckResourceNameResult: """Checks resource name validity. @@ -732,7 +743,7 @@ async def check_resource_name( does not start with a reserved word. :param resource_name_definition: The request body. Default value is None. - :type resource_name_definition: JSON + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.types.ResourceName :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -766,17 +777,19 @@ async def check_resource_name( @distributed_trace_async async def check_resource_name( - self, resource_name_definition: Optional[Union[_models.ResourceName, JSON, IO[bytes]]] = None, **kwargs: Any + self, + resource_name_definition: Optional[Union[_models.ResourceName, _types.ResourceName, IO[bytes]]] = None, + **kwargs: Any ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. - :param resource_name_definition: The request body. Is one of the following types: ResourceName, - JSON, IO[bytes] Default value is None. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.models.ResourceName or JSON - or IO[bytes] + :param resource_name_definition: The request body. Is either a ResourceName type or a IO[bytes] + type. Default value is None. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.models.ResourceName or + ~azure.mgmt.resource.subscriptions.types.ResourceName or IO[bytes] :return: CheckResourceNameResult. The CheckResourceNameResult is compatible with MutableMapping :rtype: ~azure.mgmt.resource.subscriptions.models.CheckResourceNameResult :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_patch.py index ea765788358a..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_patch.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/aio/operations/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + __all__: list[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/models/_patch.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/models/_patch.py index ea765788358a..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/models/_patch.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/models/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + __all__: list[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_operations.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_operations.py index 204aae16d916..e9694154204e 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_operations.py @@ -30,7 +30,7 @@ from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models as _models +from .. import models as _models, types as _types from .._configuration import SubscriptionClientConfiguration from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer @@ -38,7 +38,6 @@ T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() @@ -620,14 +619,19 @@ def check_zone_peers( @overload def check_zone_peers( - self, subscription_id: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + subscription_id: str, + parameters: _types.CheckZonePeersRequest, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param parameters: The request body. Required. - :type parameters: JSON + :type parameters: ~azure.mgmt.resource.subscriptions.types.CheckZonePeersRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -656,16 +660,19 @@ def check_zone_peers( @distributed_trace def check_zone_peers( - self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, JSON, IO[bytes]], **kwargs: Any + self, + subscription_id: str, + parameters: Union[_models.CheckZonePeersRequest, _types.CheckZonePeersRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param parameters: The request body. Is one of the following types: CheckZonePeersRequest, - JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersRequest or JSON or - IO[bytes] + :param parameters: The request body. Is either a CheckZonePeersRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersRequest or + ~azure.mgmt.resource.subscriptions.types.CheckZonePeersRequest or IO[bytes] :return: CheckZonePeersResult. The CheckZonePeersResult is compatible with MutableMapping :rtype: ~azure.mgmt.resource.subscriptions.models.CheckZonePeersResult :raises ~azure.core.exceptions.HttpResponseError: @@ -876,7 +883,11 @@ def check_resource_name( @overload def check_resource_name( - self, resource_name_definition: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any + self, + resource_name_definition: Optional[_types.ResourceName] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckResourceNameResult: """Checks resource name validity. @@ -884,7 +895,7 @@ def check_resource_name( does not start with a reserved word. :param resource_name_definition: The request body. Default value is None. - :type resource_name_definition: JSON + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.types.ResourceName :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -918,17 +929,19 @@ def check_resource_name( @distributed_trace def check_resource_name( - self, resource_name_definition: Optional[Union[_models.ResourceName, JSON, IO[bytes]]] = None, **kwargs: Any + self, + resource_name_definition: Optional[Union[_models.ResourceName, _types.ResourceName, IO[bytes]]] = None, + **kwargs: Any ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. - :param resource_name_definition: The request body. Is one of the following types: ResourceName, - JSON, IO[bytes] Default value is None. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.models.ResourceName or JSON - or IO[bytes] + :param resource_name_definition: The request body. Is either a ResourceName type or a IO[bytes] + type. Default value is None. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.models.ResourceName or + ~azure.mgmt.resource.subscriptions.types.ResourceName or IO[bytes] :return: CheckResourceNameResult. The CheckResourceNameResult is compatible with MutableMapping :rtype: ~azure.mgmt.resource.subscriptions.models.CheckResourceNameResult :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_patch.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_patch.py index ea765788358a..87676c65a8f0 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_patch.py +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/operations/_patch.py @@ -8,6 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ + __all__: list[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/types.py b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/types.py new file mode 100644 index 000000000000..955543cf79a9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource-subscriptions/azure/mgmt/resource/subscriptions/types.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing_extensions import Required, TypedDict + + +class CheckZonePeersRequest(TypedDict, total=False): + """Check zone peers request parameters. + + :ivar location: The Microsoft location. + :vartype location: str + :ivar subscription_ids: The peer Microsoft Azure subscription ID. + :vartype subscription_ids: list[str] + """ + + location: str + """The Microsoft location.""" + subscriptionIds: list[str] + """The peer Microsoft Azure subscription ID.""" + + +class ResourceName(TypedDict, total=False): + """Name and Type of the Resource. + + :ivar name: Name of the resource. Required. + :vartype name: str + :ivar type: The type of the resource. Required. + :vartype type: str + """ + + name: Required[str] + """Name of the resource. Required.""" + type: Required[str] + """The type of the resource. Required.""" diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/pyproject.toml b/sdk/resources/azure-mgmt-resource-subscriptions/pyproject.toml index 39be1765ba89..517bf9fd9042 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/pyproject.toml +++ b/sdk/resources/azure-mgmt-resource-subscriptions/pyproject.toml @@ -13,7 +13,7 @@ authors = [ description = "Microsoft Azure Subscriptions Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -21,6 +21,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] requires-python = ">=3.10" keywords = [ @@ -77,7 +78,7 @@ package_name = "azure-mgmt-resource-subscriptions" package_nspkg = "azure-mgmt-resource-nspkg" package_pprint_name = "Resource Subscriptions Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/resources/azure-mgmt-resource-subscriptions/tsp-location.yaml b/sdk/resources/azure-mgmt-resource-subscriptions/tsp-location.yaml index 104e0cd42146..67f98a1329e7 100644 --- a/sdk/resources/azure-mgmt-resource-subscriptions/tsp-location.yaml +++ b/sdk/resources/azure-mgmt-resource-subscriptions/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/resources/resource-manager/Microsoft.Resources/subscriptions -commit: f34830624e2040e4777496c73aa7c6fe764f4bfc +commit: cf49df24bee763924bb4d9abceebe4fd1916a6ad repo: Azure/azure-rest-api-specs additionalDirectories: