From 807e15501686972f1bd59150402d5bf306899752 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Fri, 7 Aug 2026 00:24:52 +0000 Subject: [PATCH 1/4] Configurations: 'specification/fabric/resource-manager/Microsoft.Fabric/Fabric/tspconfig.yaml', SDK Release Type: stable, and CommitSHA: 'a11c8d40bf2ab8aed7c8debec9528bff36a7ae2a' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6670686 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- sdk/fabric/azure-mgmt-fabric/CHANGELOG.md | 6 + sdk/fabric/azure-mgmt-fabric/MANIFEST.in | 9 +- sdk/fabric/azure-mgmt-fabric/README.md | 6 +- sdk/fabric/azure-mgmt-fabric/_meta.json | 6 - sdk/fabric/azure-mgmt-fabric/_metadata.json | 11 + sdk/fabric/azure-mgmt-fabric/api.md | 917 ++++++++++++++++++ sdk/fabric/azure-mgmt-fabric/api.metadata.yml | 3 + .../azure-mgmt-fabric/apiview-properties.json | 61 ++ .../azure-mgmt-fabric/azure/__init__.py | 2 +- .../azure-mgmt-fabric/azure/mgmt/__init__.py | 2 +- .../azure/mgmt/fabric/__init__.py | 10 +- .../azure/mgmt/fabric/_client.py | 46 +- .../azure/mgmt/fabric/_configuration.py | 19 +- .../azure/mgmt/fabric/_patch.py | 13 +- .../azure/mgmt/fabric/_utils/__init__.py | 6 + .../{_model_base.py => _utils/model_base.py} | 884 ++++++++++++++--- .../serialization.py} | 379 +++++--- .../azure/mgmt/fabric/_validation.py | 66 ++ .../azure/mgmt/fabric/_version.py | 2 +- .../azure/mgmt/fabric/aio/__init__.py | 10 +- .../azure/mgmt/fabric/aio/_client.py | 48 +- .../azure/mgmt/fabric/aio/_configuration.py | 19 +- .../azure/mgmt/fabric/aio/_patch.py | 13 +- .../mgmt/fabric/aio/operations/__init__.py | 12 +- .../mgmt/fabric/aio/operations/_operations.py | 337 +++++-- .../mgmt/fabric/aio/operations/_patch.py | 13 +- .../azure/mgmt/fabric/models/__init__.py | 71 +- .../azure/mgmt/fabric/models/_enums.py | 41 +- .../azure/mgmt/fabric/models/_models.py | 346 +++++-- .../azure/mgmt/fabric/models/_patch.py | 13 +- .../azure/mgmt/fabric/operations/__init__.py | 12 +- .../mgmt/fabric/operations/_operations.py | 432 ++++++--- .../azure/mgmt/fabric/operations/_patch.py | 13 +- .../azure/mgmt/fabric/types.py | 260 +++++ ...bric_capacities_check_name_availability.py | 2 +- .../fabric_capacities_create_or_update.py | 7 +- .../fabric_capacities_delete.py | 2 +- .../fabric_capacities_get.py | 2 +- ...abric_capacities_list_by_resource_group.py | 2 +- .../fabric_capacities_list_by_subscription.py | 2 +- .../fabric_capacities_list_skus.py | 2 +- ...abric_capacities_list_skus_for_capacity.py | 2 +- ..._capacities_list_usages_by_subscription.py | 42 + .../fabric_capacities_resume.py | 2 +- .../fabric_capacities_suspend.py | 2 +- .../fabric_capacities_update.py | 7 +- .../generated_samples/operations_list.py | 2 +- ...abric_mgmt_fabric_capacities_operations.py | 22 +- ...mgmt_fabric_capacities_operations_async.py | 22 +- sdk/fabric/azure-mgmt-fabric/pyproject.toml | 82 ++ .../azure-mgmt-fabric/sdk_packaging.toml | 12 - sdk/fabric/azure-mgmt-fabric/setup.py | 83 -- .../azure-mgmt-fabric/tsp-location.yaml | 4 +- 53 files changed, 3559 insertions(+), 830 deletions(-) delete mode 100644 sdk/fabric/azure-mgmt-fabric/_meta.json create mode 100644 sdk/fabric/azure-mgmt-fabric/_metadata.json create mode 100644 sdk/fabric/azure-mgmt-fabric/api.md create mode 100644 sdk/fabric/azure-mgmt-fabric/api.metadata.yml create mode 100644 sdk/fabric/azure-mgmt-fabric/apiview-properties.json create mode 100644 sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/__init__.py rename sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/{_model_base.py => _utils/model_base.py} (53%) rename sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/{_serialization.py => _utils/serialization.py} (87%) create mode 100644 sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_validation.py create mode 100644 sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/types.py create mode 100644 sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_usages_by_subscription.py delete mode 100644 sdk/fabric/azure-mgmt-fabric/sdk_packaging.toml delete mode 100644 sdk/fabric/azure-mgmt-fabric/setup.py diff --git a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md index 88133de54311..59cbdb37e275 100644 --- a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md +++ b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2026-08-07) + +WARNING: Stable SDK version 1.1.0 is used with preview API version 2026-08-01-preview. If this is expected, delete this line; otherwise, check this PR. + +tool can't generate changelog for this release, please update manually. + ## 1.0.0 (2024-10-21) ### Other Changes diff --git a/sdk/fabric/azure-mgmt-fabric/MANIFEST.in b/sdk/fabric/azure-mgmt-fabric/MANIFEST.in index b5aac3bd8f0a..c364ed694ea4 100644 --- a/sdk/fabric/azure-mgmt-fabric/MANIFEST.in +++ b/sdk/fabric/azure-mgmt-fabric/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/fabric/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/fabric/azure-mgmt-fabric/README.md b/sdk/fabric/azure-mgmt-fabric/README.md index 61b8c45bb533..b96fbc4969f5 100644 --- a/sdk/fabric/azure-mgmt-fabric/README.md +++ b/sdk/fabric/azure-mgmt-fabric/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Fabric Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.10+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.10+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of 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/fabric/azure-mgmt-fabric/_meta.json b/sdk/fabric/azure-mgmt-fabric/_meta.json deleted file mode 100644 index 9823b57d01c5..000000000000 --- a/sdk/fabric/azure-mgmt-fabric/_meta.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "commit": "9ce76c4f113368361dac4de5d0a71eb058602756", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "typespec_src": "specification/fabric/Microsoft.Fabric.Management", - "@azure-tools/typespec-python": "0.36.0" -} \ No newline at end of file diff --git a/sdk/fabric/azure-mgmt-fabric/_metadata.json b/sdk/fabric/azure-mgmt-fabric/_metadata.json new file mode 100644 index 000000000000..1b0f57384835 --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/_metadata.json @@ -0,0 +1,11 @@ +{ + "apiVersion": "2026-08-01-preview", + "apiVersions": { + "Microsoft.Fabric": "2026-08-01-preview" + }, + "commit": "a11c8d40bf2ab8aed7c8debec9528bff36a7ae2a", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/fabric/resource-manager/Microsoft.Fabric/Fabric", + "emitterVersion": "0.63.3", + "httpClientPythonVersion": "^0.35.1" +} \ No newline at end of file diff --git a/sdk/fabric/azure-mgmt-fabric/api.md b/sdk/fabric/azure-mgmt-fabric/api.md new file mode 100644 index 000000000000..532ab4471e10 --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/api.md @@ -0,0 +1,917 @@ +```py +namespace azure.mgmt.fabric + + class azure.mgmt.fabric.FabricMgmtClient: implements ContextManager + fabric_capacities: FabricCapacitiesOperations + operations: Operations + + def __init__( + self, + credential: TokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> HttpResponse: ... + + +namespace azure.mgmt.fabric.aio + + class azure.mgmt.fabric.aio.FabricMgmtClient: implements AsyncContextManager + fabric_capacities: FabricCapacitiesOperations + operations: Operations + + def __init__( + self, + credential: AsyncTokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + async def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: ... + + +namespace azure.mgmt.fabric.aio.operations + + class azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: FabricCapacity, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: FabricCapacity, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def begin_resume( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + async def begin_suspend( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: FabricCapacityUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: FabricCapacityUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[FabricCapacity]: ... + + @overload + async def check_name_availability( + self, + location: str, + body: CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @overload + async def check_name_availability( + self, + location: str, + body: CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @overload + async def check_name_availability( + self, + location: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> FabricCapacity: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncItemPaged[FabricCapacity]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged[FabricCapacity]: ... + + @distributed_trace + def list_skus(self, **kwargs: Any) -> AsyncItemPaged[RpSkuDetailsForNewResource]: ... + + @distributed_trace + def list_skus_for_capacity( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> AsyncItemPaged[RpSkuDetailsForExistingResource]: ... + + @distributed_trace + @api_version_validation(method_added_on='2025-01-15-preview', params_added_on={'2025-01-15-preview': ['api_version', 'subscription_id', 'location', 'accept']}, api_versions_list=['2025-01-15-preview', '2026-08-01-preview']) + def list_usages( + self, + location: str, + **kwargs: Any + ) -> AsyncItemPaged[Quota]: ... + + + class azure.mgmt.fabric.aio.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[Operation]: ... + + +namespace azure.mgmt.fabric.models + + class azure.mgmt.fabric.models.ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + INTERNAL = "Internal" + + + class azure.mgmt.fabric.models.CapacityAdministration(_Model): + members: list[str] + + @overload + def __init__( + self, + *, + members: list[str] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.CapacityOverageProperties(_Model): + state: Optional[Union[str, CapacityOverageState]] + threshold_capacity_unit_hours: Optional[int] + + @overload + def __init__( + self, + *, + state: Optional[Union[str, CapacityOverageState]] = ..., + threshold_capacity_unit_hours: Optional[int] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.CapacityOverageState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + DISABLED = "Disabled" + ENABLED = "Enabled" + + + class azure.mgmt.fabric.models.CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ALREADY_EXISTS = "AlreadyExists" + INVALID = "Invalid" + + + class azure.mgmt.fabric.models.CheckNameAvailabilityRequest(_Model): + name: Optional[str] + type: Optional[str] + + @overload + def __init__( + self, + *, + name: Optional[str] = ..., + type: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.CheckNameAvailabilityResponse(_Model): + message: Optional[str] + name_available: Optional[bool] + reason: Optional[Union[str, CheckNameAvailabilityReason]] + + @overload + def __init__( + self, + *, + message: Optional[str] = ..., + name_available: Optional[bool] = ..., + reason: Optional[Union[str, CheckNameAvailabilityReason]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPLICATION = "Application" + KEY = "Key" + MANAGED_IDENTITY = "ManagedIdentity" + USER = "User" + + + class azure.mgmt.fabric.models.ErrorAdditionalInfo(_Model): + info: Optional[Any] + type: Optional[str] + + + class azure.mgmt.fabric.models.ErrorDetail(_Model): + additional_info: Optional[list[ErrorAdditionalInfo]] + code: Optional[str] + details: Optional[list[ErrorDetail]] + message: Optional[str] + target: Optional[str] + + + class azure.mgmt.fabric.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.fabric.models.FabricCapacity(TrackedResource): + id: str + location: str + name: str + properties: FabricCapacityProperties + sku: RpSku + system_data: SystemData + tags: dict[str, str] + type: str + + @overload + def __init__( + self, + *, + location: str, + properties: FabricCapacityProperties, + sku: RpSku, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.FabricCapacityProperties(_Model): + administration: CapacityAdministration + overage: Optional[CapacityOverageProperties] + provisioning_state: Optional[Union[str, ProvisioningState]] + state: Optional[Union[str, ResourceState]] + + @overload + def __init__( + self, + *, + administration: CapacityAdministration, + overage: Optional[CapacityOverageProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.FabricCapacityUpdate(_Model): + properties: Optional[FabricCapacityUpdateProperties] + sku: Optional[RpSku] + tags: Optional[dict[str, str]] + + @overload + def __init__( + self, + *, + properties: Optional[FabricCapacityUpdateProperties] = ..., + sku: Optional[RpSku] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.FabricCapacityUpdateProperties(_Model): + administration: Optional[CapacityAdministration] + overage: Optional[CapacityOverageProperties] + + @overload + def __init__( + self, + *, + administration: Optional[CapacityAdministration] = ..., + overage: Optional[CapacityOverageProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.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.fabric.models.OperationDisplay(_Model): + description: Optional[str] + operation: Optional[str] + provider: Optional[str] + resource: Optional[str] + + + class azure.mgmt.fabric.models.Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + SYSTEM = "system" + USER = "user" + USER_SYSTEM = "user,system" + + + class azure.mgmt.fabric.models.ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CANCELED = "Canceled" + DELETING = "Deleting" + FAILED = "Failed" + PROVISIONING = "Provisioning" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + + class azure.mgmt.fabric.models.Quota(_Model): + current_value: int + limit: int + name: Optional[QuotaName] + unit: str + + @overload + def __init__( + self, + *, + current_value: int, + limit: int, + unit: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.QuotaName(_Model): + localized_value: Optional[str] + value: Optional[str] + + @overload + def __init__( + self, + *, + localized_value: Optional[str] = ..., + value: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.Resource(_Model): + id: Optional[str] + name: Optional[str] + system_data: Optional[SystemData] + type: Optional[str] + + + class azure.mgmt.fabric.models.ResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ACTIVE = "Active" + DELETING = "Deleting" + FAILED = "Failed" + PAUSED = "Paused" + PAUSING = "Pausing" + PREPARING = "Preparing" + PROVISIONING = "Provisioning" + RESUMING = "Resuming" + SCALING = "Scaling" + SUSPENDED = "Suspended" + SUSPENDING = "Suspending" + UPDATING = "Updating" + + + class azure.mgmt.fabric.models.RpSku(_Model): + name: str + tier: Union[str, RpSkuTier] + + @overload + def __init__( + self, + *, + name: str, + tier: Union[str, RpSkuTier] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.RpSkuDetailsForExistingResource(_Model): + resource_type: str + sku: RpSku + + @overload + def __init__( + self, + *, + resource_type: str, + sku: RpSku + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.RpSkuDetailsForNewResource(_Model): + locations: list[str] + name: str + resource_type: str + + @overload + def __init__( + self, + *, + locations: list[str], + name: str, + resource_type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.RpSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + FABRIC = "Fabric" + + + class azure.mgmt.fabric.models.SystemData(_Model): + created_at: Optional[datetime] + created_by: Optional[str] + created_by_type: Optional[Union[str, CreatedByType]] + last_modified_at: Optional[datetime] + last_modified_by: Optional[str] + last_modified_by_type: Optional[Union[str, CreatedByType]] + + @overload + def __init__( + self, + *, + created_at: Optional[datetime] = ..., + created_by: Optional[str] = ..., + created_by_type: Optional[Union[str, CreatedByType]] = ..., + last_modified_at: Optional[datetime] = ..., + last_modified_by: Optional[str] = ..., + last_modified_by_type: Optional[Union[str, CreatedByType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.fabric.models.TrackedResource(Resource): + id: str + location: str + name: str + system_data: SystemData + tags: Optional[dict[str, str]] + type: str + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + +namespace azure.mgmt.fabric.operations + + class azure.mgmt.fabric.operations.FabricCapacitiesOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: FabricCapacity, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: FabricCapacity, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + capacity_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def begin_resume( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + def begin_suspend( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: FabricCapacityUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: FabricCapacityUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + capacity_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[FabricCapacity]: ... + + @overload + def check_name_availability( + self, + location: str, + body: CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @overload + def check_name_availability( + self, + location: str, + body: CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @overload + def check_name_availability( + self, + location: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> CheckNameAvailabilityResponse: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> FabricCapacity: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> ItemPaged[FabricCapacity]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged[FabricCapacity]: ... + + @distributed_trace + def list_skus(self, **kwargs: Any) -> ItemPaged[RpSkuDetailsForNewResource]: ... + + @distributed_trace + def list_skus_for_capacity( + self, + resource_group_name: str, + capacity_name: str, + **kwargs: Any + ) -> ItemPaged[RpSkuDetailsForExistingResource]: ... + + @distributed_trace + @api_version_validation(method_added_on='2025-01-15-preview', params_added_on={'2025-01-15-preview': ['api_version', 'subscription_id', 'location', 'accept']}, api_versions_list=['2025-01-15-preview', '2026-08-01-preview']) + def list_usages( + self, + location: str, + **kwargs: Any + ) -> ItemPaged[Quota]: ... + + + class azure.mgmt.fabric.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[Operation]: ... + + +namespace azure.mgmt.fabric.types + + class azure.mgmt.fabric.types.CapacityAdministration(TypedDict, total=False): + key "members": Required[list[str]] + members: list[str] + + + class azure.mgmt.fabric.types.CapacityOverageProperties(TypedDict, total=False): + key "state": Union[str, CapacityOverageState] + key "thresholdCapacityUnitHours": int + state: Union[str, CapacityOverageState] + thresholdCapacityUnitHours: int + + + class azure.mgmt.fabric.types.CheckNameAvailabilityRequest(TypedDict, total=False): + key "name": str + key "type": str + name: str + type: str + + + class azure.mgmt.fabric.types.FabricCapacity(TrackedResource): + key "id": str + key "location": Required[str] + key "name": str + key "properties": Required[FabricCapacityProperties] + key "sku": Required[RpSku] + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + properties: FabricCapacityProperties + sku: RpSku + systemData: SystemData + tags: dict[str, str] + type: str + + + class azure.mgmt.fabric.types.FabricCapacityProperties(TypedDict, total=False): + key "administration": Required[CapacityAdministration] + key "overage": ForwardRef('CapacityOverageProperties', module='types') + key "provisioningState": Union[str, ProvisioningState] + key "state": Union[str, ResourceState] + administration: CapacityAdministration + overage: CapacityOverageProperties + provisioningState: Union[str, ProvisioningState] + state: Union[str, ResourceState] + + + class azure.mgmt.fabric.types.FabricCapacityUpdate(TypedDict, total=False): + key "properties": ForwardRef('FabricCapacityUpdateProperties', module='types') + key "sku": ForwardRef('RpSku', module='types') + properties: FabricCapacityUpdateProperties + sku: RpSku + tags: dict[str, str] + + + class azure.mgmt.fabric.types.FabricCapacityUpdateProperties(TypedDict, total=False): + key "administration": ForwardRef('CapacityAdministration', module='types') + key "overage": ForwardRef('CapacityOverageProperties', module='types') + administration: CapacityAdministration + overage: CapacityOverageProperties + + + class azure.mgmt.fabric.types.Resource(TypedDict, total=False): + key "id": str + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + name: str + systemData: SystemData + type: str + + + class azure.mgmt.fabric.types.RpSku(TypedDict, total=False): + key "name": Required[str] + key "tier": Required[Union[str, RpSkuTier]] + name: str + tier: Union[str, RpSkuTier] + + + class azure.mgmt.fabric.types.SystemData(TypedDict, total=False): + key "createdAt": str + key "createdBy": str + key "createdByType": Union[str, CreatedByType] + key "lastModifiedAt": str + key "lastModifiedBy": str + key "lastModifiedByType": Union[str, CreatedByType] + createdAt: str + createdBy: str + createdByType: Union[str, CreatedByType] + lastModifiedAt: str + lastModifiedBy: str + lastModifiedByType: Union[str, CreatedByType] + + + class azure.mgmt.fabric.types.TrackedResource(Resource): + key "id": str + key "location": Required[str] + key "name": str + key "systemData": ForwardRef('SystemData', module='types') + key "type": str + id: str + location: str + name: str + systemData: SystemData + tags: dict[str, str] + type: str + + +``` \ No newline at end of file diff --git a/sdk/fabric/azure-mgmt-fabric/api.metadata.yml b/sdk/fabric/azure-mgmt-fabric/api.metadata.yml new file mode 100644 index 000000000000..308692b30c97 --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/api.metadata.yml @@ -0,0 +1,3 @@ +apiMdSha256: 2021a2478c67c545e0a55c0cf11de33f89352614be3c4c2a8935627ea6039951 +parserVersion: 0.3.31 +pythonVersion: 3.13.14 diff --git a/sdk/fabric/azure-mgmt-fabric/apiview-properties.json b/sdk/fabric/azure-mgmt-fabric/apiview-properties.json new file mode 100644 index 000000000000..55f4694dffdd --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/apiview-properties.json @@ -0,0 +1,61 @@ +{ + "CrossLanguagePackageId": "Microsoft.Fabric", + "CrossLanguageDefinitionId": { + "azure.mgmt.fabric.models.CapacityAdministration": "Microsoft.Fabric.CapacityAdministration", + "azure.mgmt.fabric.models.CapacityOverageProperties": "Microsoft.Fabric.CapacityOverageProperties", + "azure.mgmt.fabric.models.CheckNameAvailabilityRequest": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest", + "azure.mgmt.fabric.models.CheckNameAvailabilityResponse": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse", + "azure.mgmt.fabric.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.fabric.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.fabric.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.fabric.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.fabric.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.fabric.models.FabricCapacity": "Microsoft.Fabric.FabricCapacity", + "azure.mgmt.fabric.models.FabricCapacityProperties": "Microsoft.Fabric.FabricCapacityProperties", + "azure.mgmt.fabric.models.FabricCapacityUpdate": "Azure.ResourceManager.Foundations.ResourceUpdateModel", + "azure.mgmt.fabric.models.FabricCapacityUpdateProperties": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties", + "azure.mgmt.fabric.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.fabric.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.fabric.models.Quota": "Microsoft.Fabric.Quota", + "azure.mgmt.fabric.models.QuotaName": "Microsoft.Fabric.QuotaName", + "azure.mgmt.fabric.models.RpSku": "Microsoft.Fabric.RpSku", + "azure.mgmt.fabric.models.RpSkuDetailsForExistingResource": "Microsoft.Fabric.RpSkuDetailsForExistingResource", + "azure.mgmt.fabric.models.RpSkuDetailsForNewResource": "Microsoft.Fabric.RpSkuDetailsForNewResource", + "azure.mgmt.fabric.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.fabric.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.fabric.models.ProvisioningState": "Microsoft.Fabric.ProvisioningState", + "azure.mgmt.fabric.models.ResourceState": "Microsoft.Fabric.ResourceState", + "azure.mgmt.fabric.models.CapacityOverageState": "Microsoft.Fabric.CapacityOverageState", + "azure.mgmt.fabric.models.RpSkuTier": "Microsoft.Fabric.RpSkuTier", + "azure.mgmt.fabric.models.CheckNameAvailabilityReason": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason", + "azure.mgmt.fabric.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.fabric.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.get": "Microsoft.Fabric.FabricCapacities.get", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.get": "Microsoft.Fabric.FabricCapacities.get", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.begin_create_or_update": "Microsoft.Fabric.FabricCapacities.createOrUpdate", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.begin_create_or_update": "Microsoft.Fabric.FabricCapacities.createOrUpdate", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.begin_update": "Microsoft.Fabric.FabricCapacities.update", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.begin_update": "Microsoft.Fabric.FabricCapacities.update", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.begin_delete": "Microsoft.Fabric.FabricCapacities.delete", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.begin_delete": "Microsoft.Fabric.FabricCapacities.delete", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.list_by_resource_group": "Microsoft.Fabric.FabricCapacities.listByResourceGroup", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.list_by_resource_group": "Microsoft.Fabric.FabricCapacities.listByResourceGroup", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.list_by_subscription": "Microsoft.Fabric.FabricCapacities.listBySubscription", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.list_by_subscription": "Microsoft.Fabric.FabricCapacities.listBySubscription", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.begin_resume": "Microsoft.Fabric.FabricCapacities.resume", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.begin_resume": "Microsoft.Fabric.FabricCapacities.resume", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.begin_suspend": "Microsoft.Fabric.FabricCapacities.suspend", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.begin_suspend": "Microsoft.Fabric.FabricCapacities.suspend", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.check_name_availability": "Microsoft.Fabric.FabricCapacities.checkNameAvailability", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.check_name_availability": "Microsoft.Fabric.FabricCapacities.checkNameAvailability", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.list_skus_for_capacity": "Microsoft.Fabric.FabricCapacities.listSkusForCapacity", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.list_skus_for_capacity": "Microsoft.Fabric.FabricCapacities.listSkusForCapacity", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.list_skus": "Microsoft.Fabric.FabricCapacities.listSkus", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.list_skus": "Microsoft.Fabric.FabricCapacities.listSkus", + "azure.mgmt.fabric.operations.FabricCapacitiesOperations.list_usages": "Microsoft.Fabric.FabricCapacities.listUsages", + "azure.mgmt.fabric.aio.operations.FabricCapacitiesOperations.list_usages": "Microsoft.Fabric.FabricCapacities.listUsages", + "azure.mgmt.fabric.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.fabric.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list" + }, + "CrossLanguageVersion": "663845fadb51" +} \ No newline at end of file diff --git a/sdk/fabric/azure-mgmt-fabric/azure/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/__init__.py index 302b37eefa01..5921df3dd515 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import FabricMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import FabricMgmtClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_client.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_client.py index 7082b98c2462..fac8d97ebe77 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_client.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_client.py @@ -7,23 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Optional, TYPE_CHECKING, cast from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from ._configuration import FabricMgmtClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import FabricCapacitiesOperations, Operations +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class FabricMgmtClient: +class FabricMgmtClient: # pylint: disable=docstring-keyword-should-match-keyword-only """FabricMgmtClient. :ivar fabric_capacities: FabricCapacitiesOperations operations @@ -34,10 +42,15 @@ class FabricMgmtClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -47,13 +60,26 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = FabricMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -72,7 +98,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_configuration.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_configuration.py index e6c0c711d9ab..add86fde23a1 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_configuration.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,10 +15,11 @@ from ._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes +class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,docstring-keyword-should-match-keyword-only """Configuration for FabricMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,8 +31,13 @@ class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attrib :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -39,9 +46,10 @@ def __init__( credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2026-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,6 +59,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-fabric/{}".format(VERSION)) diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_patch.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_patch.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_model_base.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/model_base.py similarity index 53% rename from sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_model_base.py rename to sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/model_base.py index 9d401b0cf012..35d5fc024978 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_model_base.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/model_base.py @@ -1,11 +1,12 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # 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. +# 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. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines +# pylint: disable=protected-access, broad-except import copy import calendar @@ -21,17 +22,19 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET -from typing_extensions import Self +from collections.abc import MutableMapping import isodate from azure.core.exceptions import DeserializationError from azure.core import CaseInsensitiveEnumMeta from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self else: - from typing import MutableMapping + from typing_extensions import Self _LOGGER = logging.getLogger(__name__) @@ -39,6 +42,7 @@ TZ_UTC = timezone.utc _T = typing.TypeVar("_T") +_NONE_TYPE = type(None) def _timedelta_as_isostr(td: timedelta) -> str: @@ -105,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": @@ -131,7 +158,15 @@ def _is_readonly(p): class SdkJSONEncoder(JSONEncoder): - """A JSON encoder that's capable of serializing datetime objects and bytes.""" + """A JSON encoder that's capable of serializing datetime objects and bytes. + + :param args: Additional positional arguments passed to the base ``JSONEncoder``. + :type args: typing.Any + :keyword exclude_readonly: Whether to exclude readonly properties. Defaults to False. + :paramtype exclude_readonly: bool + :keyword format: The format to use for serialization. Defaults to None. + :paramtype format: typing.Optional[str] + """ def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): super().__init__(*args, **kwargs) @@ -173,6 +208,21 @@ def default(self, o): # pylint: disable=too-many-return-statements r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" ) +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: """Deserialize ISO-8601 formatted string into Datetime object. @@ -204,7 +254,7 @@ def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: test_utc = date_obj.utctimetuple() if test_utc.tm_year > 9999 or test_utc.tm_year < 1: raise OverflowError("Hit max or min date") - return date_obj + return date_obj # type: ignore[no-any-return] def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: @@ -258,7 +308,7 @@ def _deserialize_time(attr: typing.Union[str, time]) -> time: """ if isinstance(attr, time): return attr - return isodate.parse_time(attr) + return isodate.parse_time(attr) # type: ignore[no-any-return] def _deserialize_bytes(attr): @@ -282,6 +332,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 @@ -294,6 +350,12 @@ def _deserialize_int_as_str(attr): return int(attr) +def _deserialize_bool_as_str(attr): + if isinstance(attr, bool): + return attr + return attr.lower() == "true" + + _DESERIALIZE_MAPPING = { datetime: _deserialize_datetime, date: _deserialize_date, @@ -311,12 +373,20 @@ 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"), } def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): if annotation is int and rf and rf._format == "str": return _deserialize_int_as_str + if annotation is bool and rf and rf._format == "str": + return _deserialize_bool_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) if rf and rf._format: return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore @@ -347,17 +417,47 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: self._data = data def __contains__(self, key: typing.Any) -> bool: return key in self._data def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized return self._data.__getitem__(key) def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass self._data.__setitem__(key, value) def __delitem__(self, key: str) -> None: @@ -373,55 +473,105 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :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 the mapping's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: a set-like object providing a view on the mapping's items + :rtype: ~typing.ItemsView + """ return self._data.items() 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: The value for key if key is in the dictionary, else default. + :rtype: any + """ try: return self[key] except KeyError: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) - def popitem(self) -> typing.Tuple[str, typing.Any]: + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if the dictionary is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from the dictionary. + """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + 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) @typing.overload def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + 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: The value for key if key is in the dictionary, else default. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data try: other_model = self.__class__(other) except Exception: @@ -438,6 +588,8 @@ def _is_model(obj: typing.Any) -> bool: def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) return [_serialize(x, format) for x in o] if isinstance(o, dict): return {k: _serialize(v, format) for k, v in o.items()} @@ -462,16 +614,14 @@ 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 return o -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: try: return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) except StopIteration: @@ -490,69 +640,253 @@ 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 # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() + _calculated: set[str] = set() def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: class_name = self.__class__.__name__ if len(args) > 1: raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks + dict_to_pass: dict[str, typing.Any] = {} + if args: if isinstance(args[0], ET.Element): - existed_attr_keys = [] - 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 = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) + dict_to_pass.update(self._init_from_xml(args[0])) else: dict_to_pass.update( {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} @@ -569,24 +903,133 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: if v is not None } ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) super().__init__(dict_to_pass) + 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. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + 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, 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] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") } annotations = { k: v for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() } for attr, rf in attr_to_rest_field.items(): rf._module = cls.__module__ @@ -594,15 +1037,18 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) if not rf._rest_name_input: rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + 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) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: - if hasattr(base, "__mapping__"): # pylint: disable=no-member - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: @@ -613,7 +1059,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField @classmethod def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + if not hasattr(cls, "__mapping__"): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) if discriminator is None: @@ -623,7 +1069,7 @@ def _deserialize(cls, data, exist_discriminators): model_meta = getattr(cls, "_xml", {}) prop_meta = getattr(discriminator, "_xml", {}) xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) if xml_ns: xml_name = "{" + xml_ns + "}" + xml_name @@ -636,7 +1082,7 @@ def _deserialize(cls, data, exist_discriminators): mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member return mapped_cls._deserialize(data, exist_discriminators) - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: """Return a dict that can be turned into json using json.dump. :keyword bool exclude_readonly: Whether to remove the readonly properties. @@ -696,7 +1142,7 @@ def _deserialize_with_union(deserializers, obj): def _deserialize_dict( value_deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], + obj: dict[typing.Any, typing.Any], ): if obj is None: return obj @@ -706,7 +1152,7 @@ def _deserialize_dict( def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], + entry_deserializers: list[typing.Optional[typing.Callable]], module: typing.Optional[str], obj, ): @@ -715,6 +1161,14 @@ def _deserialize_multiple_sequence( return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + def _deserialize_sequence( deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], @@ -724,17 +1178,30 @@ def _deserialize_sequence( return obj if isinstance(obj, ET.Element): obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: return sorted( types, key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), ) -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches annotation: typing.Any, module: typing.Optional[str], rf: typing.Optional["_RestField"] = None, @@ -754,7 +1221,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except AttributeError: model_name = annotation if module is not None: - annotation = _get_model(module, model_name) + annotation = _get_model(module, model_name) # type: ignore try: if module and _is_model(annotation): @@ -774,16 +1241,18 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur # is it optional? try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True if len(annotation.__args__) <= 2: # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore ) return functools.partial(_deserialize_with_optional, if_obj_deserializer) # the type is Optional[Union[...]], we need to remove the None type from the Union annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass @@ -799,7 +1268,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur return functools.partial(_deserialize_with_union, deserializers) try: - if annotation._name == "Dict": # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": value_deserializer = _get_deserialize_callable_from_annotation( annotation.__args__[1], module, rf # pyright: ignore ) @@ -812,7 +1284,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except (AttributeError, IndexError): pass try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: if len(annotation.__args__) > 1: # pyright: ignore entry_deserializers = [ _get_deserialize_callable_from_annotation(dt, module, rf) @@ -861,16 +1336,20 @@ def _deserialize_with_callable( return float(value.text) if value.text else None if deserializer is bool: return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None if deserializer is None: return value if deserializer in [int, float, bool]: return deserializer(value) if isinstance(deserializer, CaseInsensitiveEnumMeta): try: - return deserializer(value) + return deserializer(value.text if isinstance(value, ET.Element) else value) except ValueError: # for unknown value, return raw value - return value + return value.text if isinstance(value, ET.Element) else value if isinstance(deserializer, type) and issubclass(deserializer, Model): return deserializer._deserialize(value, []) return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) @@ -894,6 +1373,36 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes class _RestField: def __init__( self, @@ -901,11 +1410,12 @@ def __init__( name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ): self._type = type self._rest_name_input = name @@ -913,14 +1423,20 @@ def __init__( self._is_discriminator = is_discriminator self._visibility = visibility self._is_model = False + self._is_optional = False self._default = default 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: - return getattr(self._type, "args", [None])[0] + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result @property def _rest_name(self) -> str: @@ -931,14 +1447,44 @@ def _rest_name(self) -> str: def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin # by this point, type and rest_name will have a value bc we default # them in __new__ of the Model class - item = obj.get(self._rest_name) + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None if item is None: return item if self._is_model: return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # 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 + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + if value is None: # we want to wipe out entries if users set attr to None try: @@ -963,11 +1509,12 @@ def rest_field( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ) -> typing.Any: return _RestField( name=name, @@ -977,6 +1524,7 @@ def rest_field( format=format, is_multipart_file_input=is_multipart_file_input, xml=xml, + deserializer=deserializer, ) @@ -984,8 +1532,8 @@ def rest_discriminator( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, ) -> typing.Any: return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) @@ -1001,21 +1549,77 @@ def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + def _get_element( o: typing.Any, exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: +) -> typing.Union[ET.Element, list[ET.Element]]: if _is_model(o): model_meta = getattr(o, "_xml", {}) # if prop is a model, then use the prop element directly, else generate a wrapper of model if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), + element_name, model_meta.get("prefix"), - model_meta.get("ns"), + _model_ns, ) readonly_props = [] @@ -1037,7 +1641,9 @@ def _get_element( # additional properties will not have rest field, use the wire name as xml name prop_meta = {"name": k} - # if no ns for prop, use model's + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. if prop_meta.get("ns") is None and model_meta.get("ns"): prop_meta["ns"] = model_meta.get("ns") prop_meta["prefix"] = model_meta.get("prefix") @@ -1049,12 +1655,7 @@ def _get_element( # text could only set on primitive type wrapped_element.text = _get_primitive_type_value(v) elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) + _set_xml_attribute(wrapped_element, k, v, prop_meta) else: # other wrapped prop element wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) @@ -1063,6 +1664,7 @@ def _get_element( return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore if isinstance(o, dict): result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None for k, v in o.items(): result.append( _get_wrapped_element( @@ -1070,7 +1672,7 @@ def _get_element( exclude_readonly, { "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, + "ns": _dict_ns, "prefix": parent_meta.get("prefix") if parent_meta else None, }, ) @@ -1079,13 +1681,16 @@ def _get_element( # primitive case need to create element based on parent_meta if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) return _get_wrapped_element( o, exclude_readonly, { "name": parent_meta.get("itemsName", parent_meta.get("name")), "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + "ns": _items_ns, }, ) @@ -1095,10 +1700,11 @@ def _get_element( def _get_wrapped_element( v: typing.Any, exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], + meta: typing.Optional[dict[str, typing.Any]], ) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns ) if isinstance(v, (dict, list)): wrapped_element.extend(_get_element(v, exclude_readonly, meta)) @@ -1106,7 +1712,7 @@ def _get_wrapped_element( _get_element(v, exclude_readonly, meta, wrapped_element) else: wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element + return wrapped_element # type: ignore[no-any-return] def _get_primitive_type_value(v) -> str: @@ -1119,9 +1725,29 @@ def _get_primitive_type_value(v) -> str: return str(v) -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) if ns: return ET.Element("{" + ns + "}" + tag) return ET.Element(tag) @@ -1132,13 +1758,15 @@ def _deserialize_xml( value: str, ) -> typing.Any: element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) return _deserialize(deserializer, element) def _convert_element(e: ET.Element): # dict case if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} + dict_result: dict[str, typing.Any] = {} for child in e: if dict_result.get(child.tag) is not None: if isinstance(dict_result[child.tag], list): @@ -1151,7 +1779,7 @@ def _convert_element(e: ET.Element): return dict_result # array case if len(e) > 0: - array_result: typing.List[typing.Any] = [] + array_result: list[typing.Any] = [] for child in e: array_result.append(_convert_element(child)) return array_result diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_serialization.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/serialization.py similarity index 87% rename from sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_serialization.py rename to sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/serialization.py index 480e941d758f..ae08f9d89f74 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_serialization.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_utils/serialization.py @@ -1,27 +1,10 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -38,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -47,10 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, ) try: @@ -64,9 +43,13 @@ from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -184,73 +167,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -396,7 +313,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -449,25 +366,25 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -478,8 +395,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -499,14 +416,13 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. :param dict response: The initial data :param dict objects: The class objects @@ -518,7 +434,7 @@ def _classify(cls, response, objects): if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -563,8 +479,12 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods - """Request object model serializer.""" +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer. + + :param classes: Mapping of model names to model types, used to resolve models during serialization. + :type classes: typing.Optional[typing.Mapping[str, type]] + """ basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -604,6 +524,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, @@ -614,7 +538,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -626,7 +550,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -665,7 +589,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -736,8 +660,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +705,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +729,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +759,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +779,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -875,7 +799,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -909,13 +833,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1186,13 +1117,68 @@ 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. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1204,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1237,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1270,7 +1256,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1429,7 +1415,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1441,7 +1427,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1458,6 +1444,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, @@ -1470,9 +1460,13 @@ 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 {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1482,16 +1476,37 @@ 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. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :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) @@ -1502,7 +1517,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1683,17 +1698,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore @@ -1713,7 +1732,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1795,7 +1814,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1841,7 +1860,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1867,7 +1886,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1932,7 +1955,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1945,7 +1968,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1960,7 +1983,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1978,7 +2001,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1991,7 +2014,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2002,6 +2025,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. @@ -2009,7 +2074,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2025,7 +2090,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2040,14 +2105,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2063,7 +2128,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2101,7 +2166,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_validation.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py index 0ec13ea52bbf..ed0855dea5e6 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0" diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/__init__.py index 7d2657c22057..fb290457d054 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import FabricMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import FabricMgmtClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_client.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_client.py index 065196888907..9c0f29130f9e 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_client.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_client.py @@ -7,23 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING -from typing_extensions import Self +import sys +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import FabricMgmtClientConfiguration from .operations import FabricCapacitiesOperations, Operations +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class FabricMgmtClient: +class FabricMgmtClient: # pylint: disable=docstring-keyword-should-match-keyword-only """FabricMgmtClient. :ivar fabric_capacities: FabricCapacitiesOperations operations @@ -34,10 +42,15 @@ class FabricMgmtClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -47,13 +60,26 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = FabricMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -72,7 +98,9 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) self._serialize = Serializer() self._deserialize = Deserializer() diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_configuration.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_configuration.py index f6c07cb153f5..c46995d7d4a3 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_configuration.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,10 +15,11 @@ from .._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes +class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,docstring-keyword-should-match-keyword-only """Configuration for FabricMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,8 +31,13 @@ class FabricMgmtClientConfiguration: # pylint: disable=too-many-instance-attrib :type subscription_id: str :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2023-11-01". - Note that overriding this default value may result in unsupported behavior. + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-08-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -39,9 +46,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2026-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,6 +59,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-fabric/{}".format(VERSION)) diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_patch.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_patch.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/__init__.py index 29912dd9df22..5c4a04ad0951 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import FabricCapacitiesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import FabricCapacitiesOperations # type: ignore +from ._operations import Operations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_operations.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_operations.py index 64b987343d8e..54cc2d918e14 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_operations.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_operations.py @@ -6,12 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,8 +33,10 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ... import models as _models, types as _types +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ..._validation import api_version_validation from ...operations._operations import ( build_fabric_capacities_check_name_availability_request, build_fabric_capacities_create_or_update_request, @@ -43,22 +46,20 @@ build_fabric_capacities_list_by_subscription_request, build_fabric_capacities_list_skus_for_capacity_request, build_fabric_capacities_list_skus_request, + build_fabric_capacities_list_usages_request, build_fabric_capacities_resume_request, build_fabric_capacities_suspend_request, build_fabric_capacities_update_request, build_operations_list_request, ) +from .._configuration import FabricMgmtClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list -class FabricCapacitiesOperations: +class FabricCapacitiesOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,10 +71,10 @@ class FabricCapacitiesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FabricMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) -> _models.FabricCapacity: @@ -115,6 +116,7 @@ async def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -129,11 +131,14 @@ async def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.FabricCapacity, response.json()) @@ -146,7 +151,7 @@ async def _create_or_update_initial( self, resource_group_name: str, capacity_name: str, - resource: Union[_models.FabricCapacity, JSON, IO[bytes]], + resource: Union[_models.FabricCapacity, _types.FabricCapacity, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -185,6 +190,7 @@ async def _create_or_update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -198,7 +204,10 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -208,7 +217,7 @@ async def _create_or_update_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -249,7 +258,7 @@ async def begin_create_or_update( self, resource_group_name: str, capacity_name: str, - resource: JSON, + resource: _types.FabricCapacity, *, content_type: str = "application/json", **kwargs: Any @@ -263,7 +272,7 @@ async def begin_create_or_update( characters, and a maximum of 63. Required. :type capacity_name: str :param resource: Resource create parameters. Required. - :type resource: JSON + :type resource: ~azure.mgmt.fabric.types.FabricCapacity :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -307,7 +316,7 @@ async def begin_create_or_update( self, resource_group_name: str, capacity_name: str, - resource: Union[_models.FabricCapacity, JSON, IO[bytes]], + resource: Union[_models.FabricCapacity, _types.FabricCapacity, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FabricCapacity]: """Create a FabricCapacity. @@ -318,9 +327,10 @@ async def begin_create_or_update( :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. Required. :type capacity_name: str - :param resource: Resource create parameters. Is one of the following types: FabricCapacity, - JSON, IO[bytes] Required. - :type resource: ~azure.mgmt.fabric.models.FabricCapacity or JSON or IO[bytes] + :param resource: Resource create parameters. Is either a FabricCapacity type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.fabric.models.FabricCapacity or + ~azure.mgmt.fabric.types.FabricCapacity or IO[bytes] :return: An instance of AsyncLROPoller that returns FabricCapacity. The FabricCapacity is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.fabric.models.FabricCapacity] @@ -382,7 +392,7 @@ async def _update_initial( self, resource_group_name: str, capacity_name: str, - properties: Union[_models.FabricCapacityUpdate, JSON, IO[bytes]], + properties: Union[_models.FabricCapacityUpdate, _types.FabricCapacityUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -421,6 +431,7 @@ async def _update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -434,7 +445,10 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -442,7 +456,7 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -483,7 +497,7 @@ async def begin_update( self, resource_group_name: str, capacity_name: str, - properties: JSON, + properties: _types.FabricCapacityUpdate, *, content_type: str = "application/json", **kwargs: Any @@ -497,7 +511,7 @@ async def begin_update( characters, and a maximum of 63. Required. :type capacity_name: str :param properties: The resource properties to be updated. Required. - :type properties: JSON + :type properties: ~azure.mgmt.fabric.types.FabricCapacityUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -541,7 +555,7 @@ async def begin_update( self, resource_group_name: str, capacity_name: str, - properties: Union[_models.FabricCapacityUpdate, JSON, IO[bytes]], + properties: Union[_models.FabricCapacityUpdate, _types.FabricCapacityUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FabricCapacity]: """Update a FabricCapacity. @@ -552,9 +566,10 @@ async def begin_update( :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. Required. :type capacity_name: str - :param properties: The resource properties to be updated. Is one of the following types: - FabricCapacityUpdate, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.fabric.models.FabricCapacityUpdate or JSON or IO[bytes] + :param properties: The resource properties to be updated. Is either a FabricCapacityUpdate type + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.fabric.models.FabricCapacityUpdate or + ~azure.mgmt.fabric.types.FabricCapacityUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns FabricCapacity. The FabricCapacity is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.fabric.models.FabricCapacity] @@ -641,6 +656,7 @@ async def _delete_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -654,7 +670,10 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -662,7 +681,7 @@ async def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -730,7 +749,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.FabricCapacity"]: + ) -> AsyncItemPaged["_models.FabricCapacity"]: """List FabricCapacity resources by resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -781,7 +800,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -794,7 +816,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FabricCapacity], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.FabricCapacity], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -810,7 +835,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -818,7 +846,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.FabricCapacity"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.FabricCapacity"]: """List FabricCapacity resources by subscription ID. :return: An iterator like instance of FabricCapacity @@ -865,7 +893,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -878,7 +909,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FabricCapacity], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.FabricCapacity], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -894,7 +928,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -930,6 +967,7 @@ async def _resume_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -943,7 +981,10 @@ async def _resume_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -951,7 +992,7 @@ async def _resume_initial( response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1045,6 +1086,7 @@ async def _suspend_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1058,7 +1100,10 @@ async def _suspend_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1066,7 +1111,7 @@ async def _suspend_initial( response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1157,14 +1202,19 @@ async def check_name_availability( @overload async def check_name_availability( - self, location: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + location: str, + body: _types.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Implements local CheckNameAvailability operations. :param location: The name of the Azure region. Required. :type location: str :param body: The CheckAvailability request. Required. - :type body: JSON + :type body: ~azure.mgmt.fabric.types.CheckNameAvailabilityRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1195,15 +1245,19 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + self, + location: str, + body: Union[_models.CheckNameAvailabilityRequest, _types.CheckNameAvailabilityRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Implements local CheckNameAvailability operations. :param location: The name of the Azure region. Required. :type location: str - :param body: The CheckAvailability request. Is one of the following types: - CheckNameAvailabilityRequest, JSON, IO[bytes] Required. - :type body: ~azure.mgmt.fabric.models.CheckNameAvailabilityRequest or JSON or IO[bytes] + :param body: The CheckAvailability request. Is either a CheckNameAvailabilityRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.fabric.models.CheckNameAvailabilityRequest or + ~azure.mgmt.fabric.types.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with MutableMapping :rtype: ~azure.mgmt.fabric.models.CheckNameAvailabilityResponse @@ -1244,6 +1298,7 @@ async def check_name_availability( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1258,11 +1313,14 @@ async def check_name_availability( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.CheckNameAvailabilityResponse, response.json()) @@ -1274,13 +1332,14 @@ async def check_name_availability( @distributed_trace def list_skus_for_capacity( self, resource_group_name: str, capacity_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RpSkuDetailsForExistingResource"]: + ) -> AsyncItemPaged["_models.RpSkuDetailsForExistingResource"]: """List eligible SKUs for a Microsoft Fabric resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param capacity_name: The name of the capacity. Required. + :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 + characters, and a maximum of 63. Required. :type capacity_name: str :return: An iterator like instance of RpSkuDetailsForExistingResource :rtype: @@ -1329,7 +1388,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1342,7 +1404,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RpSkuDetailsForExistingResource], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.RpSkuDetailsForExistingResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1358,7 +1423,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1366,7 +1434,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.RpSkuDetailsForNewResource"]: + def list_skus(self, **kwargs: Any) -> AsyncItemPaged["_models.RpSkuDetailsForNewResource"]: """List eligible SKUs for Microsoft Fabric resource provider. :return: An iterator like instance of RpSkuDetailsForNewResource @@ -1414,7 +1482,111 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RpSkuDetailsForNewResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2025-01-15-preview", + params_added_on={"2025-01-15-preview": ["api_version", "subscription_id", "location", "accept"]}, + api_versions_list=["2025-01-15-preview", "2026-08-01-preview"], + ) + def list_usages(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.Quota"]: + """List the current consumption and limit in this location for the provided subscription. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of Quota + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.fabric.models.Quota] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Quota]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_fabric_capacities_list_usages_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1427,7 +1599,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RpSkuDetailsForNewResource], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.Quota], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1443,7 +1618,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1451,7 +1629,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) -class Operations: +class Operations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. @@ -1463,13 +1641,13 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FabricMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """List the operations for the provider. :return: An iterator like instance of Operation @@ -1515,7 +1693,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1528,7 +1709,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1544,7 +1728,10 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_patch.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_patch.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/__init__.py index fe92b365a39f..0a0b931ce5d7 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/__init__.py @@ -5,39 +5,55 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models import CapacityAdministration -from ._models import CheckNameAvailabilityRequest -from ._models import CheckNameAvailabilityResponse -from ._models import ErrorAdditionalInfo -from ._models import ErrorDetail -from ._models import ErrorResponse -from ._models import FabricCapacity -from ._models import FabricCapacityProperties -from ._models import FabricCapacityUpdate -from ._models import FabricCapacityUpdateProperties -from ._models import Operation -from ._models import OperationDisplay -from ._models import Resource -from ._models import RpSku -from ._models import RpSkuDetailsForExistingResource -from ._models import RpSkuDetailsForNewResource -from ._models import SystemData -from ._models import TrackedResource +from typing import TYPE_CHECKING -from ._enums import ActionType -from ._enums import CheckNameAvailabilityReason -from ._enums import CreatedByType -from ._enums import Origin -from ._enums import ProvisioningState -from ._enums import ResourceState -from ._enums import RpSkuTier +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + CapacityAdministration, + CapacityOverageProperties, + CheckNameAvailabilityRequest, + CheckNameAvailabilityResponse, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + FabricCapacity, + FabricCapacityProperties, + FabricCapacityUpdate, + FabricCapacityUpdateProperties, + Operation, + OperationDisplay, + Quota, + QuotaName, + Resource, + RpSku, + RpSkuDetailsForExistingResource, + RpSkuDetailsForNewResource, + SystemData, + TrackedResource, +) + +from ._enums import ( # type: ignore + ActionType, + CapacityOverageState, + CheckNameAvailabilityReason, + CreatedByType, + Origin, + ProvisioningState, + ResourceState, + RpSkuTier, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "CapacityAdministration", + "CapacityOverageProperties", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "ErrorAdditionalInfo", @@ -49,6 +65,8 @@ "FabricCapacityUpdateProperties", "Operation", "OperationDisplay", + "Quota", + "QuotaName", "Resource", "RpSku", "RpSkuDetailsForExistingResource", @@ -56,6 +74,7 @@ "SystemData", "TrackedResource", "ActionType", + "CapacityOverageState", "CheckNameAvailabilityReason", "CreatedByType", "Origin", diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_enums.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_enums.py index ff5129ff59c4..f1711ccc3b1c 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_enums.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_enums.py @@ -19,6 +19,15 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Actions are for internal-only APIs.""" +class CapacityOverageState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capacity overage state for the Fabric capacity resource.""" + + DISABLED = "Disabled" + """Capacity overage is disabled.""" + ENABLED = "Enabled" + """Capacity overage is enabled.""" + + class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Possible reasons for a name not being available.""" @@ -64,44 +73,44 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" """Resource creation was canceled.""" DELETING = "Deleting" - """Resource is deleting""" + """Resource is deleting.""" PROVISIONING = "Provisioning" - """Resource is provisioning""" + """Resource is provisioning.""" UPDATING = "Updating" - """Resource is updating""" + """Resource is updating.""" class ResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the Fabric capacity resource.""" ACTIVE = "Active" - """Resource is active""" + """Resource is active.""" PROVISIONING = "Provisioning" - """Resource is provisioning""" + """Resource is provisioning.""" FAILED = "Failed" - """Resource is failed""" + """Resource is failed.""" UPDATING = "Updating" - """Resource is updating""" + """Resource is updating.""" DELETING = "Deleting" - """Resource is deleting""" + """Resource is deleting.""" SUSPENDING = "Suspending" - """Resource is suspending""" + """Resource is suspending.""" SUSPENDED = "Suspended" - """Resource is suspended""" + """Resource is suspended.""" PAUSING = "Pausing" - """Resource is pausing""" + """Resource is pausing.""" PAUSED = "Paused" - """Resource is paused""" + """Resource is paused.""" RESUMING = "Resuming" - """Resource is resuming""" + """Resource is resuming.""" SCALING = "Scaling" - """Resource is scaling""" + """Resource is scaling.""" PREPARING = "Preparing" - """Resource is preparing""" + """Resource is preparing.""" class RpSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the Azure pricing tier to which the SKU applies.""" FABRIC = "Fabric" - """Fabric tier""" + """Fabric tier.""" diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_models.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_models.py index 6f88e0bbf6c7..d1443a640426 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_models.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,33 +6,73 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation import datetime -from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload -from .. import _model_base -from .._model_base import rest_field +from .._utils.model_base import Model as _Model, rest_field if TYPE_CHECKING: from .. import models as _models -class CapacityAdministration(_model_base.Model): +class CapacityAdministration(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The administration properties of the Fabric capacity resource. - :ivar members: An array of administrator user identities. Required. :vartype members: list[str] """ - members: List[str] = rest_field() + members: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """An array of administrator user identities. Required.""" @overload def __init__( self, *, - members: List[str], + members: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapacityOverageProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The capacity overage properties of the Fabric capacity resource. + + :ivar state: The capacity overage state for the Fabric capacity resource. Known values are: + "Disabled" and "Enabled". + :vartype state: str or ~azure.mgmt.fabric.models.CapacityOverageState + :ivar threshold_capacity_unit_hours: 24-hour rolling threshold for capacity overage. Reaching + this threshold results in capacity throttling. + :vartype threshold_capacity_unit_hours: int + """ + + state: Optional[Union[str, "_models.CapacityOverageState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The capacity overage state for the Fabric capacity resource. Known values are: \"Disabled\" and + \"Enabled\".""" + threshold_capacity_unit_hours: Optional[int] = rest_field( + name="thresholdCapacityUnitHours", visibility=["read", "create", "update", "delete", "query"] + ) + """24-hour rolling threshold for capacity overage. Reaching this threshold results in capacity + throttling.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.CapacityOverageState"]] = None, + threshold_capacity_unit_hours: Optional[int] = None, ) -> None: ... @overload @@ -41,11 +82,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CheckNameAvailabilityRequest(_model_base.Model): +class CheckNameAvailabilityRequest(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The check availability request body. :ivar name: The name of the resource for which availability needs to be checked. @@ -54,9 +95,9 @@ class CheckNameAvailabilityRequest(_model_base.Model): :vartype type: str """ - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the resource for which availability needs to be checked.""" - type: Optional[str] = rest_field() + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The resource type.""" @overload @@ -74,11 +115,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CheckNameAvailabilityResponse(_model_base.Model): +class CheckNameAvailabilityResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The check availability result. :ivar name_available: Indicates if the resource name is available. @@ -90,12 +131,16 @@ class CheckNameAvailabilityResponse(_model_base.Model): :vartype message: str """ - name_available: Optional[bool] = rest_field(name="nameAvailable") + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) """Indicates if the resource name is available.""" - reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field() + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The reason why the given name is not available. Known values are: \"Invalid\" and \"AlreadyExists\".""" - message: Optional[str] = rest_field() + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Detailed reason why the given name is not available.""" @overload @@ -114,15 +159,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ErrorAdditionalInfo(_model_base.Model): +class ErrorAdditionalInfo(_Model): """The resource management error additional info. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. @@ -135,11 +178,9 @@ class ErrorAdditionalInfo(_model_base.Model): """The additional info.""" -class ErrorDetail(_model_base.Model): +class ErrorDetail(_Model): """The error detail. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar code: The error code. :vartype code: str :ivar message: The error message. @@ -158,23 +199,22 @@ class ErrorDetail(_model_base.Model): """The error message.""" target: Optional[str] = rest_field(visibility=["read"]) """The error target.""" - details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) """The error details.""" - additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] ) """The error additional info.""" -class ErrorResponse(_model_base.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. +class ErrorResponse(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Error response. :ivar error: The error object. :vartype error: ~azure.mgmt.fabric.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -191,17 +231,15 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Resource(_model_base.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Readonly variables are only populated by the server, and will be ignored when sending a request. +class Resource(_Model): + """Resource. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -215,7 +253,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -225,15 +263,11 @@ class Resource(_model_base.Model): """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Readonly variables are only populated by the server, and will be ignored when sending a request. - +class TrackedResource(Resource): # pylint: disable=docstring-keyword-should-match-keyword-only + """Tracked Resource. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -249,7 +283,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -259,7 +293,7 @@ def __init__( self, *, location: str, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, ) -> None: ... @overload @@ -269,18 +303,15 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FabricCapacity(TrackedResource): +class FabricCapacity(TrackedResource): # pylint: disable=docstring-keyword-should-match-keyword-only """Fabric Capacity resource. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -300,9 +331,11 @@ class FabricCapacity(TrackedResource): :vartype sku: ~azure.mgmt.fabric.models.RpSku """ - properties: "_models.FabricCapacityProperties" = rest_field() + properties: "_models.FabricCapacityProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource. Required.""" - sku: "_models.RpSku" = rest_field() + sku: "_models.RpSku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The SKU details. Required.""" @overload @@ -312,7 +345,7 @@ def __init__( location: str, properties: "_models.FabricCapacityProperties", sku: "_models.RpSku", - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, ) -> None: ... @overload @@ -322,16 +355,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FabricCapacityProperties(_model_base.Model): +class FabricCapacityProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The Microsoft Fabric capacity properties. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The current deployment state of Microsoft Fabric resource. The provisioningState is to indicate states for resource provisioning. Known values are: "Succeeded", "Failed", "Canceled", "Deleting", "Provisioning", and "Updating". @@ -341,6 +371,8 @@ class FabricCapacityProperties(_model_base.Model): "Updating", "Deleting", "Suspending", "Suspended", "Pausing", "Paused", "Resuming", "Scaling", and "Preparing". :vartype state: str or ~azure.mgmt.fabric.models.ResourceState + :ivar overage: The capacity overage properties of the Fabric capacity resource. + :vartype overage: ~azure.mgmt.fabric.models.CapacityOverageProperties :ivar administration: The capacity administration. Required. :vartype administration: ~azure.mgmt.fabric.models.CapacityAdministration """ @@ -356,7 +388,13 @@ class FabricCapacityProperties(_model_base.Model): resource provisioning. Known values are: \"Active\", \"Provisioning\", \"Failed\", \"Updating\", \"Deleting\", \"Suspending\", \"Suspended\", \"Pausing\", \"Paused\", \"Resuming\", \"Scaling\", and \"Preparing\".""" - administration: "_models.CapacityAdministration" = rest_field() + overage: Optional["_models.CapacityOverageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The capacity overage properties of the Fabric capacity resource.""" + administration: "_models.CapacityAdministration" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The capacity administration. Required.""" @overload @@ -364,6 +402,7 @@ def __init__( self, *, administration: "_models.CapacityAdministration", + overage: Optional["_models.CapacityOverageProperties"] = None, ) -> None: ... @overload @@ -373,11 +412,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FabricCapacityUpdate(_model_base.Model): +class FabricCapacityUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The type used for update operations of the FabricCapacity. :ivar sku: The SKU details. @@ -388,11 +427,13 @@ class FabricCapacityUpdate(_model_base.Model): :vartype properties: ~azure.mgmt.fabric.models.FabricCapacityUpdateProperties """ - sku: Optional["_models.RpSku"] = rest_field() + sku: Optional["_models.RpSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The SKU details.""" - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" - properties: Optional["_models.FabricCapacityUpdateProperties"] = rest_field() + properties: Optional["_models.FabricCapacityUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -400,7 +441,7 @@ def __init__( self, *, sku: Optional["_models.RpSku"] = None, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, properties: Optional["_models.FabricCapacityUpdateProperties"] = None, ) -> None: ... @@ -411,24 +452,33 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FabricCapacityUpdateProperties(_model_base.Model): +class FabricCapacityUpdateProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The updatable properties of the FabricCapacity. + :ivar overage: The capacity overage properties of the Fabric capacity resource. + :vartype overage: ~azure.mgmt.fabric.models.CapacityOverageProperties :ivar administration: The capacity administration. :vartype administration: ~azure.mgmt.fabric.models.CapacityAdministration """ - administration: Optional["_models.CapacityAdministration"] = rest_field() + overage: Optional["_models.CapacityOverageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The capacity overage properties of the Fabric capacity resource.""" + administration: Optional["_models.CapacityAdministration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The capacity administration.""" @overload def __init__( self, *, + overage: Optional["_models.CapacityOverageProperties"] = None, administration: Optional["_models.CapacityAdministration"] = None, ) -> None: ... @@ -439,14 +489,12 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Operation(_model_base.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Readonly variables are only populated by the server, and will be ignored when sending a request. +class Operation(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """REST API Operation. :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". @@ -472,13 +520,15 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and \"user,system\".""" - action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType") + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs. \"Internal\"""" @@ -486,7 +536,7 @@ class Operation(_model_base.Model): def __init__( self, *, - action_type: Optional[Union[str, "_models.ActionType"]] = None, + display: Optional["_models.OperationDisplay"] = None, ) -> None: ... @overload @@ -496,14 +546,12 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OperationDisplay(_model_base.Model): - """Localized display information for and operation. - - Readonly variables are only populated by the server, and will be ignored when sending a request. +class OperationDisplay(_Model): + """Localized display information for an operation. :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". @@ -533,9 +581,85 @@ class OperationDisplay(_model_base.Model): views.""" -class RpSku(_model_base.Model): - """Represents the SKU name and Azure pricing tier for Microsoft Fabric capacity resource. +class Quota(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Describes Resource Quota. + :ivar name: The name of the quota. + :vartype name: ~azure.mgmt.fabric.models.QuotaName + :ivar unit: The unit of usage measurement. Required. + :vartype unit: str + :ivar current_value: The current usage of the resource. Required. + :vartype current_value: int + :ivar limit: The maximum permitted usage of the resource. Required. + :vartype limit: int + """ + + name: Optional["_models.QuotaName"] = rest_field(visibility=["read"]) + """The name of the quota.""" + unit: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unit of usage measurement. Required.""" + current_value: int = rest_field(name="currentValue", visibility=["read", "create", "update", "delete", "query"]) + """The current usage of the resource. Required.""" + limit: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum permitted usage of the resource. Required.""" + + @overload + def __init__( + self, + *, + unit: str, + current_value: int, + limit: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaName(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The Quota Names. + + :ivar value: The name of the resource. + :vartype value: str + :ivar localized_value: The localized name of the resource. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the resource.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """The localized name of the resource.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RpSku(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Represents the SKU name and Azure pricing tier for Microsoft Fabric capacity resource. :ivar name: The name of the SKU level. Required. :vartype name: str @@ -543,9 +667,9 @@ class RpSku(_model_base.Model): :vartype tier: str or ~azure.mgmt.fabric.models.RpSkuTier """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the SKU level. Required.""" - tier: Union[str, "_models.RpSkuTier"] = rest_field() + tier: Union[str, "_models.RpSkuTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the Azure pricing tier to which the SKU applies. Required. \"Fabric\"""" @overload @@ -563,23 +687,22 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class RpSkuDetailsForExistingResource(_model_base.Model): +class RpSkuDetailsForExistingResource(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """An object that represents SKU details for existing resources. - :ivar resource_type: The resource type. Required. :vartype resource_type: str :ivar sku: The SKU details. Required. :vartype sku: ~azure.mgmt.fabric.models.RpSku """ - resource_type: str = rest_field(name="resourceType") + resource_type: str = rest_field(name="resourceType", visibility=["read", "create", "update", "delete", "query"]) """The resource type. Required.""" - sku: "_models.RpSku" = rest_field() + sku: "_models.RpSku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The SKU details. Required.""" @overload @@ -597,14 +720,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class RpSkuDetailsForNewResource(_model_base.Model): +class RpSkuDetailsForNewResource(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The SKU details. - :ivar resource_type: The resource type. Required. :vartype resource_type: str :ivar name: The SKU's name. Required. @@ -613,11 +735,11 @@ class RpSkuDetailsForNewResource(_model_base.Model): :vartype locations: list[str] """ - resource_type: str = rest_field(name="resourceType") + resource_type: str = rest_field(name="resourceType", visibility=["read", "create", "update", "delete", "query"]) """The resource type. Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The SKU's name. Required.""" - locations: List[str] = rest_field() + locations: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The list of available locations for the SKU. Required.""" @overload @@ -626,7 +748,7 @@ def __init__( *, resource_type: str, name: str, - locations: List[str], + locations: list[str], ) -> None: ... @overload @@ -636,11 +758,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SystemData(_model_base.Model): +class SystemData(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. @@ -659,19 +781,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -693,5 +825,5 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_patch.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_patch.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/__init__.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/__init__.py index 29912dd9df22..5c4a04ad0951 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/__init__.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import FabricCapacitiesOperations -from ._operations import Operations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import FabricCapacitiesOperations # type: ignore +from ._operations import Operations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_operations.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_operations.py index 01fb0e2a5e92..a8b5e0a9aadf 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_operations.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,12 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -31,17 +32,15 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .. import models as _models, types as _types +from .._configuration import FabricMgmtClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._validation import api_version_validation -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -53,11 +52,11 @@ def build_fabric_capacities_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -82,11 +81,11 @@ def build_fabric_capacities_create_or_update_request( # pylint: disable=name-to _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -113,11 +112,11 @@ def build_fabric_capacities_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -140,14 +139,11 @@ def build_fabric_capacities_update_request( def build_fabric_capacities_delete_request( resource_group_name: str, capacity_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -159,10 +155,7 @@ def build_fabric_capacities_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_fabric_capacities_list_by_resource_group_request( # pylint: disable=name-too-long @@ -171,7 +164,7 @@ def build_fabric_capacities_list_by_resource_group_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,7 +191,7 @@ def build_fabric_capacities_list_by_subscription_request( # pylint: disable=nam _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -221,14 +214,11 @@ def build_fabric_capacities_list_by_subscription_request( # pylint: disable=nam def build_fabric_capacities_resume_request( resource_group_name: str, capacity_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/resume" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/resume" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -240,23 +230,17 @@ def build_fabric_capacities_resume_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_fabric_capacities_suspend_request( resource_group_name: str, capacity_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/suspend" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/suspend" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -268,10 +252,7 @@ def build_fabric_capacities_suspend_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_fabric_capacities_check_name_availability_request( # pylint: disable=name-too-long @@ -281,7 +262,7 @@ def build_fabric_capacities_check_name_availability_request( # pylint: disable= _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -310,11 +291,11 @@ def build_fabric_capacities_list_skus_for_capacity_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/skus" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/skus" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -338,7 +319,7 @@ def build_fabric_capacities_list_skus_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -358,11 +339,38 @@ def build_fabric_capacities_list_skus_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_fabric_capacities_list_usages_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Fabric/locations/{location}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -377,7 +385,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class FabricCapacitiesOperations: +class FabricCapacitiesOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. @@ -387,12 +395,12 @@ class FabricCapacitiesOperations: :attr:`fabric_capacities` attribute. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FabricMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) -> _models.FabricCapacity: @@ -434,6 +442,7 @@ def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) -> _m } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -448,11 +457,14 @@ def get(self, resource_group_name: str, capacity_name: str, **kwargs: Any) -> _m except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.FabricCapacity, response.json()) @@ -465,7 +477,7 @@ def _create_or_update_initial( self, resource_group_name: str, capacity_name: str, - resource: Union[_models.FabricCapacity, JSON, IO[bytes]], + resource: Union[_models.FabricCapacity, _types.FabricCapacity, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -504,6 +516,7 @@ def _create_or_update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -517,7 +530,10 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -527,7 +543,7 @@ def _create_or_update_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -568,7 +584,7 @@ def begin_create_or_update( self, resource_group_name: str, capacity_name: str, - resource: JSON, + resource: _types.FabricCapacity, *, content_type: str = "application/json", **kwargs: Any @@ -582,7 +598,7 @@ def begin_create_or_update( characters, and a maximum of 63. Required. :type capacity_name: str :param resource: Resource create parameters. Required. - :type resource: JSON + :type resource: ~azure.mgmt.fabric.types.FabricCapacity :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -626,7 +642,7 @@ def begin_create_or_update( self, resource_group_name: str, capacity_name: str, - resource: Union[_models.FabricCapacity, JSON, IO[bytes]], + resource: Union[_models.FabricCapacity, _types.FabricCapacity, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FabricCapacity]: """Create a FabricCapacity. @@ -637,9 +653,10 @@ def begin_create_or_update( :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. Required. :type capacity_name: str - :param resource: Resource create parameters. Is one of the following types: FabricCapacity, - JSON, IO[bytes] Required. - :type resource: ~azure.mgmt.fabric.models.FabricCapacity or JSON or IO[bytes] + :param resource: Resource create parameters. Is either a FabricCapacity type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.fabric.models.FabricCapacity or + ~azure.mgmt.fabric.types.FabricCapacity or IO[bytes] :return: An instance of LROPoller that returns FabricCapacity. The FabricCapacity is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.fabric.models.FabricCapacity] @@ -701,7 +718,7 @@ def _update_initial( self, resource_group_name: str, capacity_name: str, - properties: Union[_models.FabricCapacityUpdate, JSON, IO[bytes]], + properties: Union[_models.FabricCapacityUpdate, _types.FabricCapacityUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -740,6 +757,7 @@ def _update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -753,7 +771,10 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -761,7 +782,7 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -802,7 +823,7 @@ def begin_update( self, resource_group_name: str, capacity_name: str, - properties: JSON, + properties: _types.FabricCapacityUpdate, *, content_type: str = "application/json", **kwargs: Any @@ -816,7 +837,7 @@ def begin_update( characters, and a maximum of 63. Required. :type capacity_name: str :param properties: The resource properties to be updated. Required. - :type properties: JSON + :type properties: ~azure.mgmt.fabric.types.FabricCapacityUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -860,7 +881,7 @@ def begin_update( self, resource_group_name: str, capacity_name: str, - properties: Union[_models.FabricCapacityUpdate, JSON, IO[bytes]], + properties: Union[_models.FabricCapacityUpdate, _types.FabricCapacityUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FabricCapacity]: """Update a FabricCapacity. @@ -871,9 +892,10 @@ def begin_update( :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. Required. :type capacity_name: str - :param properties: The resource properties to be updated. Is one of the following types: - FabricCapacityUpdate, JSON, IO[bytes] Required. - :type properties: ~azure.mgmt.fabric.models.FabricCapacityUpdate or JSON or IO[bytes] + :param properties: The resource properties to be updated. Is either a FabricCapacityUpdate type + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.fabric.models.FabricCapacityUpdate or + ~azure.mgmt.fabric.types.FabricCapacityUpdate or IO[bytes] :return: An instance of LROPoller that returns FabricCapacity. The FabricCapacity is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.fabric.models.FabricCapacity] @@ -958,6 +980,7 @@ def _delete_initial(self, resource_group_name: str, capacity_name: str, **kwargs } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -971,7 +994,10 @@ def _delete_initial(self, resource_group_name: str, capacity_name: str, **kwargs except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -979,7 +1005,7 @@ def _delete_initial(self, resource_group_name: str, capacity_name: str, **kwargs response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1045,7 +1071,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.FabricCapacity"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.FabricCapacity"]: """List FabricCapacity resources by resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1096,7 +1122,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1109,7 +1138,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FabricCapacity], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.FabricCapacity], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1125,7 +1157,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1133,7 +1168,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.FabricCapacity"]: + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.FabricCapacity"]: """List FabricCapacity resources by subscription ID. :return: An iterator like instance of FabricCapacity @@ -1180,7 +1215,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1193,7 +1231,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FabricCapacity], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.FabricCapacity], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1209,7 +1250,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1243,6 +1287,7 @@ def _resume_initial(self, resource_group_name: str, capacity_name: str, **kwargs } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1256,7 +1301,10 @@ def _resume_initial(self, resource_group_name: str, capacity_name: str, **kwargs except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1264,7 +1312,7 @@ def _resume_initial(self, resource_group_name: str, capacity_name: str, **kwargs response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1356,6 +1404,7 @@ def _suspend_initial(self, resource_group_name: str, capacity_name: str, **kwarg } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1369,7 +1418,10 @@ def _suspend_initial(self, resource_group_name: str, capacity_name: str, **kwarg except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1377,7 +1429,7 @@ def _suspend_initial(self, resource_group_name: str, capacity_name: str, **kwarg response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1468,14 +1520,19 @@ def check_name_availability( @overload def check_name_availability( - self, location: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + location: str, + body: _types.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Implements local CheckNameAvailability operations. :param location: The name of the Azure region. Required. :type location: str :param body: The CheckAvailability request. Required. - :type body: JSON + :type body: ~azure.mgmt.fabric.types.CheckNameAvailabilityRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1506,15 +1563,19 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + self, + location: str, + body: Union[_models.CheckNameAvailabilityRequest, _types.CheckNameAvailabilityRequest, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Implements local CheckNameAvailability operations. :param location: The name of the Azure region. Required. :type location: str - :param body: The CheckAvailability request. Is one of the following types: - CheckNameAvailabilityRequest, JSON, IO[bytes] Required. - :type body: ~azure.mgmt.fabric.models.CheckNameAvailabilityRequest or JSON or IO[bytes] + :param body: The CheckAvailability request. Is either a CheckNameAvailabilityRequest type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.fabric.models.CheckNameAvailabilityRequest or + ~azure.mgmt.fabric.types.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with MutableMapping :rtype: ~azure.mgmt.fabric.models.CheckNameAvailabilityResponse @@ -1555,6 +1616,7 @@ def check_name_availability( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -1569,11 +1631,14 @@ def check_name_availability( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.CheckNameAvailabilityResponse, response.json()) @@ -1585,13 +1650,14 @@ def check_name_availability( @distributed_trace def list_skus_for_capacity( self, resource_group_name: str, capacity_name: str, **kwargs: Any - ) -> Iterable["_models.RpSkuDetailsForExistingResource"]: + ) -> ItemPaged["_models.RpSkuDetailsForExistingResource"]: """List eligible SKUs for a Microsoft Fabric resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param capacity_name: The name of the capacity. Required. + :param capacity_name: The name of the Microsoft Fabric capacity. It must be a minimum of 3 + characters, and a maximum of 63. Required. :type capacity_name: str :return: An iterator like instance of RpSkuDetailsForExistingResource :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.fabric.models.RpSkuDetailsForExistingResource] @@ -1639,7 +1705,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1652,7 +1721,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RpSkuDetailsForExistingResource], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.RpSkuDetailsForExistingResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1668,7 +1740,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1676,7 +1751,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_skus(self, **kwargs: Any) -> Iterable["_models.RpSkuDetailsForNewResource"]: + def list_skus(self, **kwargs: Any) -> ItemPaged["_models.RpSkuDetailsForNewResource"]: """List eligible SKUs for Microsoft Fabric resource provider. :return: An iterator like instance of RpSkuDetailsForNewResource @@ -1723,7 +1798,111 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RpSkuDetailsForNewResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2025-01-15-preview", + params_added_on={"2025-01-15-preview": ["api_version", "subscription_id", "location", "accept"]}, + api_versions_list=["2025-01-15-preview", "2026-08-01-preview"], + ) + def list_usages(self, location: str, **kwargs: Any) -> ItemPaged["_models.Quota"]: + """List the current consumption and limit in this location for the provided subscription. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of Quota + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.fabric.models.Quota] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Quota]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_fabric_capacities_list_usages_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1736,7 +1915,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RpSkuDetailsForNewResource], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.Quota], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1752,7 +1934,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1760,7 +1945,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class Operations: +class Operations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. @@ -1770,15 +1955,15 @@ class Operations: :attr:`operations` attribute. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FabricMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: """List the operations for the provider. :return: An iterator like instance of Operation @@ -1824,7 +2009,10 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1837,7 +2025,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1853,7 +2044,10 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_patch.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_patch.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/types.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/types.py new file mode 100644 index 000000000000..e2ce5c7946c3 --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/types.py @@ -0,0 +1,260 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 import TYPE_CHECKING, Union +from typing_extensions import Required, TypedDict + +if TYPE_CHECKING: + from .models import CapacityOverageState, CreatedByType, ProvisioningState, ResourceState, RpSkuTier + + +class CapacityAdministration(TypedDict, total=False): + """The administration properties of the Fabric capacity resource. + + :ivar members: An array of administrator user identities. Required. + :vartype members: list[str] + """ + + members: Required[list[str]] + """An array of administrator user identities. Required.""" + + +class CapacityOverageProperties(TypedDict, total=False): + """The capacity overage properties of the Fabric capacity resource. + + :ivar state: The capacity overage state for the Fabric capacity resource. Known values are: + "Disabled" and "Enabled". + :vartype state: Union[str, "CapacityOverageState"] + :ivar thresholdCapacityUnitHours: 24-hour rolling threshold for capacity overage. Reaching this + threshold results in capacity throttling. + :vartype thresholdCapacityUnitHours: int + """ + + state: Union[str, "CapacityOverageState"] + """The capacity overage state for the Fabric capacity resource. Known values are: \"Disabled\" and + \"Enabled\".""" + thresholdCapacityUnitHours: int + """24-hour rolling threshold for capacity overage. Reaching this threshold results in capacity + throttling.""" + + +class CheckNameAvailabilityRequest(TypedDict, total=False): + """The check availability request body. + + :ivar name: The name of the resource for which availability needs to be checked. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + """ + + name: str + """The name of the resource for which availability needs to be checked.""" + type: str + """The resource type.""" + + +class Resource(TypedDict, total=False): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype systemData: "SystemData" + """ + + id: str + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: str + """The name of the resource.""" + type: str + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + systemData: "SystemData" + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype systemData: "SystemData" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: dict[str, str] + """Resource tags.""" + location: Required[str] + """The geo-location where the resource lives. Required.""" + + +class FabricCapacity(TrackedResource): + """Fabric Capacity resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype systemData: "SystemData" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The resource-specific properties for this resource. Required. + :vartype properties: "FabricCapacityProperties" + :ivar sku: The SKU details. Required. + :vartype sku: "RpSku" + """ + + properties: Required["FabricCapacityProperties"] + """The resource-specific properties for this resource. Required.""" + sku: Required["RpSku"] + """The SKU details. Required.""" + + +class FabricCapacityProperties(TypedDict, total=False): + """The Microsoft Fabric capacity properties. + + :ivar provisioningState: The current deployment state of Microsoft Fabric resource. The + provisioningState is to indicate states for resource provisioning. Known values are: + "Succeeded", "Failed", "Canceled", "Deleting", "Provisioning", and "Updating". + :vartype provisioningState: Union[str, "ProvisioningState"] + :ivar state: The current state of Microsoft Fabric resource. The state is to indicate more + states outside of resource provisioning. Known values are: "Active", "Provisioning", "Failed", + "Updating", "Deleting", "Suspending", "Suspended", "Pausing", "Paused", "Resuming", "Scaling", + and "Preparing". + :vartype state: Union[str, "ResourceState"] + :ivar overage: The capacity overage properties of the Fabric capacity resource. + :vartype overage: "CapacityOverageProperties" + :ivar administration: The capacity administration. Required. + :vartype administration: "CapacityAdministration" + """ + + provisioningState: Union[str, "ProvisioningState"] + """The current deployment state of Microsoft Fabric resource. The provisioningState is to indicate + states for resource provisioning. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", + \"Deleting\", \"Provisioning\", and \"Updating\".""" + state: Union[str, "ResourceState"] + """The current state of Microsoft Fabric resource. The state is to indicate more states outside of + resource provisioning. Known values are: \"Active\", \"Provisioning\", \"Failed\", + \"Updating\", \"Deleting\", \"Suspending\", \"Suspended\", \"Pausing\", \"Paused\", + \"Resuming\", \"Scaling\", and \"Preparing\".""" + overage: "CapacityOverageProperties" + """The capacity overage properties of the Fabric capacity resource.""" + administration: Required["CapacityAdministration"] + """The capacity administration. Required.""" + + +class FabricCapacityUpdate(TypedDict, total=False): + """The type used for update operations of the FabricCapacity. + + :ivar sku: The SKU details. + :vartype sku: "RpSku" + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: The resource-specific properties for this resource. + :vartype properties: "FabricCapacityUpdateProperties" + """ + + sku: "RpSku" + """The SKU details.""" + tags: dict[str, str] + """Resource tags.""" + properties: "FabricCapacityUpdateProperties" + """The resource-specific properties for this resource.""" + + +class FabricCapacityUpdateProperties(TypedDict, total=False): + """The updatable properties of the FabricCapacity. + + :ivar overage: The capacity overage properties of the Fabric capacity resource. + :vartype overage: "CapacityOverageProperties" + :ivar administration: The capacity administration. + :vartype administration: "CapacityAdministration" + """ + + overage: "CapacityOverageProperties" + """The capacity overage properties of the Fabric capacity resource.""" + administration: "CapacityAdministration" + """The capacity administration.""" + + +class RpSku(TypedDict, total=False): + """Represents the SKU name and Azure pricing tier for Microsoft Fabric capacity resource. + + :ivar name: The name of the SKU level. Required. + :vartype name: str + :ivar tier: The name of the Azure pricing tier to which the SKU applies. Required. "Fabric" + :vartype tier: Union[str, "RpSkuTier"] + """ + + name: Required[str] + """The name of the SKU level. Required.""" + tier: Required[Union[str, "RpSkuTier"]] + """The name of the Azure pricing tier to which the SKU applies. Required. \"Fabric\"""" + + +class SystemData(TypedDict, total=False): + """Metadata pertaining to creation and last modification of the resource. + + :ivar createdBy: The identity that created the resource. + :vartype createdBy: str + :ivar createdByType: The type of identity that created the resource. Known values are: "User", + "Application", "ManagedIdentity", and "Key". + :vartype createdByType: Union[str, "CreatedByType"] + :ivar createdAt: The timestamp of resource creation (UTC). + :vartype createdAt: str + :ivar lastModifiedBy: The identity that last modified the resource. + :vartype lastModifiedBy: str + :ivar lastModifiedByType: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype lastModifiedByType: Union[str, "CreatedByType"] + :ivar lastModifiedAt: The timestamp of resource last modification (UTC). + :vartype lastModifiedAt: str + """ + + createdBy: str + """The identity that created the resource.""" + createdByType: Union[str, "CreatedByType"] + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + createdAt: str + """The timestamp of resource creation (UTC).""" + lastModifiedBy: str + """The identity that last modified the resource.""" + lastModifiedByType: Union[str, "CreatedByType"] + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + lastModifiedAt: str + """The timestamp of resource last modification (UTC).""" diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_check_name_availability.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_check_name_availability.py index 6a1e46d7e158..4d03f6f722cf 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_check_name_availability.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_check_name_availability.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2023-11-01/FabricCapacities_CheckNameAvailability.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_create_or_update.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_create_or_update.py index cdafea096322..64390bed35e8 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_create_or_update.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_create_or_update.py @@ -35,13 +35,16 @@ def main(): capacity_name="azsdktest", resource={ "location": "westcentralus", - "properties": {"administration": {"members": ["azsdktest@microsoft.com", "azsdktest2@microsoft.com"]}}, + "properties": { + "administration": {"members": ["azsdktest@microsoft.com", "azsdktest2@microsoft.com"]}, + "overage": {"state": "Enabled", "thresholdCapacityUnitHours": 4}, + }, "sku": {"name": "F2", "tier": "Fabric"}, }, ).result() print(response) -# x-ms-original-file: 2023-11-01/FabricCapacities_CreateOrUpdate.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_delete.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_delete.py index 91977e9351bf..fcf0bf4c52ce 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_delete.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2023-11-01/FabricCapacities_Delete.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_Delete.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_get.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_get.py index 7fd92386ae66..42f60d978b09 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_get.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2023-11-01/FabricCapacities_Get.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_Get.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_resource_group.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_resource_group.py index 0e3c743cc7b8..551568cd7787 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_resource_group.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2023-11-01/FabricCapacities_ListByResourceGroup.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_subscription.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_subscription.py index 58d7b7eb071d..03dec3d9683d 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_subscription.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_by_subscription.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2023-11-01/FabricCapacities_ListBySubscription.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus.py index 84586fe550b2..fc50c1d332a0 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2023-11-01/FabricCapacities_ListSkus.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_ListSkus.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus_for_capacity.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus_for_capacity.py index 60d85b58fbd7..c4eff5a8e759 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus_for_capacity.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_skus_for_capacity.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2023-11-01/FabricCapacities_ListSkusForCapacity.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_ListSkusForCapacity.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_usages_by_subscription.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_usages_by_subscription.py new file mode 100644 index 000000000000..db3dfe89dbae --- /dev/null +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_list_usages_by_subscription.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.fabric import FabricMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-fabric +# USAGE + python fabric_capacities_list_usages_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = FabricMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.fabric_capacities.list_usages( + location="centraluseuap", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_ListUsagesBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_resume.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_resume.py index a9d11899de2a..bbaa39149e21 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_resume.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_resume.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2023-11-01/FabricCapacities_Resume.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_Resume.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_suspend.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_suspend.py index 9c444d40fac0..792fca8be0bd 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_suspend.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_suspend.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2023-11-01/FabricCapacities_Suspend.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_Suspend.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_update.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_update.py index 408f8c6cb43c..f67a6ac86c7d 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_update.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/fabric_capacities_update.py @@ -34,7 +34,10 @@ def main(): resource_group_name="TestRG", capacity_name="azsdktest", properties={ - "properties": {"administration": {"members": ["azsdktest2@microsoft.com"]}}, + "properties": { + "administration": {"members": ["azsdktest2@microsoft.com"]}, + "overage": {"state": "Enabled", "thresholdCapacityUnitHours": 4}, + }, "sku": {"name": "F8", "tier": "Fabric"}, "tags": {"testKey": "testValue"}, }, @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: 2023-11-01/FabricCapacities_Update.json +# x-ms-original-file: 2026-08-01-preview/FabricCapacities_Update.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_samples/operations_list.py b/sdk/fabric/azure-mgmt-fabric/generated_samples/operations_list.py index 665744cf3829..c3c028d73834 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_samples/operations_list.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2023-11-01/Operations_List.json +# x-ms-original-file: 2026-08-01-preview/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations.py b/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations.py index 422835a941e6..7f90a8928319 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations.py @@ -37,7 +37,12 @@ def test_fabric_capacities_begin_create_or_update(self, resource_group): capacity_name="str", resource={ "location": "str", - "properties": {"administration": {"members": ["str"]}, "provisioningState": "str", "state": "str"}, + "properties": { + "administration": {"members": ["str"]}, + "overage": {"state": "str", "thresholdCapacityUnitHours": 0}, + "provisioningState": "str", + "state": "str", + }, "sku": {"name": "str", "tier": "str"}, "id": "str", "name": "str", @@ -64,7 +69,10 @@ def test_fabric_capacities_begin_update(self, resource_group): resource_group_name=resource_group.name, capacity_name="str", properties={ - "properties": {"administration": {"members": ["str"]}}, + "properties": { + "administration": {"members": ["str"]}, + "overage": {"state": "str", "thresholdCapacityUnitHours": 0}, + }, "sku": {"name": "str", "tier": "str"}, "tags": {"str": "str"}, }, @@ -153,3 +161,13 @@ def test_fabric_capacities_list_skus(self, resource_group): result = [r for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_capacities_list_usages(self, resource_group): + response = self.client.fabric_capacities.list_usages( + location="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations_async.py b/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations_async.py index 2414c137dba4..84576c88f567 100644 --- a/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations_async.py +++ b/sdk/fabric/azure-mgmt-fabric/generated_tests/test_fabric_mgmt_fabric_capacities_operations_async.py @@ -39,7 +39,12 @@ async def test_fabric_capacities_begin_create_or_update(self, resource_group): capacity_name="str", resource={ "location": "str", - "properties": {"administration": {"members": ["str"]}, "provisioningState": "str", "state": "str"}, + "properties": { + "administration": {"members": ["str"]}, + "overage": {"state": "str", "thresholdCapacityUnitHours": 0}, + "provisioningState": "str", + "state": "str", + }, "sku": {"name": "str", "tier": "str"}, "id": "str", "name": "str", @@ -68,7 +73,10 @@ async def test_fabric_capacities_begin_update(self, resource_group): resource_group_name=resource_group.name, capacity_name="str", properties={ - "properties": {"administration": {"members": ["str"]}}, + "properties": { + "administration": {"members": ["str"]}, + "overage": {"state": "str", "thresholdCapacityUnitHours": 0}, + }, "sku": {"name": "str", "tier": "str"}, "tags": {"str": "str"}, }, @@ -164,3 +172,13 @@ async def test_fabric_capacities_list_skus(self, resource_group): result = [r async for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_capacities_list_usages(self, resource_group): + response = self.client.fabric_capacities.list_usages( + location="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/fabric/azure-mgmt-fabric/pyproject.toml b/sdk/fabric/azure-mgmt-fabric/pyproject.toml index 540da07d41af..d1d36f1c2490 100644 --- a/sdk/fabric/azure-mgmt-fabric/pyproject.toml +++ b/sdk/fabric/azure-mgmt-fabric/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-fabric" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Fabric Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "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 = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.fabric._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-fabric" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Fabric Management" +package_doc_id = "" +is_stable = true +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" +title = "FabricMgmtClient" diff --git a/sdk/fabric/azure-mgmt-fabric/sdk_packaging.toml b/sdk/fabric/azure-mgmt-fabric/sdk_packaging.toml deleted file mode 100644 index c79e9166bd21..000000000000 --- a/sdk/fabric/azure-mgmt-fabric/sdk_packaging.toml +++ /dev/null @@ -1,12 +0,0 @@ -[packaging] -package_name = "azure-mgmt-fabric" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Fabric Management" -package_doc_id = "" -is_stable = true -is_arm = true -need_msrestazure = false -need_azuremgmtcore = true -sample_link = "" -exclude_folders = "" -title = "FabricMgmtClient" diff --git a/sdk/fabric/azure-mgmt-fabric/setup.py b/sdk/fabric/azure-mgmt-fabric/setup.py deleted file mode 100644 index 56b5f718a923..000000000000 --- a/sdk/fabric/azure-mgmt-fabric/setup.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-fabric" -PACKAGE_PPRINT_NAME = "Fabric Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", - ], - python_requires=">=3.8", -) diff --git a/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml b/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml index 70bb9c371953..0c2ab368f8c5 100644 --- a/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml +++ b/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml @@ -1,4 +1,4 @@ -directory: specification/fabric/Microsoft.Fabric.Management -commit: 9ce76c4f113368361dac4de5d0a71eb058602756 +directory: specification/fabric/resource-manager/Microsoft.Fabric/Fabric +commit: a11c8d40bf2ab8aed7c8debec9528bff36a7ae2a repo: Azure/azure-rest-api-specs additionalDirectories: From a2ac74b0c04efe388a03942c9dd6fc0ac4cf2b24 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Fri, 7 Aug 2026 06:14:55 +0000 Subject: [PATCH 2/4] Configurations: 'specification/fabric/resource-manager/Microsoft.Fabric/Fabric/tspconfig.yaml', SDK Release Type: beta, and CommitSHA: '2c275e5b4f834495b2dc99c0ed162436f38686bd' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6671798 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- sdk/fabric/azure-mgmt-fabric/CHANGELOG.md | 13 +++++++++++++ sdk/fabric/azure-mgmt-fabric/_metadata.json | 2 +- .../azure-mgmt-fabric/azure/mgmt/fabric/_version.py | 2 +- sdk/fabric/azure-mgmt-fabric/pyproject.toml | 4 ++-- sdk/fabric/azure-mgmt-fabric/tsp-location.yaml | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md index 59cbdb37e275..f00bffa5d998 100644 --- a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md +++ b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 1.1.0b1 (2026-08-07) + +### Features Added + + - Client `FabricMgmtClient` added parameter `cloud_setting` in method `__init__` + - Model `FabricCapacityProperties` added property `overage` + - Model `FabricCapacityUpdateProperties` added property `overage` + - Added model `CapacityOverageProperties` + - Added enum `CapacityOverageState` + - Added model `Quota` + - Added model `QuotaName` + - Model `FabricCapacitiesOperations` added method `list_usages` + ## 1.1.0 (2026-08-07) WARNING: Stable SDK version 1.1.0 is used with preview API version 2026-08-01-preview. If this is expected, delete this line; otherwise, check this PR. diff --git a/sdk/fabric/azure-mgmt-fabric/_metadata.json b/sdk/fabric/azure-mgmt-fabric/_metadata.json index 1b0f57384835..be35a2769097 100644 --- a/sdk/fabric/azure-mgmt-fabric/_metadata.json +++ b/sdk/fabric/azure-mgmt-fabric/_metadata.json @@ -3,7 +3,7 @@ "apiVersions": { "Microsoft.Fabric": "2026-08-01-preview" }, - "commit": "a11c8d40bf2ab8aed7c8debec9528bff36a7ae2a", + "commit": "2c275e5b4f834495b2dc99c0ed162436f38686bd", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/fabric/resource-manager/Microsoft.Fabric/Fabric", "emitterVersion": "0.63.3", diff --git a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py index ed0855dea5e6..a1f432eddc4e 100644 --- a/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py +++ b/sdk/fabric/azure-mgmt-fabric/azure/mgmt/fabric/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.1.0b1" diff --git a/sdk/fabric/azure-mgmt-fabric/pyproject.toml b/sdk/fabric/azure-mgmt-fabric/pyproject.toml index d1d36f1c2490..dfc5ee17e545 100644 --- a/sdk/fabric/azure-mgmt-fabric/pyproject.toml +++ b/sdk/fabric/azure-mgmt-fabric/pyproject.toml @@ -13,7 +13,7 @@ authors = [ description = "Microsoft Azure Fabric Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -79,7 +79,7 @@ package_name = "azure-mgmt-fabric" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Fabric Management" package_doc_id = "" -is_stable = true +is_stable = false is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml b/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml index 0c2ab368f8c5..6c97f703d8d3 100644 --- a/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml +++ b/sdk/fabric/azure-mgmt-fabric/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/fabric/resource-manager/Microsoft.Fabric/Fabric -commit: a11c8d40bf2ab8aed7c8debec9528bff36a7ae2a +commit: 2c275e5b4f834495b2dc99c0ed162436f38686bd repo: Azure/azure-rest-api-specs additionalDirectories: From 9959b061a5890ddbc81f13051e517321760d1c87 Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:30:56 +0800 Subject: [PATCH 3/4] Update CHANGELOG.md --- sdk/fabric/azure-mgmt-fabric/CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md index f00bffa5d998..96b090fe6e03 100644 --- a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md +++ b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md @@ -13,12 +13,6 @@ - Added model `QuotaName` - Model `FabricCapacitiesOperations` added method `list_usages` -## 1.1.0 (2026-08-07) - -WARNING: Stable SDK version 1.1.0 is used with preview API version 2026-08-01-preview. If this is expected, delete this line; otherwise, check this PR. - -tool can't generate changelog for this release, please update manually. - ## 1.0.0 (2024-10-21) ### Other Changes From 11214f808fa3f2d3fef64d766f9934675c5c3b2c Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 Date: Fri, 7 Aug 2026 14:35:56 +0800 Subject: [PATCH 4/4] update Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5806c81-9a1b-477a-9f9e-9c9b04f329cf --- sdk/fabric/azure-mgmt-fabric/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md index 96b090fe6e03..a2f54b52d9fb 100644 --- a/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md +++ b/sdk/fabric/azure-mgmt-fabric/CHANGELOG.md @@ -11,7 +11,7 @@ - Added enum `CapacityOverageState` - Added model `Quota` - Added model `QuotaName` - - Model `FabricCapacitiesOperations` added method `list_usages` + - Operation group `FabricCapacitiesOperations` added method `list_usages` ## 1.0.0 (2024-10-21)