diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/CHANGELOG.md b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/CHANGELOG.md index c118e690a4b6..c8ac1afd0f69 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/CHANGELOG.md +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/CHANGELOG.md @@ -1,5 +1,242 @@ # Release History +## 1.0.0 (2025-04-27) + +### Features Added + + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `check_name_availability` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `deployment_preflight` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `location_based_operation_results` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `operation_results` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `fabric_agent` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `job` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `private_endpoint_connection_proxies` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `private_endpoint_connections` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `private_link_resources` + - Client `RecoveryServicesDataReplicationMgmtClient` added operation group `recovery_point` + - Model `DeploymentPreflightResource` added property `properties` + - Model `EmailConfigurationModelProperties` added property `provisioning_state` + - Model `EventModelProperties` added property `provisioning_state` + - Model `HyperVToAzStackHCIDiskInput` added property `disk_block_size` + - Model `HyperVToAzStackHCIDiskInput` added property `disk_logical_sector_size` + - Model `HyperVToAzStackHCIDiskInput` added property `disk_physical_sector_size` + - Model `HyperVToAzStackHCIDiskInput` added property `disk_identifier` + - Model `HyperVToAzStackHCIDiskInput` added property `disk_controller` + - Model `HyperVToAzStackHCINicInput` added property `is_static_ip_migration_enabled` + - Model `HyperVToAzStackHCINicInput` added property `is_mac_migration_enabled` + - Model `HyperVToAzStackHCIProtectedDiskProperties` added property `disk_block_size` + - Model `HyperVToAzStackHCIProtectedDiskProperties` added property `disk_logical_sector_size` + - Model `HyperVToAzStackHCIProtectedDiskProperties` added property `disk_physical_sector_size` + - Model `HyperVToAzStackHCIProtectedItemModelCustomProperties` added property `source_fabric_agent_name` + - Model `HyperVToAzStackHCIProtectedItemModelCustomProperties` added property `target_fabric_agent_name` + - Model `ProtectedItemModelProperties` added property `fabric_agent_id` + - Model `ProtectedItemModelProperties` added property `target_fabric_agent_id` + - Model `RecoveryPointModelProperties` added property `provisioning_state` + - Model `TaskModel` added property `children_jobs` + - Model `VMwareToAzStackHCIDiskInput` added property `disk_block_size` + - Model `VMwareToAzStackHCIDiskInput` added property `disk_logical_sector_size` + - Model `VMwareToAzStackHCIDiskInput` added property `disk_physical_sector_size` + - Model `VMwareToAzStackHCIDiskInput` added property `disk_identifier` + - Model `VMwareToAzStackHCIDiskInput` added property `disk_controller` + - Model `VMwareToAzStackHCINicInput` added property `is_static_ip_migration_enabled` + - Model `VMwareToAzStackHCINicInput` added property `is_mac_migration_enabled` + - Model `VMwareToAzStackHCIProtectedDiskProperties` added property `disk_block_size` + - Model `VMwareToAzStackHCIProtectedDiskProperties` added property `disk_logical_sector_size` + - Model `VMwareToAzStackHCIProtectedDiskProperties` added property `disk_physical_sector_size` + - Model `VMwareToAzStackHCIProtectedItemModelCustomProperties` added property `source_fabric_agent_name` + - Model `VMwareToAzStackHCIProtectedItemModelCustomProperties` added property `target_fabric_agent_name` + - Model `VaultModel` added property `identity` + - Model `VaultModelUpdate` added property `identity` + - Added model `ConnectionDetails` + - Added enum `CreatedByType` + - Added model `DiskControllerInputs` + - Added model `EmailConfigurationModelListResult` + - Added model `EventModelListResult` + - Added model `FabricAgentModel` + - Added model `FabricAgentModelCustomProperties` + - Added model `FabricAgentModelListResult` + - Added model `FabricAgentModelProperties` + - Added model `FabricModelListResult` + - Added model `FailoverJobModelCustomProperties` + - Added model `GroupConnectivityInformation` + - Added model `HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate` + - Added model `JobModel` + - Added model `JobModelCustomProperties` + - Added model `JobModelCustomPropertiesAffectedObjectDetails` + - Added model `JobModelListResult` + - Added model `JobModelProperties` + - Added enum `JobObjectType` + - Added enum `JobState` + - Added model `ManagedServiceIdentity` + - Added enum `ManagedServiceIdentityType` + - Added model `PolicyModelListResult` + - Added model `PrivateEndpoint` + - Added model `PrivateEndpointConnection` + - Added model `PrivateEndpointConnectionListResult` + - Added model `PrivateEndpointConnectionProxy` + - Added model `PrivateEndpointConnectionProxyListResult` + - Added model `PrivateEndpointConnectionProxyProperties` + - Added model `PrivateEndpointConnectionResponseProperties` + - Added enum `PrivateEndpointConnectionStatus` + - Added model `PrivateLinkResource` + - Added model `PrivateLinkResourceListResult` + - Added model `PrivateLinkResourceProperties` + - Added model `PrivateLinkServiceConnection` + - Added model `PrivateLinkServiceConnectionState` + - Added model `PrivateLinkServiceProxy` + - Added model `ProtectedItemModelCustomPropertiesUpdate` + - Added model `ProtectedItemModelListResult` + - Added model `ProtectedItemModelPropertiesUpdate` + - Added model `ProtectedItemModelUpdate` + - Added model `ProxyResource` + - Added model `RecoveryPointModelListResult` + - Added model `RemotePrivateEndpoint` + - Added model `RemotePrivateEndpointConnection` + - Added model `ReplicationExtensionModelListResult` + - Added model `Resource` + - Added model `SystemData` + - Added model `TestFailoverCleanupJobModelCustomProperties` + - Added model `TestFailoverJobModelCustomProperties` + - Added model `TrackedResource` + - Added model `UserAssignedIdentity` + - Added model `VMwareFabricAgentModelCustomProperties` + - Added model `VMwareToAzStackHCIEventModelCustomProperties` + - Added model `VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate` + - Added model `VMwareToAzStackHCIRecoveryPointModelCustomProperties` + - Added model `VaultIdentityModel` + - Added enum `VaultIdentityType` + - Added model `VaultModelListResult` + - Model `ProtectedItemOperations` added method `begin_update` + - Added model `CheckNameAvailabilityOperations` + - Added model `DeploymentPreflightOperations` + - Added model `FabricAgentOperations` + - Added model `JobOperations` + - Added model `LocationBasedOperationResultsOperations` + - Added model `OperationResultsOperations` + - Added model `PrivateEndpointConnectionProxiesOperations` + - Added model `PrivateEndpointConnectionsOperations` + - Added model `PrivateLinkResourcesOperations` + - Added model `RecoveryPointOperations` + - Method `EmailConfigurationOperations.create` has a new overload `def create(self: None, resource_group_name: str, vault_name: str, email_configuration_name: str, body: EmailConfigurationModel, content_type: str)` + - Method `EmailConfigurationOperations.create` has a new overload `def create(self: None, resource_group_name: str, vault_name: str, email_configuration_name: str, body: IO[bytes], content_type: str)` + - Method `FabricOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, fabric_name: str, body: FabricModel, content_type: str)` + - Method `FabricOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, fabric_name: str, body: IO[bytes], content_type: str)` + - Method `FabricOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, fabric_name: str, body: FabricModelUpdate, content_type: str)` + - Method `FabricOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, fabric_name: str, body: IO[bytes], content_type: str)` + - Method `PolicyOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, policy_name: str, body: PolicyModel, content_type: str)` + - Method `PolicyOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, policy_name: str, body: IO[bytes], content_type: str)` + - Method `ProtectedItemOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: ProtectedItemModel, content_type: str)` + - Method `ProtectedItemOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: IO[bytes], content_type: str)` + - Method `ProtectedItemOperations.begin_planned_failover` has a new overload `def begin_planned_failover(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: PlannedFailoverModel, content_type: str)` + - Method `ProtectedItemOperations.begin_planned_failover` has a new overload `def begin_planned_failover(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: IO[bytes], content_type: str)` + - Method `ProtectedItemOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: ProtectedItemModelUpdate, content_type: str)` + - Method `ProtectedItemOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, vault_name: str, protected_item_name: str, body: IO[bytes], content_type: str)` + - Method `ReplicationExtensionOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, replication_extension_name: str, body: ReplicationExtensionModel, content_type: str)` + - Method `ReplicationExtensionOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, replication_extension_name: str, body: IO[bytes], content_type: str)` + - Method `VaultOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, body: VaultModel, content_type: str)` + - Method `VaultOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, vault_name: str, body: IO[bytes], content_type: str)` + - Method `VaultOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, vault_name: str, body: VaultModelUpdate, content_type: str)` + - Method `VaultOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, vault_name: str, body: IO[bytes], content_type: str)` + - Method `CheckNameAvailabilityOperations.post` has a new overload `def post(self: None, location: str, body: Optional[CheckNameAvailabilityModel], content_type: str)` + - Method `CheckNameAvailabilityOperations.post` has a new overload `def post(self: None, location: str, body: Optional[IO[bytes]], content_type: str)` + - Method `DeploymentPreflightOperations.post` has a new overload `def post(self: None, resource_group_name: str, deployment_id: str, body: Optional[DeploymentPreflightModel], content_type: str)` + - Method `DeploymentPreflightOperations.post` has a new overload `def post(self: None, resource_group_name: str, deployment_id: str, body: Optional[IO[bytes]], content_type: str)` + - Method `FabricAgentOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, fabric_name: str, fabric_agent_name: str, body: FabricAgentModel, content_type: str)` + - Method `FabricAgentOperations.begin_create` has a new overload `def begin_create(self: None, resource_group_name: str, fabric_name: str, fabric_agent_name: str, body: IO[bytes], content_type: str)` + - Method `PrivateEndpointConnectionProxiesOperations.create` has a new overload `def create(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, body: PrivateEndpointConnectionProxy, content_type: str)` + - Method `PrivateEndpointConnectionProxiesOperations.create` has a new overload `def create(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, body: IO[bytes], content_type: str)` + - Method `PrivateEndpointConnectionProxiesOperations.validate` has a new overload `def validate(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, body: PrivateEndpointConnectionProxy, content_type: str)` + - Method `PrivateEndpointConnectionProxiesOperations.validate` has a new overload `def validate(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, body: IO[bytes], content_type: str)` + - Method `PrivateEndpointConnectionsOperations.update` has a new overload `def update(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, body: PrivateEndpointConnection, content_type: str)` + - Method `PrivateEndpointConnectionsOperations.update` has a new overload `def update(self: None, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, body: IO[bytes], content_type: str)` + +### Breaking Changes + + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.dra` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.dra_operation_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.fabric_operations_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.policy_operation_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.protected_item_operation_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.recovery_points` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.replication_extension_operation_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.vault_operation_status` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.workflow` + - Deleted or renamed client operation group `RecoveryServicesDataReplicationMgmtClient.workflow_operation_status` + - Deleted or renamed client method `RecoveryServicesDataReplicationMgmtClient.check_name_availability` + - Deleted or renamed client method `RecoveryServicesDataReplicationMgmtClient.deployment_preflight` + - Model `HyperVToAzStackHCIProtectedItemModelCustomProperties` deleted or renamed its instance variable `source_dra_name` + - Model `HyperVToAzStackHCIProtectedItemModelCustomProperties` deleted or renamed its instance variable `target_dra_name` + - Model `ProtectedItemModelProperties` deleted or renamed its instance variable `dra_id` + - Model `ProtectedItemModelProperties` deleted or renamed its instance variable `target_dra_id` + - Model `TaskModel` deleted or renamed its instance variable `children_workflows` + - Model `VMwareToAzStackHCIProtectedItemModelCustomProperties` deleted or renamed its instance variable `source_dra_name` + - Model `VMwareToAzStackHCIProtectedItemModelCustomProperties` deleted or renamed its instance variable `target_dra_name` + - Deleted or renamed model `DraModel` + - Deleted or renamed model `DraModelCollection` + - Deleted or renamed model `DraModelCustomProperties` + - Deleted or renamed model `DraModelProperties` + - Deleted or renamed model `DraModelSystemData` + - Deleted or renamed model `EmailConfigurationModelCollection` + - Deleted or renamed model `EmailConfigurationModelSystemData` + - Deleted or renamed model `EventModelCollection` + - Deleted or renamed model `EventModelSystemData` + - Deleted or renamed model `FabricModelCollection` + - Deleted or renamed model `FabricModelSystemData` + - Deleted or renamed model `FabricModelUpdateSystemData` + - Deleted or renamed model `FailoverWorkflowModelCustomProperties` + - Deleted or renamed model `OperationModel` + - Deleted or renamed model `OperationModelCollection` + - Deleted or renamed model `OperationModelProperties` + - Deleted or renamed model `PolicyModelCollection` + - Deleted or renamed model `PolicyModelSystemData` + - Deleted or renamed model `ProtectedItemModelCollection` + - Deleted or renamed model `ProtectedItemModelPropertiesCurrentJob` + - Deleted or renamed model `ProtectedItemModelPropertiesLastFailedEnableProtectionJob` + - Deleted or renamed model `ProtectedItemModelPropertiesLastFailedPlannedFailoverJob` + - Deleted or renamed model `ProtectedItemModelPropertiesLastTestFailoverJob` + - Deleted or renamed model `ProtectedItemModelSystemData` + - Deleted or renamed model `RecoveryPointModelCollection` + - Deleted or renamed model `RecoveryPointModelSystemData` + - Deleted or renamed model `ReplicationExtensionModelCollection` + - Deleted or renamed model `ReplicationExtensionModelSystemData` + - Deleted or renamed model `SystemDataModel` + - Deleted or renamed model `TestFailoverCleanupWorkflowModelCustomProperties` + - Deleted or renamed model `TestFailoverWorkflowModelCustomProperties` + - Deleted or renamed model `VMwareDraModelCustomProperties` + - Deleted or renamed model `VaultModelCollection` + - Deleted or renamed model `VaultModelSystemData` + - Deleted or renamed model `VaultModelUpdateSystemData` + - Deleted or renamed model `WorkflowModel` + - Deleted or renamed model `WorkflowModelCollection` + - Deleted or renamed model `WorkflowModelCustomProperties` + - Deleted or renamed model `WorkflowModelProperties` + - Deleted or renamed model `WorkflowModelSystemData` + - Deleted or renamed model `WorkflowObjectType` + - Deleted or renamed model `WorkflowState` + - Method `EmailConfigurationOperations.create` removed default value `None` from its parameter `body` + - Method `EventOperations.list` deleted or renamed its parameter `filter` of kind `positional_or_keyword` + - Method `FabricOperations.begin_create` removed default value `None` from its parameter `body` + - Method `FabricOperations.begin_update` removed default value `None` from its parameter `body` + - Method `FabricOperations.list_by_subscription` deleted or renamed its parameter `continuation_token_parameter` of kind `positional_or_keyword` + - Method `PolicyOperations.begin_create` removed default value `None` from its parameter `body` + - Method `ProtectedItemOperations.begin_create` removed default value `None` from its parameter `body` + - Method `ProtectedItemOperations.begin_planned_failover` removed default value `None` from its parameter `body` + - Method `ReplicationExtensionOperations.begin_create` removed default value `None` from its parameter `body` + - Method `VaultOperations.begin_create` removed default value `None` from its parameter `body` + - Method `VaultOperations.begin_update` removed default value `None` from its parameter `body` + - Method `VaultOperations.list_by_subscription` deleted or renamed its parameter `continuation_token_parameter` of kind `positional_or_keyword` + - Deleted or renamed model `DraOperationStatusOperations` + - Deleted or renamed model `DraOperations` + - Deleted or renamed model `FabricOperationsStatusOperations` + - Deleted or renamed model `PolicyOperationStatusOperations` + - Deleted or renamed model `ProtectedItemOperationStatusOperations` + - Deleted or renamed model `RecoveryPointsOperations` + - Deleted or renamed model `RecoveryServicesDataReplicationMgmtClientOperationsMixin` + - Deleted or renamed model `ReplicationExtensionOperationStatusOperations` + - Deleted or renamed model `VaultOperationStatusOperations` + - Deleted or renamed model `WorkflowOperationStatusOperations` + - Deleted or renamed model `WorkflowOperations` + ## 1.0.0b1 (2023-10-23) * Initial Release diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/README.md b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/README.md index 80e9a6174db9..b2c6351e349f 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/README.md +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Recoveryservicesdatareplication Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.9+. 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.7+ is required to use this package. +- Python 3.9+ 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, [Azure Active Directory](https://aka.ms/awps/aad) 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. @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/_meta.json b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/_meta.json index 2e978e6fd2a3..cb650e0a8288 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/_meta.json +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/_meta.json @@ -1,11 +1,11 @@ { - "commit": "82e7e30a6d46c095e0c3211f3ff7bafe82a362f1", + "commit": "c908490d3d2b6fdd1a5dfa108a0f47183e4c06e0", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.34.1", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/recoveryservicesdatareplication/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/recoveryservicesdatareplication/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.34.1 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/recoveryservicesdatareplication/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/__init__.py index e96e0b432e4f..636b5153c015 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/__init__.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._recovery_services_data_replication_mgmt_client import RecoveryServicesDataReplicationMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._recovery_services_data_replication_mgmt_client import RecoveryServicesDataReplicationMgmtClient # 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 @@ -21,6 +27,6 @@ __all__ = [ "RecoveryServicesDataReplicationMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_configuration.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_configuration.py index a13ca8e5e8fb..8162c8ee52fb 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_configuration.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,20 +9,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class RecoveryServicesDataReplicationMgmtClientConfiguration( - Configuration -): # pylint: disable=too-many-instance-attributes +class RecoveryServicesDataReplicationMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for RecoveryServicesDataReplicationMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -31,14 +28,13 @@ class RecoveryServicesDataReplicationMgmtClientConfiguration( :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 - :keyword api_version: Api Version. Default value is "2021-02-16-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(RecoveryServicesDataReplicationMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-02-16-preview") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-recoveryservicesdatareplication/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -58,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_recovery_services_data_replication_mgmt_client.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_recovery_services_data_replication_mgmt_client.py index 706bade06ff3..fa75d39b73f8 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_recovery_services_data_replication_mgmt_client.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_recovery_services_data_replication_mgmt_client.py @@ -7,161 +7,183 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +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 . import models as _models from ._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( - DraOperationStatusOperations, - DraOperations, + CheckNameAvailabilityOperations, + DeploymentPreflightOperations, EmailConfigurationOperations, EventOperations, + FabricAgentOperations, FabricOperations, - FabricOperationsStatusOperations, + JobOperations, + LocationBasedOperationResultsOperations, + OperationResultsOperations, Operations, - PolicyOperationStatusOperations, PolicyOperations, - ProtectedItemOperationStatusOperations, + PrivateEndpointConnectionProxiesOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, ProtectedItemOperations, - RecoveryPointsOperations, - RecoveryServicesDataReplicationMgmtClientOperationsMixin, - ReplicationExtensionOperationStatusOperations, + RecoveryPointOperations, ReplicationExtensionOperations, - VaultOperationStatusOperations, VaultOperations, - WorkflowOperationStatusOperations, - WorkflowOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class RecoveryServicesDataReplicationMgmtClient( - RecoveryServicesDataReplicationMgmtClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class RecoveryServicesDataReplicationMgmtClient: # pylint: disable=too-many-instance-attributes,name-too-long """A first party Azure service enabling the data replication. - :ivar dra: DraOperations operations - :vartype dra: azure.mgmt.recoveryservicesdatareplication.operations.DraOperations - :ivar dra_operation_status: DraOperationStatusOperations operations - :vartype dra_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.DraOperationStatusOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.recoveryservicesdatareplication.operations.Operations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.recoveryservicesdatareplication.operations.CheckNameAvailabilityOperations + :ivar fabric: FabricOperations operations + :vartype fabric: azure.mgmt.recoveryservicesdatareplication.operations.FabricOperations + :ivar vault: VaultOperations operations + :vartype vault: azure.mgmt.recoveryservicesdatareplication.operations.VaultOperations + :ivar deployment_preflight: DeploymentPreflightOperations operations + :vartype deployment_preflight: + azure.mgmt.recoveryservicesdatareplication.operations.DeploymentPreflightOperations + :ivar location_based_operation_results: LocationBasedOperationResultsOperations operations + :vartype location_based_operation_results: + azure.mgmt.recoveryservicesdatareplication.operations.LocationBasedOperationResultsOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.recoveryservicesdatareplication.operations.OperationResultsOperations + :ivar fabric_agent: FabricAgentOperations operations + :vartype fabric_agent: + azure.mgmt.recoveryservicesdatareplication.operations.FabricAgentOperations :ivar email_configuration: EmailConfigurationOperations operations :vartype email_configuration: azure.mgmt.recoveryservicesdatareplication.operations.EmailConfigurationOperations :ivar event: EventOperations operations :vartype event: azure.mgmt.recoveryservicesdatareplication.operations.EventOperations - :ivar fabric: FabricOperations operations - :vartype fabric: azure.mgmt.recoveryservicesdatareplication.operations.FabricOperations - :ivar fabric_operations_status: FabricOperationsStatusOperations operations - :vartype fabric_operations_status: - azure.mgmt.recoveryservicesdatareplication.operations.FabricOperationsStatusOperations - :ivar policy: PolicyOperations operations - :vartype policy: azure.mgmt.recoveryservicesdatareplication.operations.PolicyOperations - :ivar policy_operation_status: PolicyOperationStatusOperations operations - :vartype policy_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.PolicyOperationStatusOperations + :ivar job: JobOperations operations + :vartype job: azure.mgmt.recoveryservicesdatareplication.operations.JobOperations + :ivar private_endpoint_connection_proxies: PrivateEndpointConnectionProxiesOperations + operations + :vartype private_endpoint_connection_proxies: + azure.mgmt.recoveryservicesdatareplication.operations.PrivateEndpointConnectionProxiesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.recoveryservicesdatareplication.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.recoveryservicesdatareplication.operations.PrivateLinkResourcesOperations :ivar protected_item: ProtectedItemOperations operations :vartype protected_item: azure.mgmt.recoveryservicesdatareplication.operations.ProtectedItemOperations - :ivar protected_item_operation_status: ProtectedItemOperationStatusOperations operations - :vartype protected_item_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.ProtectedItemOperationStatusOperations - :ivar recovery_points: RecoveryPointsOperations operations - :vartype recovery_points: - azure.mgmt.recoveryservicesdatareplication.operations.RecoveryPointsOperations + :ivar recovery_point: RecoveryPointOperations operations + :vartype recovery_point: + azure.mgmt.recoveryservicesdatareplication.operations.RecoveryPointOperations :ivar replication_extension: ReplicationExtensionOperations operations :vartype replication_extension: azure.mgmt.recoveryservicesdatareplication.operations.ReplicationExtensionOperations - :ivar replication_extension_operation_status: ReplicationExtensionOperationStatusOperations - operations - :vartype replication_extension_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.ReplicationExtensionOperationStatusOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.recoveryservicesdatareplication.operations.Operations - :ivar vault: VaultOperations operations - :vartype vault: azure.mgmt.recoveryservicesdatareplication.operations.VaultOperations - :ivar vault_operation_status: VaultOperationStatusOperations operations - :vartype vault_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.VaultOperationStatusOperations - :ivar workflow: WorkflowOperations operations - :vartype workflow: azure.mgmt.recoveryservicesdatareplication.operations.WorkflowOperations - :ivar workflow_operation_status: WorkflowOperationStatusOperations operations - :vartype workflow_operation_status: - azure.mgmt.recoveryservicesdatareplication.operations.WorkflowOperationStatusOperations + :ivar policy: PolicyOperations operations + :vartype policy: azure.mgmt.recoveryservicesdatareplication.operations.PolicyOperations :param credential: Credential needed for the client to connect to Azure. Required. :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 URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2021-02-16-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-09-01". 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. """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) 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 = RecoveryServicesDataReplicationMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.dra = DraOperations(self._client, self._config, self._serialize, self._deserialize) - self.dra_operation_status = DraOperationStatusOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.email_configuration = EmailConfigurationOperations( + self.fabric = FabricOperations(self._client, self._config, self._serialize, self._deserialize) + self.vault = VaultOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_preflight = DeploymentPreflightOperations( self._client, self._config, self._serialize, self._deserialize ) - self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) - self.fabric = FabricOperations(self._client, self._config, self._serialize, self._deserialize) - self.fabric_operations_status = FabricOperationsStatusOperations( + self.location_based_operation_results = LocationBasedOperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_operation_status = PolicyOperationStatusOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.protected_item = ProtectedItemOperations(self._client, self._config, self._serialize, self._deserialize) - self.protected_item_operation_status = ProtectedItemOperationStatusOperations( + self.fabric_agent = FabricAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.email_configuration = EmailConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recovery_points = RecoveryPointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.replication_extension = ReplicationExtensionOperations( + self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) + self.job = JobOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.replication_extension_operation_status = ReplicationExtensionOperationStatusOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.vault = VaultOperations(self._client, self._config, self._serialize, self._deserialize) - self.vault_operation_status = VaultOperationStatusOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workflow = WorkflowOperations(self._client, self._config, self._serialize, self._deserialize) - self.workflow_operation_status = WorkflowOperationStatusOperations( + self.protected_item = ProtectedItemOperations(self._client, self._config, self._serialize, self._deserialize) + self.recovery_point = RecoveryPointOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_extension = ReplicationExtensionOperations( self._client, self._config, self._serialize, self._deserialize ) + self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -181,12 +203,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "RecoveryServicesDataReplicationMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_utils/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_serialization.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_utils/serialization.py similarity index 80% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_serialization.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_utils/serialization.py index 4bae2292227b..f5187701d7be 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_serialization.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_utils/serialization.py @@ -1,30 +1,12 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -48,11 +30,8 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, - Mapping, ) try: @@ -62,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +70,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +93,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -124,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +124,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +136,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +158,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -184,80 +165,31 @@ 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.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - 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): - 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: Dict[str, Any] = {} - for k in kwargs: + 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__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +244,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +280,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +293,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +304,9 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -385,12 +340,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -400,30 +358,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: 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 + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + 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, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -431,9 +390,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :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 + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -445,7 +406,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -453,21 +414,25 @@ 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)) + result.update(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 + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None 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: @@ -506,11 +471,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -545,7 +512,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,17 +528,20 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = 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 - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :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) keep_readonly = kwargs.get("keep_readonly", False) @@ -597,12 +567,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -638,7 +610,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -649,7 +622,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,18 +641,18 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :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 """ # Just in case this is a dict @@ -708,20 +681,22 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :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 + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -730,30 +705,30 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -763,19 +738,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :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: if data_type in ["[str]"]: @@ -784,32 +760,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :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 """ if data is None: raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -824,12 +799,11 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -845,23 +819,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ 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 + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -875,8 +852,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -886,15 +862,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -949,9 +923,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -975,7 +948,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -983,6 +956,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -993,7 +967,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1007,7 +981,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1038,56 +1012,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1095,11 +1074,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1109,30 +1089,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + 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: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1145,12 +1127,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :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): attr = isodate.parse_datetime(attr) @@ -1170,19 +1153,20 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :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): return attr @@ -1190,11 +1174,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1209,14 +1193,15 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1230,7 +1215,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1238,17 +1222,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1285,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1337,22 +1333,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # 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( - xml_name - ) + # 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( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1360,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1369,9 +1364,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1386,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = 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 @@ -1407,27 +1402,29 @@ def __call__(self, target_obj, response_data, content_type=None): :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 """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :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 """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1444,15 +1441,15 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1481,10 +1478,9 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1511,18 +1507,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1537,10 +1535,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1558,10 +1558,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1578,31 +1580,42 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + 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() # 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 - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1611,15 +1624,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :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 """ if data is None: return data @@ -1633,7 +1647,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1652,15 +1670,15 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1677,6 +1695,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1687,20 +1706,21 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :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 if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1726,11 +1746,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1738,8 +1757,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :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. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1749,24 +1769,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1774,6 +1793,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1787,8 +1807,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1800,6 +1819,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1808,12 +1828,11 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1829,8 +1848,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :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 @@ -1841,8 +1861,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :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 @@ -1856,24 +1877,26 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :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 @@ -1884,8 +1907,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :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 @@ -1893,32 +1917,33 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :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 if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :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 @@ -1931,31 +1956,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :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) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :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 @@ -1982,9 +2008,8 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1992,15 +2017,16 @@ def deserialize_unix(attr): This is represented as seconds. :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 try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_vendor.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_vendor.py deleted file mode 100644 index 69f25b502ec4..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_vendor.py +++ /dev/null @@ -1,36 +0,0 @@ -# -------------------------------------------------------------------------- -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -class RecoveryServicesDataReplicationMgmtClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: RecoveryServicesDataReplicationMgmtClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_version.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_version.py index e5754a47ce68..c47f66669f1b 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_version.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0" diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/__init__.py index 8e2727907bbb..4e9805963769 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/__init__.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._recovery_services_data_replication_mgmt_client import RecoveryServicesDataReplicationMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._recovery_services_data_replication_mgmt_client import RecoveryServicesDataReplicationMgmtClient # 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 @@ -18,6 +24,6 @@ __all__ = [ "RecoveryServicesDataReplicationMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_configuration.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_configuration.py index 2647c8c368a5..27e4c883a3ec 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_configuration.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,20 +9,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class RecoveryServicesDataReplicationMgmtClientConfiguration( - Configuration -): # pylint: disable=too-many-instance-attributes +class RecoveryServicesDataReplicationMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for RecoveryServicesDataReplicationMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -31,14 +28,13 @@ class RecoveryServicesDataReplicationMgmtClientConfiguration( :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 - :keyword api_version: Api Version. Default value is "2021-02-16-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(RecoveryServicesDataReplicationMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-02-16-preview") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-recoveryservicesdatareplication/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -58,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_recovery_services_data_replication_mgmt_client.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_recovery_services_data_replication_mgmt_client.py index e23fab178e10..abece5e0d188 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_recovery_services_data_replication_mgmt_client.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_recovery_services_data_replication_mgmt_client.py @@ -7,161 +7,187 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +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 .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration from .operations import ( - DraOperationStatusOperations, - DraOperations, + CheckNameAvailabilityOperations, + DeploymentPreflightOperations, EmailConfigurationOperations, EventOperations, + FabricAgentOperations, FabricOperations, - FabricOperationsStatusOperations, + JobOperations, + LocationBasedOperationResultsOperations, + OperationResultsOperations, Operations, - PolicyOperationStatusOperations, PolicyOperations, - ProtectedItemOperationStatusOperations, + PrivateEndpointConnectionProxiesOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, ProtectedItemOperations, - RecoveryPointsOperations, - RecoveryServicesDataReplicationMgmtClientOperationsMixin, - ReplicationExtensionOperationStatusOperations, + RecoveryPointOperations, ReplicationExtensionOperations, - VaultOperationStatusOperations, VaultOperations, - WorkflowOperationStatusOperations, - WorkflowOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class RecoveryServicesDataReplicationMgmtClient( - RecoveryServicesDataReplicationMgmtClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class RecoveryServicesDataReplicationMgmtClient: # pylint: disable=too-many-instance-attributes,name-too-long """A first party Azure service enabling the data replication. - :ivar dra: DraOperations operations - :vartype dra: azure.mgmt.recoveryservicesdatareplication.aio.operations.DraOperations - :ivar dra_operation_status: DraOperationStatusOperations operations - :vartype dra_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.DraOperationStatusOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.recoveryservicesdatareplication.aio.operations.Operations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.recoveryservicesdatareplication.aio.operations.CheckNameAvailabilityOperations + :ivar fabric: FabricOperations operations + :vartype fabric: azure.mgmt.recoveryservicesdatareplication.aio.operations.FabricOperations + :ivar vault: VaultOperations operations + :vartype vault: azure.mgmt.recoveryservicesdatareplication.aio.operations.VaultOperations + :ivar deployment_preflight: DeploymentPreflightOperations operations + :vartype deployment_preflight: + azure.mgmt.recoveryservicesdatareplication.aio.operations.DeploymentPreflightOperations + :ivar location_based_operation_results: LocationBasedOperationResultsOperations operations + :vartype location_based_operation_results: + azure.mgmt.recoveryservicesdatareplication.aio.operations.LocationBasedOperationResultsOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.recoveryservicesdatareplication.aio.operations.OperationResultsOperations + :ivar fabric_agent: FabricAgentOperations operations + :vartype fabric_agent: + azure.mgmt.recoveryservicesdatareplication.aio.operations.FabricAgentOperations :ivar email_configuration: EmailConfigurationOperations operations :vartype email_configuration: azure.mgmt.recoveryservicesdatareplication.aio.operations.EmailConfigurationOperations :ivar event: EventOperations operations :vartype event: azure.mgmt.recoveryservicesdatareplication.aio.operations.EventOperations - :ivar fabric: FabricOperations operations - :vartype fabric: azure.mgmt.recoveryservicesdatareplication.aio.operations.FabricOperations - :ivar fabric_operations_status: FabricOperationsStatusOperations operations - :vartype fabric_operations_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.FabricOperationsStatusOperations - :ivar policy: PolicyOperations operations - :vartype policy: azure.mgmt.recoveryservicesdatareplication.aio.operations.PolicyOperations - :ivar policy_operation_status: PolicyOperationStatusOperations operations - :vartype policy_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.PolicyOperationStatusOperations + :ivar job: JobOperations operations + :vartype job: azure.mgmt.recoveryservicesdatareplication.aio.operations.JobOperations + :ivar private_endpoint_connection_proxies: PrivateEndpointConnectionProxiesOperations + operations + :vartype private_endpoint_connection_proxies: + azure.mgmt.recoveryservicesdatareplication.aio.operations.PrivateEndpointConnectionProxiesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.recoveryservicesdatareplication.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.recoveryservicesdatareplication.aio.operations.PrivateLinkResourcesOperations :ivar protected_item: ProtectedItemOperations operations :vartype protected_item: azure.mgmt.recoveryservicesdatareplication.aio.operations.ProtectedItemOperations - :ivar protected_item_operation_status: ProtectedItemOperationStatusOperations operations - :vartype protected_item_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.ProtectedItemOperationStatusOperations - :ivar recovery_points: RecoveryPointsOperations operations - :vartype recovery_points: - azure.mgmt.recoveryservicesdatareplication.aio.operations.RecoveryPointsOperations + :ivar recovery_point: RecoveryPointOperations operations + :vartype recovery_point: + azure.mgmt.recoveryservicesdatareplication.aio.operations.RecoveryPointOperations :ivar replication_extension: ReplicationExtensionOperations operations :vartype replication_extension: azure.mgmt.recoveryservicesdatareplication.aio.operations.ReplicationExtensionOperations - :ivar replication_extension_operation_status: ReplicationExtensionOperationStatusOperations - operations - :vartype replication_extension_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.ReplicationExtensionOperationStatusOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.recoveryservicesdatareplication.aio.operations.Operations - :ivar vault: VaultOperations operations - :vartype vault: azure.mgmt.recoveryservicesdatareplication.aio.operations.VaultOperations - :ivar vault_operation_status: VaultOperationStatusOperations operations - :vartype vault_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.VaultOperationStatusOperations - :ivar workflow: WorkflowOperations operations - :vartype workflow: azure.mgmt.recoveryservicesdatareplication.aio.operations.WorkflowOperations - :ivar workflow_operation_status: WorkflowOperationStatusOperations operations - :vartype workflow_operation_status: - azure.mgmt.recoveryservicesdatareplication.aio.operations.WorkflowOperationStatusOperations + :ivar policy: PolicyOperations operations + :vartype policy: azure.mgmt.recoveryservicesdatareplication.aio.operations.PolicyOperations :param credential: Credential needed for the client to connect to Azure. Required. :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 URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2021-02-16-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-09-01". 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. """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) 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 = RecoveryServicesDataReplicationMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.dra = DraOperations(self._client, self._config, self._serialize, self._deserialize) - self.dra_operation_status = DraOperationStatusOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.email_configuration = EmailConfigurationOperations( + self.fabric = FabricOperations(self._client, self._config, self._serialize, self._deserialize) + self.vault = VaultOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_preflight = DeploymentPreflightOperations( self._client, self._config, self._serialize, self._deserialize ) - self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) - self.fabric = FabricOperations(self._client, self._config, self._serialize, self._deserialize) - self.fabric_operations_status = FabricOperationsStatusOperations( + self.location_based_operation_results = LocationBasedOperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_operation_status = PolicyOperationStatusOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.protected_item = ProtectedItemOperations(self._client, self._config, self._serialize, self._deserialize) - self.protected_item_operation_status = ProtectedItemOperationStatusOperations( + self.fabric_agent = FabricAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.email_configuration = EmailConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recovery_points = RecoveryPointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.replication_extension = ReplicationExtensionOperations( + self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) + self.job = JobOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.replication_extension_operation_status = ReplicationExtensionOperationStatusOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.vault = VaultOperations(self._client, self._config, self._serialize, self._deserialize) - self.vault_operation_status = VaultOperationStatusOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workflow = WorkflowOperations(self._client, self._config, self._serialize, self._deserialize) - self.workflow_operation_status = WorkflowOperationStatusOperations( + self.protected_item = ProtectedItemOperations(self._client, self._config, self._serialize, self._deserialize) + self.recovery_point = RecoveryPointOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_extension = ReplicationExtensionOperations( self._client, self._config, self._serialize, self._deserialize ) + self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -181,12 +207,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "RecoveryServicesDataReplicationMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_vendor.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_vendor.py deleted file mode 100644 index 19394cdd762b..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/_vendor.py +++ /dev/null @@ -1,28 +0,0 @@ -# -------------------------------------------------------------------------- -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class RecoveryServicesDataReplicationMgmtClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: RecoveryServicesDataReplicationMgmtClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/__init__.py index 08f3ec0219c3..4fb5feec9c05 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/__init__.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/__init__.py @@ -5,53 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._dra_operations import DraOperations -from ._dra_operation_status_operations import DraOperationStatusOperations -from ._email_configuration_operations import EmailConfigurationOperations -from ._event_operations import EventOperations -from ._fabric_operations import FabricOperations -from ._fabric_operations_status_operations import FabricOperationsStatusOperations -from ._policy_operations import PolicyOperations -from ._policy_operation_status_operations import PolicyOperationStatusOperations -from ._protected_item_operations import ProtectedItemOperations -from ._protected_item_operation_status_operations import ProtectedItemOperationStatusOperations -from ._recovery_points_operations import RecoveryPointsOperations -from ._replication_extension_operations import ReplicationExtensionOperations -from ._replication_extension_operation_status_operations import ReplicationExtensionOperationStatusOperations -from ._recovery_services_data_replication_mgmt_client_operations import ( - RecoveryServicesDataReplicationMgmtClientOperationsMixin, -) -from ._operations import Operations -from ._vault_operations import VaultOperations -from ._vault_operation_status_operations import VaultOperationStatusOperations -from ._workflow_operations import WorkflowOperations -from ._workflow_operation_status_operations import WorkflowOperationStatusOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore +from ._fabric_operations import FabricOperations # type: ignore +from ._vault_operations import VaultOperations # type: ignore +from ._deployment_preflight_operations import DeploymentPreflightOperations # type: ignore +from ._location_based_operation_results_operations import LocationBasedOperationResultsOperations # type: ignore +from ._operation_results_operations import OperationResultsOperations # type: ignore +from ._fabric_agent_operations import FabricAgentOperations # type: ignore +from ._email_configuration_operations import EmailConfigurationOperations # type: ignore +from ._event_operations import EventOperations # type: ignore +from ._job_operations import JobOperations # type: ignore +from ._private_endpoint_connection_proxies_operations import PrivateEndpointConnectionProxiesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._protected_item_operations import ProtectedItemOperations # type: ignore +from ._recovery_point_operations import RecoveryPointOperations # type: ignore +from ._replication_extension_operations import ReplicationExtensionOperations # type: ignore +from ._policy_operations import PolicyOperations # 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__ = [ - "DraOperations", - "DraOperationStatusOperations", + "Operations", + "CheckNameAvailabilityOperations", + "FabricOperations", + "VaultOperations", + "DeploymentPreflightOperations", + "LocationBasedOperationResultsOperations", + "OperationResultsOperations", + "FabricAgentOperations", "EmailConfigurationOperations", "EventOperations", - "FabricOperations", - "FabricOperationsStatusOperations", - "PolicyOperations", - "PolicyOperationStatusOperations", + "JobOperations", + "PrivateEndpointConnectionProxiesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", "ProtectedItemOperations", - "ProtectedItemOperationStatusOperations", - "RecoveryPointsOperations", + "RecoveryPointOperations", "ReplicationExtensionOperations", - "ReplicationExtensionOperationStatusOperations", - "RecoveryServicesDataReplicationMgmtClientOperationsMixin", - "Operations", - "VaultOperations", - "VaultOperationStatusOperations", - "WorkflowOperations", - "WorkflowOperationStatusOperations", + "PolicyOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_check_name_availability_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_check_name_availability_operations.py new file mode 100644 index 000000000000..6241cbd4be71 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_check_name_availability_operations.py @@ -0,0 +1,175 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._check_name_availability_operations import build_post_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`check_name_availability` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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") + + @overload + async def post( + self, + location: str, + body: Optional[_models.CheckNameAvailabilityModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def post( + self, location: str, body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def post( + self, location: str, body: Optional[Union[_models.CheckNameAvailabilityModel, IO[bytes]]] = None, **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Is either a CheckNameAvailabilityModel type or a IO[bytes] type. + Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel or + IO[bytes] + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResponseModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "CheckNameAvailabilityModel") + else: + _json = None + + _request = build_post_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResponseModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_deployment_preflight_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_deployment_preflight_operations.py new file mode 100644 index 000000000000..fad44dc97c4c --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_deployment_preflight_operations.py @@ -0,0 +1,196 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._deployment_preflight_operations import build_post_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeploymentPreflightOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`deployment_preflight` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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") + + @overload + async def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[_models.DeploymentPreflightModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[Union[_models.DeploymentPreflightModel, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Is either a DeploymentPreflightModel type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel or + IO[bytes] + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeploymentPreflightModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "DeploymentPreflightModel") + else: + _json = None + + _request = build_post_request( + resource_group_name=resource_group_name, + deployment_id=deployment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentPreflightModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operation_status_operations.py deleted file mode 100644 index 99b0411f7874..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operation_status_operations.py +++ /dev/null @@ -1,125 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dra_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DraOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`dra_operation_status` attribute. - """ - - models = _models - - 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the fabric agent (Dra) operation status. - - Tracks the results of an asynchronous operation on the fabric agent. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. - :type fabric_agent_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - fabric_name=fabric_name, - fabric_agent_name=fabric_agent_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_email_configuration_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_email_configuration_operations.py index bcbfdc655e7d..37fa9983b8b3 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_email_configuration_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_email_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,12 @@ # Code generated by Microsoft (R) AutoRest 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 from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,17 +22,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._email_configuration_operations import build_create_request, build_get_request, build_list_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,18 +51,104 @@ class EmailConfigurationOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EmailConfigurationModel"]: + """Gets the list of alert configuration settings for the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either EmailConfigurationModel or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EmailConfigurationModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EmailConfigurationModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, email_configuration_name: str, **kwargs: Any ) -> _models.EmailConfigurationModel: - """Gets the email configuration setting. - - Gets the details of the alert configuration setting. + """Gets the details of the alert configuration setting. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -70,12 +157,11 @@ async def get( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,22 +175,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EmailConfigurationModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, email_configuration_name=email_configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,16 +198,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) + deserialized = self._deserialize("EmailConfigurationModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" - } + return deserialized # type: ignore @overload async def create( @@ -131,14 +211,12 @@ async def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[_models.EmailConfigurationModel] = None, + body: _models.EmailConfigurationModel, *, content_type: str = "application/json", **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -147,12 +225,11 @@ async def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Default value is None. + :param body: EmailConfiguration model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: @@ -164,14 +241,12 @@ async def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -180,12 +255,11 @@ async def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Default value is None. - :type body: IO + :param body: EmailConfiguration model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: @@ -197,12 +271,10 @@ async def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[Union[_models.EmailConfigurationModel, IO]] = None, + body: Union[_models.EmailConfigurationModel, IO[bytes]], **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -211,18 +283,15 @@ async def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Is either a EmailConfigurationModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: EmailConfiguration model. Is either a EmailConfigurationModel type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel or + IO[bytes] :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,12 +312,9 @@ async def create( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "EmailConfigurationModel") - else: - _json = None + _json = self._serialize.body(body, "EmailConfigurationModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, email_configuration_name=email_configuration_name, @@ -257,16 +323,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,113 +340,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) + deserialized = self._deserialize("EmailConfigurationModel", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" - } - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EmailConfigurationModel"]: - """Lists the email configuration settings. - - Gets the list of alert configuration settings for the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EmailConfigurationModel or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EmailConfigurationModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EmailConfigurationModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_event_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_event_operations.py index 28eefb8c6b29..ed0164d5b611 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_event_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_event_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,17 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._event_operations import build_get_request, build_list_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,104 +49,36 @@ class EventOperations: 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, vault_name: str, event_name: str, **kwargs: Any - ) -> _models.EventModel: - """Gets the event. - - Gets the details of the event. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param event_name: The event name. Required. - :type event_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EventModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EventModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - event_name=event_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("EventModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events/{eventName}" - } + 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, resource_group_name: str, vault_name: str, - filter: Optional[str] = None, + odata_options: Optional[str] = None, continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, **kwargs: Any ) -> AsyncIterable["_models.EventModel"]: - """Lists the events. - - Gets the list of events in the given vault. + """Gets the list of events in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param filter: Filter string. Default value is None. - :type filter: str + :param odata_options: OData options. Default value is None. + :type odata_options: str :param continuation_token_parameter: Continuation token. Default value is None. :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param page_size: Page size. Default value is None. + :type page_size: int :return: An iterator like instance of either EventModel or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] @@ -156,9 +88,9 @@ def list( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EventModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.EventModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,19 +101,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, - filter=filter, + odata_options=odata_options, continuation_token_parameter=continuation_token_parameter, + page_size=page_size, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -193,27 +124,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("EventModelCollection", pipeline_response) + deserialized = self._deserialize("EventModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,6 +156,63 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events" - } + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, event_name: str, **kwargs: Any + ) -> _models.EventModel: + """Gets the details of the event. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param event_name: The event name. Required. + :type event_name: str + :return: EventModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EventModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EventModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + event_name=event_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_agent_operations.py similarity index 62% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_agent_operations.py index 159eba321204..7fc73951e627 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_dra_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_agent_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,59 +32,143 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request -from ...operations._dra_operations import ( +from ..._utils.serialization import Deserializer, Serializer +from ...operations._fabric_agent_operations import ( build_create_request, build_delete_request, build_get_request, build_list_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DraOperations: +class FabricAgentOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`dra` attribute. + :attr:`fabric_agent` attribute. """ models = _models 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, fabric_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FabricAgentModel"]: + """Gets the list of fabric agents in the given fabric. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param fabric_name: The fabric name. Required. + :type fabric_name: str + :return: An iterator like instance of either FabricAgentModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricAgentModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + fabric_name=fabric_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FabricAgentModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any - ) -> _models.DraModel: - """Gets the fabric agent (Dra). - - Gets the details of the fabric agent. + ) -> _models.FabricAgentModel: + """Gets the details of the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DraModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel + :return: FabricAgentModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,24 +180,22 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[_models.FabricAgentModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,26 +205,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DraModel", pipeline_response) + deserialized = self._deserialize("FabricAgentModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[Union[_models.DraModel, IO]] = None, + body: Union[_models.FabricAgentModel, IO[bytes]], **kwargs: Any - ) -> _models.DraModel: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,7 +233,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -161,12 +241,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "DraModel") - else: - _json = None + _json = self._serialize.body(body, "FabricAgentModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, @@ -175,79 +252,71 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DraModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("DraModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } - @overload async def begin_create( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[_models.DraModel] = None, + body: _models.FabricAgentModel, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> AsyncLROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel + :param body: Fabric agent model. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DraModel or the result of + :return: An instance of AsyncLROPoller that returns either FabricAgentModel or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -257,39 +326,29 @@ async def begin_create( resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> AsyncLROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Default value is None. - :type body: IO + :param body: Fabric agent model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DraModel or the result of + :return: An instance of AsyncLROPoller that returns either FabricAgentModel or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -299,37 +358,25 @@ async def begin_create( resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[Union[_models.DraModel, IO]] = None, + body: Union[_models.FabricAgentModel, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> AsyncLROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Is either a DraModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DraModel or the result of + :param body: Fabric agent model. Is either a FabricAgentModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel or IO[bytes] + :return: An instance of AsyncLROPoller that returns either FabricAgentModel or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -337,7 +384,7 @@ async def begin_create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[_models.FabricAgentModel] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -354,39 +401,39 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DraModel", pipeline_response) + deserialized = self._deserialize("FabricAgentModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.FabricAgentModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return AsyncLROPoller[_models.FabricAgentModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,70 +445,61 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes the fabric agent (Dra). - - Deletes the fabric agent. + """Deletes fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -475,7 +513,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, @@ -485,11 +523,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -500,107 +539,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } - - @distributed_trace - def list(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> AsyncIterable["_models.DraModel"]: - """Lists the fabric agents (Dras). - - Gets the list of fabric agents in the given fabric. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DraModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DraModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - fabric_name=fabric_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DraModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations.py index e30be8684020..3b640e8a00d2 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._fabric_operations import ( build_create_request, build_delete_request, @@ -39,7 +41,7 @@ build_list_request, build_update_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,28 +61,189 @@ class FabricOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.FabricModel"]: + """Gets the list of fabrics in the given subscription. + + :return: An iterator like instance of either FabricModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricModelListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FabricModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.FabricModel"]: + """Gets the list of fabrics in the given subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param continuation_token_parameter: Continuation token from the previous call. Default value + is None. + :type continuation_token_parameter: str + :return: An iterator like instance of either FabricModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FabricModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> _models.FabricModel: - """Gets the fabric. - - Gets the details of the fabric. + """Gets the details of the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FabricModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,21 +257,19 @@ async def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FabricModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,25 +279,17 @@ async def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore async def _create_initial( - self, - resource_group_name: str, - fabric_name: str, - body: Optional[Union[_models.FabricModel, IO]] = None, - **kwargs: Any - ) -> _models.FabricModel: - error_map = { + self, resource_group_name: str, fabric_name: str, body: Union[_models.FabricModel, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +302,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FabricModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -157,12 +310,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "FabricModel") - else: - _json = None + _json = self._serialize.body(body, "FabricModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, @@ -170,72 +320,64 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("FabricModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("FabricModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } - @overload async def begin_create( self, resource_group_name: str, fabric_name: str, - body: Optional[_models.FabricModel] = None, + body: _models.FabricModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. + :param body: Fabric properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -248,33 +390,23 @@ async def begin_create( self, resource_group_name: str, fabric_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. - :type body: IO + :param body: Fabric properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -284,35 +416,17 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, - resource_group_name: str, - fabric_name: str, - body: Optional[Union[_models.FabricModel, IO]] = None, - **kwargs: Any + self, resource_group_name: str, fabric_name: str, body: Union[_models.FabricModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Is either a FabricModel type or a IO type. Default value is - None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Fabric properties. Is either a FabricModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -340,43 +454,43 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.FabricModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return AsyncLROPoller[_models.FabricModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, fabric_name: str, - body: Optional[Union[_models.FabricModelUpdate, IO]] = None, + body: Union[_models.FabricModelUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.FabricModel]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,7 +503,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FabricModel]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -397,12 +511,9 @@ async def _update_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "FabricModelUpdate") - else: - _json = None + _json = self._serialize.body(body, "FabricModelUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, @@ -410,77 +521,62 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("FabricModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore @overload async def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[_models.FabricModelUpdate] = None, + body: _models.FabricModelUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. + :param body: Fabric properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -493,33 +589,23 @@ async def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. - :type body: IO + :param body: Fabric properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -532,32 +618,19 @@ async def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[Union[_models.FabricModelUpdate, IO]] = None, + body: Union[_models.FabricModelUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Is either a FabricModelUpdate type or a IO type. Default value - is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Fabric properties. Is either a FabricModelUpdate type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -585,12 +658,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -602,22 +676,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.FabricModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return AsyncLROPoller[_models.FabricModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, fabric_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,65 +699,56 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes the fabric. - - Removes the fabric. + """Removes the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -701,7 +762,7 @@ async def begin_delete(self, resource_group_name: str, fabric_name: str, **kwarg lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, fabric_name=fabric_name, api_version=api_version, @@ -710,11 +771,12 @@ async def begin_delete(self, resource_group_name: str, fabric_name: str, **kwarg params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -725,202 +787,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } - - @distributed_trace - def list_by_subscription( - self, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FabricModel"]: - """Lists the fabrics. - - Gets the list of fabrics in the given subscription. - - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FabricModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FabricModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_by_subscription_request( - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("FabricModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationFabrics" - } - - @distributed_trace - def list( - self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FabricModel"]: - """Lists the fabrics. - - Gets the list of fabrics in the given subscription and resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FabricModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FabricModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("FabricModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_job_operations.py similarity index 66% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_job_operations.py index eb027288f4e5..f34cdf1c9b6e 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_job_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,146 +20,77 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._workflow_operations import build_get_request, build_list_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from ..._utils.serialization import Deserializer, Serializer +from ...operations._job_operations import build_get_request, build_list_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkflowOperations: +class JobOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`workflow` attribute. + :attr:`job` attribute. """ models = _models 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, vault_name: str, job_name: str, **kwargs: Any - ) -> _models.WorkflowModel: - """Gets the job (workflow). - - Gets the details of the job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param job_name: The job (workflow) name. Required. - :type job_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkflowModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WorkflowModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - - 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkflowModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}" - } + 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, resource_group_name: str, vault_name: str, - filter: Optional[str] = None, + odata_options: Optional[str] = None, continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.WorkflowModel"]: - """Lists the jobs (workflows). - - Gets the list of jobs in the given vault. + ) -> AsyncIterable["_models.JobModel"]: + """Gets the list of jobs in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param filter: Filter string. Default value is None. - :type filter: str + :param odata_options: OData options. Default value is None. + :type odata_options: str :param continuation_token_parameter: Continuation token. Default value is None. :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkflowModel or the result of cls(response) + :param page_size: Page size. Default value is None. + :type page_size: int + :return: An iterator like instance of either JobModel or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WorkflowModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.JobModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,19 +101,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, - filter=filter, + odata_options=odata_options, continuation_token_parameter=continuation_token_parameter, + page_size=page_size, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -193,27 +124,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("WorkflowModelCollection", pipeline_response) + deserialized = self._deserialize("JobModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,6 +156,61 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs" - } + @distributed_trace_async + async def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs: Any) -> _models.JobModel: + """Gets the details of the job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param job_name: The job name. Required. + :type job_name: str + :return: JobModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.JobModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_location_based_operation_results_operations.py similarity index 66% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operation_status_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_location_based_operation_results_operations.py index 6a016515a96e..f212e42ed744 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operation_status_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_location_based_operation_results_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,61 +18,61 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._vault_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from ..._utils.serialization import Deserializer, Serializer +from ...operations._location_based_operation_results_operations import build_get_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VaultOperationStatusOperations: +class LocationBasedOperationResultsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`vault_operation_status` attribute. + :attr:`location_based_operation_results` attribute. """ models = _models 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, vault_name: str, operation_id: str, **kwargs: Any + self, resource_group_name: str, location: str, operation_id: str, **kwargs: Any ) -> _models.OperationStatus: - """Gets the vault operation status. + """Gets the location based operation result status. - Tracks the results of an asynchronous operation on the vault. + Gets the location based operation result. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,22 +86,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, - vault_name=vault_name, + location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,13 +109,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operation_results_operations.py similarity index 65% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations_status_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operation_results_operations.py index a8b6a54f0e07..a1062a1e465f 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_fabric_operations_status_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operation_results_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,61 +18,57 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._fabric_operations_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operation_results_operations import build_get_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class FabricOperationsStatusOperations: +class OperationResultsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`fabric_operations_status` attribute. + :attr:`operation_results` attribute. """ models = _models 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, fabric_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the fabric operation status. + async def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _models.OperationStatus: + """Gets the operation result status. - Tracks the results of an asynchronous operation on the fabric. + Gets the operations. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,22 +82,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, - fabric_name=fabric_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,13 +104,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operations.py index e01988b7520d..23a48d122245 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,18 +48,17 @@ 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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"]: - """Get a list of REST API operations supported by Microsoft.DataReplication. + """List the operations for the provider. - Gets the operations. - - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.Operation] @@ -71,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +81,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,13 +98,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -117,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DataReplication/operations"} diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operation_status_operations.py deleted file mode 100644 index 2b4d56303f6c..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operation_status_operations.py +++ /dev/null @@ -1,125 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._policy_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolicyOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`policy_operation_status` attribute. - """ - - models = _models - - 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, vault_name: str, policy_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the policy operation status. - - Tracks the results of an asynchronous operation on the policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param policy_name: The policy name. Required. - :type policy_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - policy_name=policy_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operations.py index 86416da04dff..cd23a1712db5 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_policy_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,14 +32,14 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_operations import ( build_create_request, build_delete_request, build_get_request, build_list_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,18 +59,101 @@ class PolicyOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncIterable["_models.PolicyModel"]: + """Gets the list of policies in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PolicyModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any ) -> _models.PolicyModel: - """Gets the policy. - - Gets the details of the policy. + """Gets the details of the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -77,12 +162,11 @@ async def get( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +180,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,26 +203,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyModel", pipeline_response) + deserialized = self._deserialize("PolicyModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[Union[_models.PolicyModel, IO]] = None, + body: Union[_models.PolicyModel, IO[bytes]], **kwargs: Any - ) -> _models.PolicyModel: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,7 +231,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -161,12 +239,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "PolicyModel") - else: - _json = None + _json = self._serialize.body(body, "PolicyModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, @@ -175,54 +250,54 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PolicyModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("PolicyModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } - @overload async def begin_create( self, resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[_models.PolicyModel] = None, + body: _models.PolicyModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -231,19 +306,11 @@ async def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Default value is None. + :param body: Policy model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -257,14 +324,12 @@ async def begin_create( resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -273,19 +338,11 @@ async def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Default value is None. - :type body: IO + :param body: Policy model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -299,12 +356,10 @@ async def begin_create( resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[Union[_models.PolicyModel, IO]] = None, + body: Union[_models.PolicyModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -313,19 +368,8 @@ async def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Is either a PolicyModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Policy model. Is either a PolicyModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -354,39 +398,39 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PolicyModel", pipeline_response) + deserialized = self._deserialize("PolicyModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PolicyModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return AsyncLROPoller[_models.PolicyModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,54 +442,53 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes the policy. - - Removes the policy. + """Removes the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -454,14 +497,6 @@ async def begin_delete( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -475,7 +510,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, @@ -485,11 +520,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -500,107 +536,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } - - @distributed_trace - def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncIterable["_models.PolicyModel"]: - """Lists the policies. - - Gets the list of policies in the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PolicyModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connection_proxies_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connection_proxies_operations.py new file mode 100644 index 000000000000..c59545e27843 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connection_proxies_operations.py @@ -0,0 +1,628 @@ +# 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) AutoRest 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 +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._private_endpoint_connection_proxies_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionProxiesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_endpoint_connection_proxies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnectionProxy"]: + """Gets the all private endpoint connections proxies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateEndpointConnectionProxy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionProxyListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionProxyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Gets the private endpoint connection proxy details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: _models.PrivateEndpointConnectionProxy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: Union[_models.PrivateEndpointConnectionProxy, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Is either a + PrivateEndpointConnectionProxy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + or IO[bytes] + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnectionProxy") + + _request = build_create_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Returns the operation to track the deletion of private endpoint connection proxy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: _models.PrivateEndpointConnectionProxy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: Union[_models.PrivateEndpointConnectionProxy, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Is either a + PrivateEndpointConnectionProxy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + or IO[bytes] + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnectionProxy") + + _request = build_validate_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connections_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..0975c327fdb3 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,477 @@ +# 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) AutoRest 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 +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """Gets the all private endpoint connections configured on the vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the private endpoint connection details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Is either a PrivateEndpointConnection + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection or + IO[bytes] + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnection") + + _request = build_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_link_resources_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..7ecf228e0939 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,203 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._private_link_resources_operations import build_get_request, build_list_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Gets the list of private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, vault_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the details of site recovery private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_link_resource_name: The private link name. Required. + :type private_link_resource_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operation_status_operations.py deleted file mode 100644 index 02a64e0f98dc..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operation_status_operations.py +++ /dev/null @@ -1,125 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._protected_item_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProtectedItemOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`protected_item_operation_status` attribute. - """ - - models = _models - - 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, vault_name: str, protected_item_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the protected item operation status. - - Tracks the results of an asynchronous operation on the protected item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param protected_item_name: The protected item name. Required. - :type protected_item_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - protected_item_name=protected_item_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operations.py index 686a4f75940f..99cd3db9b0b1 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_protected_item_operations.py @@ -6,10 +6,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,15 +33,16 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._protected_item_operations import ( build_create_request, build_delete_request, build_get_request, build_list_request, build_planned_failover_request, + build_update_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,18 +62,118 @@ class ProtectedItemOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, + resource_group_name: str, + vault_name: str, + odata_options: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProtectedItemModel"]: + """Gets the list of protected items in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param odata_options: OData options. Default value is None. + :type odata_options: str + :param continuation_token_parameter: Continuation token. Default value is None. + :type continuation_token_parameter: str + :param page_size: Page size. Default value is None. + :type page_size: int + :return: An iterator like instance of either ProtectedItemModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProtectedItemModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + odata_options=odata_options, + continuation_token_parameter=continuation_token_parameter, + page_size=page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProtectedItemModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, protected_item_name: str, **kwargs: Any ) -> _models.ProtectedItemModel: - """Gets the protected item. - - Gets the details of the protected item. + """Gets the details of the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -78,12 +182,11 @@ async def get( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProtectedItemModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,22 +200,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -122,26 +223,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.ProtectedItemModel, IO]] = None, + body: Union[_models.ProtectedItemModel, IO[bytes]], **kwargs: Any - ) -> _models.ProtectedItemModel: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,7 +251,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -162,12 +259,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "ProtectedItemModel") - else: - _json = None + _json = self._serialize.body(body, "ProtectedItemModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, @@ -176,54 +270,54 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } - @overload async def begin_create( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[_models.ProtectedItemModel] = None, + body: _models.ProtectedItemModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -232,19 +326,11 @@ async def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Default value is None. + :param body: Protected item model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -258,14 +344,12 @@ async def begin_create( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -274,19 +358,11 @@ async def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Default value is None. - :type body: IO + :param body: Protected item model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -300,12 +376,10 @@ async def begin_create( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.ProtectedItemModel, IO]] = None, + body: Union[_models.ProtectedItemModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -314,20 +388,9 @@ async def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Is either a ProtectedItemModel type or a IO type. Default - value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Protected item model. Is either a ProtectedItemModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -356,44 +419,44 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ProtectedItemModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return AsyncLROPoller[_models.ProtectedItemModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _update_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - force_delete: Optional[bool] = None, + body: Union[_models.ProtectedItemModelUpdate, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -401,64 +464,108 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ProtectedItemModelUpdate") + + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, - force_delete=force_delete, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return deserialized # type: ignore - @distributed_trace_async - async def begin_delete( + @overload + async def begin_update( self, resource_group_name: str, vault_name: str, protected_item_name: str, - force_delete: Optional[bool] = None, + body: _models.ProtectedItemModelUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the protected item. + ) -> AsyncLROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param body: Protected item model. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ - Removes the protected item. + @overload + async def begin_update( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -467,46 +574,76 @@ async def begin_delete( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param force_delete: A flag indicating whether to do force delete or not. Default value is - None. - :type force_delete: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param body: Protected item model. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + body: Union[_models.ProtectedItemModelUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param body: Protected item model. Is either a ProtectedItemModelUpdate type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelUpdate or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, - force_delete=force_delete, + body=body, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( @@ -517,122 +654,157 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ProtectedItemModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.ProtectedItemModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProtectedItemModel"]: - """Lists the protected items. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore - Gets the list of protected items in the given vault. + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProtectedItemModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param force_delete: A flag indicating whether to do force delete or not. Default value is + None. + :type force_delete: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProtectedItemModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + force_delete=force_delete, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProtectedItemModelCollection", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems" - } + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _planned_failover_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.PlannedFailoverModel, IO]] = None, + body: Union[_models.PlannedFailoverModel, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PlannedFailoverModel]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -645,7 +817,7 @@ async def _planned_failover_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PlannedFailoverModel]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -653,12 +825,9 @@ async def _planned_failover_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "PlannedFailoverModel") - else: - _json = None + _json = self._serialize.body(body, "PlannedFailoverModel") - request = build_planned_failover_request( + _request = build_planned_failover_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, @@ -667,44 +836,39 @@ async def _planned_failover_initial( content_type=content_type, json=_json, content=_content, - template_url=self._planned_failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("PlannedFailoverModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _planned_failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover" - } + return deserialized # type: ignore @overload async def begin_planned_failover( @@ -712,14 +876,12 @@ async def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[_models.PlannedFailoverModel] = None, + body: _models.PlannedFailoverModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -728,19 +890,11 @@ async def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Default value is None. + :param body: Planned failover model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -754,14 +908,12 @@ async def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -770,19 +922,11 @@ async def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Default value is None. - :type body: IO + :param body: Planned failover model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -796,12 +940,10 @@ async def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.PlannedFailoverModel, IO]] = None, + body: Union[_models.PlannedFailoverModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -810,20 +952,10 @@ async def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Is either a PlannedFailoverModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Planned failover model. Is either a PlannedFailoverModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel or + IO[bytes] :return: An instance of AsyncLROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -852,12 +984,13 @@ async def begin_planned_failover( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PlannedFailoverModel", pipeline_response) + deserialized = self._deserialize("PlannedFailoverModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -869,14 +1002,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PlannedFailoverModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_planned_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover" - } + return AsyncLROPoller[_models.PlannedFailoverModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_points_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_point_operations.py similarity index 73% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_points_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_point_operations.py index e2fc1ca05662..8a07f3b059fe 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_points_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_point_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,126 +20,47 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._recovery_points_operations import build_get_request, build_list_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from ..._utils.serialization import Deserializer, Serializer +from ...operations._recovery_point_operations import build_get_request, build_list_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RecoveryPointsOperations: +class RecoveryPointOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`recovery_points` attribute. + :attr:`recovery_point` attribute. """ models = _models 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") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vault_name: str, - protected_item_name: str, - recovery_point_name: str, - **kwargs: Any - ) -> _models.RecoveryPointModel: - """Gets the recovery point. - - Gets the details of the recovery point of a protected item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param protected_item_name: The protected item name. Required. - :type protected_item_name: str - :param recovery_point_name: The recovery point name. Required. - :type recovery_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecoveryPointModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RecoveryPointModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - protected_item_name=protected_item_name, - recovery_point_name=recovery_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryPointModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointName}" - } + 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, resource_group_name: str, vault_name: str, protected_item_name: str, **kwargs: Any ) -> AsyncIterable["_models.RecoveryPointModel"]: - """Lists the recovery points. - - Gets the list of recovery points of the given protected item. + """Gets the list of recovery points of the given protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -147,7 +69,6 @@ def list( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecoveryPointModel or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel] @@ -157,9 +78,9 @@ def list( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RecoveryPointModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.RecoveryPointModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,18 +91,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -193,27 +112,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("RecoveryPointModelCollection", pipeline_response) + deserialized = self._deserialize("RecoveryPointModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,6 +144,71 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints" - } + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + recovery_point_name: str, + **kwargs: Any + ) -> _models.RecoveryPointModel: + """Gets the details of the recovery point of a protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param recovery_point_name: The recovery point name. Required. + :type recovery_point_name: str + :return: RecoveryPointModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecoveryPointModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + recovery_point_name=recovery_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecoveryPointModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_services_data_replication_mgmt_client_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_services_data_replication_mgmt_client_operations.py deleted file mode 100644 index ed6e8da6ad7a..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_recovery_services_data_replication_mgmt_client_operations.py +++ /dev/null @@ -1,321 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._recovery_services_data_replication_mgmt_client_operations import ( - build_check_name_availability_request, - build_deployment_preflight_request, -) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RecoveryServicesDataReplicationMgmtClientOperationsMixin(RecoveryServicesDataReplicationMgmtClientMixinABC): - @overload - async def check_name_availability( - self, - location: str, - body: Optional[_models.CheckNameAvailabilityModel] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, location: str, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, location: str, body: Optional[Union[_models.CheckNameAvailabilityModel, IO]] = None, **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Is either a CheckNameAvailabilityModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameAvailabilityResponseModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "CheckNameAvailabilityModel") - else: - _json = None - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResponseModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/locations/{location}/checkNameAvailability" - } - - @overload - async def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[_models.DeploymentPreflightModel] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[Union[_models.DeploymentPreflightModel, IO]] = None, - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Is either a DeploymentPreflightModel type or a IO - type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DeploymentPreflightModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DeploymentPreflightModel") - else: - _json = None - - request = build_deployment_preflight_request( - resource_group_name=resource_group_name, - deployment_id=deployment_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.deployment_preflight.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeploymentPreflightModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - deployment_preflight.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/deployments/{deploymentId}/preflight" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operation_status_operations.py deleted file mode 100644 index 016d75f382cd..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operation_status_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._replication_extension_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ReplicationExtensionOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`replication_extension_operation_status` attribute. - """ - - models = _models - - 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") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vault_name: str, - replication_extension_name: str, - operation_id: str, - **kwargs: Any - ) -> _models.OperationStatus: - """Gets the replication extension operation status. - - Tracks the results of an asynchronous operation on the replication extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param replication_extension_name: The replication extension name. Required. - :type replication_extension_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - replication_extension_name=replication_extension_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operations.py index 22740fb50191..af48b6afed73 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_replication_extension_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,14 +33,14 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._replication_extension_operations import ( build_create_request, build_delete_request, build_get_request, build_list_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,18 +60,104 @@ class ReplicationExtensionOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ReplicationExtensionModel"]: + """Gets the list of replication extensions in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either ReplicationExtensionModel or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ReplicationExtensionModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationExtensionModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any ) -> _models.ReplicationExtensionModel: - """Gets the replication extension. - - Gets the details of the replication extension. + """Gets the details of the replication extension. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -77,12 +166,11 @@ async def get( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationExtensionModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +184,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationExtensionModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,26 +207,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[Union[_models.ReplicationExtensionModel, IO]] = None, + body: Union[_models.ReplicationExtensionModel, IO[bytes]], **kwargs: Any - ) -> _models.ReplicationExtensionModel: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,7 +235,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ReplicationExtensionModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -161,12 +243,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "ReplicationExtensionModel") - else: - _json = None + _json = self._serialize.body(body, "ReplicationExtensionModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, @@ -175,54 +254,54 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } - @overload async def begin_create( self, resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[_models.ReplicationExtensionModel] = None, + body: _models.ReplicationExtensionModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -231,19 +310,11 @@ async def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Default value is None. + :param body: Replication extension model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -257,14 +328,12 @@ async def begin_create( resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -273,19 +342,11 @@ async def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Default value is None. - :type body: IO + :param body: Replication extension model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -299,12 +360,10 @@ async def begin_create( resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[Union[_models.ReplicationExtensionModel, IO]] = None, + body: Union[_models.ReplicationExtensionModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -313,20 +372,10 @@ async def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Is either a ReplicationExtensionModel type or a IO - type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Replication extension model. Is either a ReplicationExtensionModel type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel or + IO[bytes] :return: An instance of AsyncLROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -355,39 +404,39 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ReplicationExtensionModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return AsyncLROPoller[_models.ReplicationExtensionModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,54 +448,53 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes the replication extension. - - Deletes the replication extension in the given vault. + """Deletes the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -455,14 +503,6 @@ async def begin_delete( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +516,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, @@ -486,11 +526,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -501,110 +542,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ReplicationExtensionModel"]: - """Lists the replication extensions. - - Gets the list of replication extensions in the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationExtensionModel or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ReplicationExtensionModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationExtensionModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operations.py index 213327ddc32f..c7caa0d7a393 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_vault_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,12 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._vault_operations import ( build_create_request, build_delete_request, @@ -39,7 +41,7 @@ build_list_request, build_update_request, ) -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,28 +61,189 @@ class VaultOperations: 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.VaultModel"]: + """Gets the list of vaults in the given subscription. + + :return: An iterator like instance of either VaultModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VaultModelListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VaultModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.VaultModel"]: + """Gets the list of vaults in the given subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param continuation_token_parameter: Continuation token from the previous call. Default value + is None. + :type continuation_token_parameter: str + :return: An iterator like instance of either VaultModel or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VaultModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VaultModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.VaultModel: - """Gets the vault. - - Gets the details of the vault. + """Gets the details of the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VaultModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,21 +257,19 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VaultModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,25 +279,17 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore async def _create_initial( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModel, IO]] = None, - **kwargs: Any - ) -> _models.VaultModel: - error_map = { + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModel, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +302,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VaultModel] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -157,12 +310,9 @@ async def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "VaultModel") - else: - _json = None + _json = self._serialize.body(body, "VaultModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -170,72 +320,64 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VaultModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("VaultModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } - @overload async def begin_create( self, resource_group_name: str, vault_name: str, - body: Optional[_models.VaultModel] = None, + body: _models.VaultModel, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. + :param body: Vault properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -248,33 +390,23 @@ async def begin_create( self, resource_group_name: str, vault_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. - :type body: IO + :param body: Vault properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -284,34 +416,17 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModel, IO]] = None, - **kwargs: Any + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Is either a VaultModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Vault properties. Is either a VaultModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -339,43 +454,39 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VaultModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return AsyncLROPoller[_models.VaultModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModelUpdate, IO]] = None, - **kwargs: Any - ) -> Optional[_models.VaultModel]: - error_map = { + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModelUpdate, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +499,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VaultModel]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -396,12 +507,9 @@ async def _update_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "VaultModelUpdate") - else: - _json = None + _json = self._serialize.body(body, "VaultModelUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -409,77 +517,62 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VaultModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore @overload async def begin_update( self, resource_group_name: str, vault_name: str, - body: Optional[_models.VaultModelUpdate] = None, + body: _models.VaultModelUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. + :param body: Vault properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -492,33 +585,23 @@ async def begin_update( self, resource_group_name: str, vault_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. - :type body: IO + :param body: Vault properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -528,35 +611,17 @@ async def begin_update( @distributed_trace_async async def begin_update( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModelUpdate, IO]] = None, - **kwargs: Any + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModelUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Is either a VaultModelUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Vault properties. Is either a VaultModelUpdate type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either VaultModel or the result of cls(response) :rtype: @@ -584,12 +649,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -601,22 +667,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VaultModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return AsyncLROPoller[_models.VaultModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,65 +690,56 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes the vault. - - Removes the vault. + """Removes the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -700,7 +753,7 @@ async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -709,11 +762,12 @@ async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -724,202 +778,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } - - @distributed_trace - def list_by_subscription( - self, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VaultModel"]: - """Lists the vaults. - - Gets the list of vaults in the given subscription. - - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VaultModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VaultModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_by_subscription_request( - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VaultModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationVaults" - } - - @distributed_trace - def list( - self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VaultModel"]: - """Lists the vaults. - - Gets the list of vaults in the given subscription and resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VaultModel or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VaultModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VaultModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operation_status_operations.py deleted file mode 100644 index 01b711e0f5c2..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/aio/operations/_workflow_operation_status_operations.py +++ /dev/null @@ -1,125 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._workflow_operation_status_operations import build_get_request -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class WorkflowOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.aio.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`workflow_operation_status` attribute. - """ - - models = _models - - 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") - - @distributed_trace_async - async def get( - self, resource_group_name: str, vault_name: str, job_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the job (workflow) operation status. - - Tracks the results of an asynchronous operation on the job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param job_name: The job (workflow) name. Required. - :type job_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - job_name=job_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/__init__.py index 522d9fad6e96..9eb0acf3526a 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/__init__.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/__init__.py @@ -5,135 +5,163 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AzStackHCIClusterProperties -from ._models_py3 import AzStackHCIFabricModelCustomProperties -from ._models_py3 import CheckNameAvailabilityModel -from ._models_py3 import CheckNameAvailabilityResponseModel -from ._models_py3 import DeploymentPreflightModel -from ._models_py3 import DeploymentPreflightResource -from ._models_py3 import DraModel -from ._models_py3 import DraModelCollection -from ._models_py3 import DraModelCustomProperties -from ._models_py3 import DraModelProperties -from ._models_py3 import DraModelSystemData -from ._models_py3 import EmailConfigurationModel -from ._models_py3 import EmailConfigurationModelCollection -from ._models_py3 import EmailConfigurationModelProperties -from ._models_py3 import EmailConfigurationModelSystemData -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorModel -from ._models_py3 import ErrorResponse -from ._models_py3 import EventModel -from ._models_py3 import EventModelCollection -from ._models_py3 import EventModelCustomProperties -from ._models_py3 import EventModelProperties -from ._models_py3 import EventModelSystemData -from ._models_py3 import FabricModel -from ._models_py3 import FabricModelCollection -from ._models_py3 import FabricModelCustomProperties -from ._models_py3 import FabricModelProperties -from ._models_py3 import FabricModelSystemData -from ._models_py3 import FabricModelUpdate -from ._models_py3 import FabricModelUpdateSystemData -from ._models_py3 import FailoverProtectedItemProperties -from ._models_py3 import FailoverWorkflowModelCustomProperties -from ._models_py3 import HealthErrorModel -from ._models_py3 import HyperVMigrateFabricModelCustomProperties -from ._models_py3 import HyperVToAzStackHCIDiskInput -from ._models_py3 import HyperVToAzStackHCIEventModelCustomProperties -from ._models_py3 import HyperVToAzStackHCINicInput -from ._models_py3 import HyperVToAzStackHCIPlannedFailoverModelCustomProperties -from ._models_py3 import HyperVToAzStackHCIPolicyModelCustomProperties -from ._models_py3 import HyperVToAzStackHCIProtectedDiskProperties -from ._models_py3 import HyperVToAzStackHCIProtectedItemModelCustomProperties -from ._models_py3 import HyperVToAzStackHCIProtectedNicProperties -from ._models_py3 import HyperVToAzStackHCIRecoveryPointModelCustomProperties -from ._models_py3 import HyperVToAzStackHCIReplicationExtensionModelCustomProperties -from ._models_py3 import IdentityModel -from ._models_py3 import InnerHealthErrorModel -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import OperationModel -from ._models_py3 import OperationModelCollection -from ._models_py3 import OperationModelProperties -from ._models_py3 import OperationStatus -from ._models_py3 import PlannedFailoverModel -from ._models_py3 import PlannedFailoverModelCustomProperties -from ._models_py3 import PlannedFailoverModelProperties -from ._models_py3 import PolicyModel -from ._models_py3 import PolicyModelCollection -from ._models_py3 import PolicyModelCustomProperties -from ._models_py3 import PolicyModelProperties -from ._models_py3 import PolicyModelSystemData -from ._models_py3 import ProtectedItemDynamicMemoryConfig -from ._models_py3 import ProtectedItemJobProperties -from ._models_py3 import ProtectedItemModel -from ._models_py3 import ProtectedItemModelCollection -from ._models_py3 import ProtectedItemModelCustomProperties -from ._models_py3 import ProtectedItemModelProperties -from ._models_py3 import ProtectedItemModelPropertiesCurrentJob -from ._models_py3 import ProtectedItemModelPropertiesLastFailedEnableProtectionJob -from ._models_py3 import ProtectedItemModelPropertiesLastFailedPlannedFailoverJob -from ._models_py3 import ProtectedItemModelPropertiesLastTestFailoverJob -from ._models_py3 import ProtectedItemModelSystemData -from ._models_py3 import RecoveryPointModel -from ._models_py3 import RecoveryPointModelCollection -from ._models_py3 import RecoveryPointModelCustomProperties -from ._models_py3 import RecoveryPointModelProperties -from ._models_py3 import RecoveryPointModelSystemData -from ._models_py3 import ReplicationExtensionModel -from ._models_py3 import ReplicationExtensionModelCollection -from ._models_py3 import ReplicationExtensionModelCustomProperties -from ._models_py3 import ReplicationExtensionModelProperties -from ._models_py3 import ReplicationExtensionModelSystemData -from ._models_py3 import StorageContainerProperties -from ._models_py3 import SystemDataModel -from ._models_py3 import TaskModel -from ._models_py3 import TaskModelCustomProperties -from ._models_py3 import TestFailoverCleanupWorkflowModelCustomProperties -from ._models_py3 import TestFailoverWorkflowModelCustomProperties -from ._models_py3 import VMwareDraModelCustomProperties -from ._models_py3 import VMwareMigrateFabricModelCustomProperties -from ._models_py3 import VMwareToAzStackHCIDiskInput -from ._models_py3 import VMwareToAzStackHCINicInput -from ._models_py3 import VMwareToAzStackHCIPlannedFailoverModelCustomProperties -from ._models_py3 import VMwareToAzStackHCIPolicyModelCustomProperties -from ._models_py3 import VMwareToAzStackHCIProtectedDiskProperties -from ._models_py3 import VMwareToAzStackHCIProtectedItemModelCustomProperties -from ._models_py3 import VMwareToAzStackHCIProtectedNicProperties -from ._models_py3 import VMwareToAzStackHCIReplicationExtensionModelCustomProperties -from ._models_py3 import VaultModel -from ._models_py3 import VaultModelCollection -from ._models_py3 import VaultModelProperties -from ._models_py3 import VaultModelSystemData -from ._models_py3 import VaultModelUpdate -from ._models_py3 import VaultModelUpdateSystemData -from ._models_py3 import WorkflowModel -from ._models_py3 import WorkflowModelCollection -from ._models_py3 import WorkflowModelCustomProperties -from ._models_py3 import WorkflowModelProperties -from ._models_py3 import WorkflowModelSystemData +from typing import TYPE_CHECKING -from ._recovery_services_data_replication_mgmt_client_enums import ActionType -from ._recovery_services_data_replication_mgmt_client_enums import HealthStatus -from ._recovery_services_data_replication_mgmt_client_enums import Origin -from ._recovery_services_data_replication_mgmt_client_enums import ProtectedItemActiveLocation -from ._recovery_services_data_replication_mgmt_client_enums import ProtectionState -from ._recovery_services_data_replication_mgmt_client_enums import ProvisioningState -from ._recovery_services_data_replication_mgmt_client_enums import RecoveryPointType -from ._recovery_services_data_replication_mgmt_client_enums import ReplicationVaultType -from ._recovery_services_data_replication_mgmt_client_enums import ResynchronizationState -from ._recovery_services_data_replication_mgmt_client_enums import TaskState -from ._recovery_services_data_replication_mgmt_client_enums import TestFailoverState -from ._recovery_services_data_replication_mgmt_client_enums import VMNicSelection -from ._recovery_services_data_replication_mgmt_client_enums import VMwareToAzureMigrateResyncState -from ._recovery_services_data_replication_mgmt_client_enums import WorkflowObjectType -from ._recovery_services_data_replication_mgmt_client_enums import WorkflowState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AzStackHCIClusterProperties, + AzStackHCIFabricModelCustomProperties, + CheckNameAvailabilityModel, + CheckNameAvailabilityResponseModel, + ConnectionDetails, + DeploymentPreflightModel, + DeploymentPreflightResource, + DiskControllerInputs, + EmailConfigurationModel, + EmailConfigurationModelListResult, + EmailConfigurationModelProperties, + ErrorAdditionalInfo, + ErrorDetail, + ErrorModel, + ErrorResponse, + EventModel, + EventModelCustomProperties, + EventModelListResult, + EventModelProperties, + FabricAgentModel, + FabricAgentModelCustomProperties, + FabricAgentModelListResult, + FabricAgentModelProperties, + FabricModel, + FabricModelCustomProperties, + FabricModelListResult, + FabricModelProperties, + FabricModelUpdate, + FailoverJobModelCustomProperties, + FailoverProtectedItemProperties, + GroupConnectivityInformation, + HealthErrorModel, + HyperVMigrateFabricModelCustomProperties, + HyperVToAzStackHCIDiskInput, + HyperVToAzStackHCIEventModelCustomProperties, + HyperVToAzStackHCINicInput, + HyperVToAzStackHCIPlannedFailoverModelCustomProperties, + HyperVToAzStackHCIPolicyModelCustomProperties, + HyperVToAzStackHCIProtectedDiskProperties, + HyperVToAzStackHCIProtectedItemModelCustomProperties, + HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate, + HyperVToAzStackHCIProtectedNicProperties, + HyperVToAzStackHCIRecoveryPointModelCustomProperties, + HyperVToAzStackHCIReplicationExtensionModelCustomProperties, + IdentityModel, + InnerHealthErrorModel, + JobModel, + JobModelCustomProperties, + JobModelCustomPropertiesAffectedObjectDetails, + JobModelListResult, + JobModelProperties, + ManagedServiceIdentity, + Operation, + OperationDisplay, + OperationListResult, + OperationStatus, + PlannedFailoverModel, + PlannedFailoverModelCustomProperties, + PlannedFailoverModelProperties, + PolicyModel, + PolicyModelCustomProperties, + PolicyModelListResult, + PolicyModelProperties, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionListResult, + PrivateEndpointConnectionProxy, + PrivateEndpointConnectionProxyListResult, + PrivateEndpointConnectionProxyProperties, + PrivateEndpointConnectionResponseProperties, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkResourceProperties, + PrivateLinkServiceConnection, + PrivateLinkServiceConnectionState, + PrivateLinkServiceProxy, + ProtectedItemDynamicMemoryConfig, + ProtectedItemJobProperties, + ProtectedItemModel, + ProtectedItemModelCustomProperties, + ProtectedItemModelCustomPropertiesUpdate, + ProtectedItemModelListResult, + ProtectedItemModelProperties, + ProtectedItemModelPropertiesUpdate, + ProtectedItemModelUpdate, + ProxyResource, + RecoveryPointModel, + RecoveryPointModelCustomProperties, + RecoveryPointModelListResult, + RecoveryPointModelProperties, + RemotePrivateEndpoint, + RemotePrivateEndpointConnection, + ReplicationExtensionModel, + ReplicationExtensionModelCustomProperties, + ReplicationExtensionModelListResult, + ReplicationExtensionModelProperties, + Resource, + StorageContainerProperties, + SystemData, + TaskModel, + TaskModelCustomProperties, + TestFailoverCleanupJobModelCustomProperties, + TestFailoverJobModelCustomProperties, + TrackedResource, + UserAssignedIdentity, + VMwareFabricAgentModelCustomProperties, + VMwareMigrateFabricModelCustomProperties, + VMwareToAzStackHCIDiskInput, + VMwareToAzStackHCIEventModelCustomProperties, + VMwareToAzStackHCINicInput, + VMwareToAzStackHCIPlannedFailoverModelCustomProperties, + VMwareToAzStackHCIPolicyModelCustomProperties, + VMwareToAzStackHCIProtectedDiskProperties, + VMwareToAzStackHCIProtectedItemModelCustomProperties, + VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate, + VMwareToAzStackHCIProtectedNicProperties, + VMwareToAzStackHCIRecoveryPointModelCustomProperties, + VMwareToAzStackHCIReplicationExtensionModelCustomProperties, + VaultIdentityModel, + VaultModel, + VaultModelListResult, + VaultModelProperties, + VaultModelUpdate, +) + +from ._recovery_services_data_replication_mgmt_client_enums import ( # type: ignore + ActionType, + CreatedByType, + HealthStatus, + JobObjectType, + JobState, + ManagedServiceIdentityType, + Origin, + PrivateEndpointConnectionStatus, + ProtectedItemActiveLocation, + ProtectionState, + ProvisioningState, + RecoveryPointType, + ReplicationVaultType, + ResynchronizationState, + TaskState, + TestFailoverState, + VMNicSelection, + VMwareToAzureMigrateResyncState, + VaultIdentityType, +) 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__ = [ @@ -141,35 +169,33 @@ "AzStackHCIFabricModelCustomProperties", "CheckNameAvailabilityModel", "CheckNameAvailabilityResponseModel", + "ConnectionDetails", "DeploymentPreflightModel", "DeploymentPreflightResource", - "DraModel", - "DraModelCollection", - "DraModelCustomProperties", - "DraModelProperties", - "DraModelSystemData", + "DiskControllerInputs", "EmailConfigurationModel", - "EmailConfigurationModelCollection", + "EmailConfigurationModelListResult", "EmailConfigurationModelProperties", - "EmailConfigurationModelSystemData", "ErrorAdditionalInfo", "ErrorDetail", "ErrorModel", "ErrorResponse", "EventModel", - "EventModelCollection", "EventModelCustomProperties", + "EventModelListResult", "EventModelProperties", - "EventModelSystemData", + "FabricAgentModel", + "FabricAgentModelCustomProperties", + "FabricAgentModelListResult", + "FabricAgentModelProperties", "FabricModel", - "FabricModelCollection", "FabricModelCustomProperties", + "FabricModelListResult", "FabricModelProperties", - "FabricModelSystemData", "FabricModelUpdate", - "FabricModelUpdateSystemData", + "FailoverJobModelCustomProperties", "FailoverProtectedItemProperties", - "FailoverWorkflowModelCustomProperties", + "GroupConnectivityInformation", "HealthErrorModel", "HyperVMigrateFabricModelCustomProperties", "HyperVToAzStackHCIDiskInput", @@ -179,77 +205,97 @@ "HyperVToAzStackHCIPolicyModelCustomProperties", "HyperVToAzStackHCIProtectedDiskProperties", "HyperVToAzStackHCIProtectedItemModelCustomProperties", + "HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate", "HyperVToAzStackHCIProtectedNicProperties", "HyperVToAzStackHCIRecoveryPointModelCustomProperties", "HyperVToAzStackHCIReplicationExtensionModelCustomProperties", "IdentityModel", "InnerHealthErrorModel", + "JobModel", + "JobModelCustomProperties", + "JobModelCustomPropertiesAffectedObjectDetails", + "JobModelListResult", + "JobModelProperties", + "ManagedServiceIdentity", "Operation", "OperationDisplay", "OperationListResult", - "OperationModel", - "OperationModelCollection", - "OperationModelProperties", "OperationStatus", "PlannedFailoverModel", "PlannedFailoverModelCustomProperties", "PlannedFailoverModelProperties", "PolicyModel", - "PolicyModelCollection", "PolicyModelCustomProperties", + "PolicyModelListResult", "PolicyModelProperties", - "PolicyModelSystemData", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionProxy", + "PrivateEndpointConnectionProxyListResult", + "PrivateEndpointConnectionProxyProperties", + "PrivateEndpointConnectionResponseProperties", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", + "PrivateLinkServiceConnection", + "PrivateLinkServiceConnectionState", + "PrivateLinkServiceProxy", "ProtectedItemDynamicMemoryConfig", "ProtectedItemJobProperties", "ProtectedItemModel", - "ProtectedItemModelCollection", "ProtectedItemModelCustomProperties", + "ProtectedItemModelCustomPropertiesUpdate", + "ProtectedItemModelListResult", "ProtectedItemModelProperties", - "ProtectedItemModelPropertiesCurrentJob", - "ProtectedItemModelPropertiesLastFailedEnableProtectionJob", - "ProtectedItemModelPropertiesLastFailedPlannedFailoverJob", - "ProtectedItemModelPropertiesLastTestFailoverJob", - "ProtectedItemModelSystemData", + "ProtectedItemModelPropertiesUpdate", + "ProtectedItemModelUpdate", + "ProxyResource", "RecoveryPointModel", - "RecoveryPointModelCollection", "RecoveryPointModelCustomProperties", + "RecoveryPointModelListResult", "RecoveryPointModelProperties", - "RecoveryPointModelSystemData", + "RemotePrivateEndpoint", + "RemotePrivateEndpointConnection", "ReplicationExtensionModel", - "ReplicationExtensionModelCollection", "ReplicationExtensionModelCustomProperties", + "ReplicationExtensionModelListResult", "ReplicationExtensionModelProperties", - "ReplicationExtensionModelSystemData", + "Resource", "StorageContainerProperties", - "SystemDataModel", + "SystemData", "TaskModel", "TaskModelCustomProperties", - "TestFailoverCleanupWorkflowModelCustomProperties", - "TestFailoverWorkflowModelCustomProperties", - "VMwareDraModelCustomProperties", + "TestFailoverCleanupJobModelCustomProperties", + "TestFailoverJobModelCustomProperties", + "TrackedResource", + "UserAssignedIdentity", + "VMwareFabricAgentModelCustomProperties", "VMwareMigrateFabricModelCustomProperties", "VMwareToAzStackHCIDiskInput", + "VMwareToAzStackHCIEventModelCustomProperties", "VMwareToAzStackHCINicInput", "VMwareToAzStackHCIPlannedFailoverModelCustomProperties", "VMwareToAzStackHCIPolicyModelCustomProperties", "VMwareToAzStackHCIProtectedDiskProperties", "VMwareToAzStackHCIProtectedItemModelCustomProperties", + "VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate", "VMwareToAzStackHCIProtectedNicProperties", + "VMwareToAzStackHCIRecoveryPointModelCustomProperties", "VMwareToAzStackHCIReplicationExtensionModelCustomProperties", + "VaultIdentityModel", "VaultModel", - "VaultModelCollection", + "VaultModelListResult", "VaultModelProperties", - "VaultModelSystemData", "VaultModelUpdate", - "VaultModelUpdateSystemData", - "WorkflowModel", - "WorkflowModelCollection", - "WorkflowModelCustomProperties", - "WorkflowModelProperties", - "WorkflowModelSystemData", "ActionType", + "CreatedByType", "HealthStatus", + "JobObjectType", + "JobState", + "ManagedServiceIdentityType", "Origin", + "PrivateEndpointConnectionStatus", "ProtectedItemActiveLocation", "ProtectionState", "ProvisioningState", @@ -260,8 +306,7 @@ "TestFailoverState", "VMNicSelection", "VMwareToAzureMigrateResyncState", - "WorkflowObjectType", - "WorkflowState", + "VaultIdentityType", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_models_py3.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_models_py3.py index a788a96de777..2ac399fecab7 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_models_py3.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_models_py3.py @@ -1,5 +1,5 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,19 +8,18 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union -from .. import _serialization +from .._utils import serialization as _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class AzStackHCIClusterProperties(_serialization.Model): """AzStackHCI cluster properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar cluster_name: Gets or sets the AzStackHCICluster FQDN name. Required. :vartype cluster_name: str @@ -83,14 +82,14 @@ class FabricModelCustomProperties(_serialization.Model): AzStackHCIFabricModelCustomProperties, HyperVMigrateFabricModelCustomProperties, VMwareMigrateFabricModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for FabricModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { @@ -116,9 +115,9 @@ class AzStackHCIFabricModelCustomProperties(FabricModelCustomProperties): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for FabricModelCustomProperties. Required. :vartype instance_type: str :ivar az_stack_hci_site_id: Gets or sets the ARM Id of the AzStackHCI site. Required. :vartype az_stack_hci_site_id: str @@ -138,13 +137,13 @@ class AzStackHCIFabricModelCustomProperties(FabricModelCustomProperties): """ _validation = { - "instance_type": {"required": True, "min_length": 1}, - "az_stack_hci_site_id": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, + "az_stack_hci_site_id": {"required": True}, "appliance_name": {"readonly": True}, "cluster": {"required": True}, "fabric_resource_id": {"readonly": True}, "fabric_container_id": {"readonly": True}, - "migration_solution_id": {"required": True, "min_length": 1}, + "migration_solution_id": {"required": True}, "migration_hub_uri": {"readonly": True}, } @@ -179,12 +178,12 @@ def __init__( super().__init__(**kwargs) self.instance_type: str = "AzStackHCI" self.az_stack_hci_site_id = az_stack_hci_site_id - self.appliance_name = None + self.appliance_name: Optional[List[str]] = None self.cluster = cluster - self.fabric_resource_id = None - self.fabric_container_id = None + self.fabric_resource_id: Optional[str] = None + self.fabric_container_id: Optional[str] = None self.migration_solution_id = migration_solution_id - self.migration_hub_uri = None + self.migration_hub_uri: Optional[str] = None class CheckNameAvailabilityModel(_serialization.Model): @@ -254,6 +253,59 @@ def __init__( self.message = message +class ConnectionDetails(_serialization.Model): + """Private endpoint connection details at member level. + + :ivar id: Gets or sets id. + :vartype id: str + :ivar private_ip_address: Gets or sets private IP address. + :vartype private_ip_address: str + :ivar link_identifier: Gets or sets link identifier. + :vartype link_identifier: str + :ivar group_id: Gets or sets group id. + :vartype group_id: str + :ivar member_name: Gets or sets member name. + :vartype member_name: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "private_ip_address": {"key": "privateIpAddress", "type": "str"}, + "link_identifier": {"key": "linkIdentifier", "type": "str"}, + "group_id": {"key": "groupId", "type": "str"}, + "member_name": {"key": "memberName", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + private_ip_address: Optional[str] = None, + link_identifier: Optional[str] = None, + group_id: Optional[str] = None, + member_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Gets or sets id. + :paramtype id: str + :keyword private_ip_address: Gets or sets private IP address. + :paramtype private_ip_address: str + :keyword link_identifier: Gets or sets link identifier. + :paramtype link_identifier: str + :keyword group_id: Gets or sets group id. + :paramtype group_id: str + :keyword member_name: Gets or sets member name. + :paramtype member_name: str + """ + super().__init__(**kwargs) + self.id = id + self.private_ip_address = private_ip_address + self.link_identifier = link_identifier + self.group_id = group_id + self.member_name = member_name + + class DeploymentPreflightModel(_serialization.Model): """Deployment preflight model. @@ -289,6 +341,8 @@ class DeploymentPreflightResource(_serialization.Model): :vartype location: str :ivar api_version: Gets or sets the Api version. :vartype api_version: str + :ivar properties: Gets or sets the properties of the resource. + :vartype properties: any """ _attribute_map = { @@ -296,6 +350,7 @@ class DeploymentPreflightResource(_serialization.Model): "type": {"key": "type", "type": "str"}, "location": {"key": "location", "type": "str"}, "api_version": {"key": "apiVersion", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( @@ -305,6 +360,7 @@ def __init__( type: Optional[str] = None, location: Optional[str] = None, api_version: Optional[str] = None, + properties: Optional[Any] = None, **kwargs: Any ) -> None: """ @@ -316,383 +372,140 @@ def __init__( :paramtype location: str :keyword api_version: Gets or sets the Api version. :paramtype api_version: str + :keyword properties: Gets or sets the properties of the resource. + :paramtype properties: any """ super().__init__(**kwargs) self.name = name self.type = type self.location = location self.api_version = api_version + self.properties = properties -class DraModel(_serialization.Model): - """Dra model. - - Variables are only populated by the server, and will be ignored when sending a request. +class DiskControllerInputs(_serialization.Model): + """Disk controller. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar properties: Dra model properties. Required. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.DraModelProperties - :ivar id: Gets or sets the Id of the resource. - :vartype id: str - :ivar name: Gets or sets the name of the resource. - :vartype name: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :ivar system_data: - :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.DraModelSystemData + :ivar controller_name: Gets or sets the controller name (IDE,SCSI). Required. + :vartype controller_name: str + :ivar controller_id: Gets or sets the controller ID. Required. + :vartype controller_id: int + :ivar controller_location: Gets or sets the controller Location. Required. + :vartype controller_location: int """ _validation = { - "properties": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "DraModelProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "DraModelSystemData"}, + "controller_name": {"required": True, "min_length": 1}, + "controller_id": {"required": True}, + "controller_location": {"required": True}, } - def __init__(self, *, properties: "_models.DraModelProperties", **kwargs: Any) -> None: - """ - :keyword properties: Dra model properties. Required. - :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.DraModelProperties - """ - super().__init__(**kwargs) - self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class DraModelCollection(_serialization.Model): - """Dra model collection. - - :ivar value: Gets or sets the list of Dras. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] - :ivar next_link: Gets or sets the value of next link. - :vartype next_link: str - """ - _attribute_map = { - "value": {"key": "value", "type": "[DraModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "controller_name": {"key": "controllerName", "type": "str"}, + "controller_id": {"key": "controllerId", "type": "int"}, + "controller_location": {"key": "controllerLocation", "type": "int"}, } - def __init__( - self, *, value: Optional[List["_models.DraModel"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: + def __init__(self, *, controller_name: str, controller_id: int, controller_location: int, **kwargs: Any) -> None: """ - :keyword value: Gets or sets the list of Dras. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] - :keyword next_link: Gets or sets the value of next link. - :paramtype next_link: str + :keyword controller_name: Gets or sets the controller name (IDE,SCSI). Required. + :paramtype controller_name: str + :keyword controller_id: Gets or sets the controller ID. Required. + :paramtype controller_id: int + :keyword controller_location: Gets or sets the controller Location. Required. + :paramtype controller_location: int """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link - + self.controller_name = controller_name + self.controller_id = controller_id + self.controller_location = controller_location -class DraModelCustomProperties(_serialization.Model): - """Dra model custom properties. - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - VMwareDraModelCustomProperties +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar instance_type: Gets or sets the instance type. Required. - :vartype instance_type: str + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - "instance_type": {"key": "instanceType", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = {"instance_type": {"VMware": "VMwareDraModelCustomProperties"}} - def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.instance_type: Optional[str] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None -class DraModelProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Dra model properties. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar correlation_id: Gets or sets the Dra correlation Id. - :vartype correlation_id: str - :ivar machine_id: Gets or sets the machine Id where Dra is running. Required. - :vartype machine_id: str - :ivar machine_name: Gets or sets the machine name where Dra is running. Required. - :vartype machine_name: str - :ivar authentication_identity: Identity model. Required. - :vartype authentication_identity: - ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel - :ivar resource_access_identity: Identity model. Required. - :vartype resource_access_identity: - ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel - :ivar is_responsive: Gets or sets a value indicating whether Dra is responsive. - :vartype is_responsive: bool - :ivar last_heartbeat: Gets or sets the time when last heartbeat was sent by the Dra. - :vartype last_heartbeat: ~datetime.datetime - :ivar version_number: Gets or sets the Dra version. - :vartype version_number: str - :ivar provisioning_state: Gets or sets the provisioning state of the Dra. Known values are: - "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState - :ivar health_errors: Gets or sets the list of health errors. - :vartype health_errors: - list[~azure.mgmt.recoveryservicesdatareplication.models.HealthErrorModel] - :ivar custom_properties: Dra model custom properties. Required. - :vartype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.DraModelCustomProperties - """ - - _validation = { - "correlation_id": {"readonly": True}, - "machine_id": {"required": True, "min_length": 1}, - "machine_name": {"required": True, "min_length": 1}, - "authentication_identity": {"required": True}, - "resource_access_identity": {"required": True}, - "is_responsive": {"readonly": True}, - "last_heartbeat": {"readonly": True}, - "version_number": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "health_errors": {"readonly": True}, - "custom_properties": {"required": True}, - } - - _attribute_map = { - "correlation_id": {"key": "correlationId", "type": "str"}, - "machine_id": {"key": "machineId", "type": "str"}, - "machine_name": {"key": "machineName", "type": "str"}, - "authentication_identity": {"key": "authenticationIdentity", "type": "IdentityModel"}, - "resource_access_identity": {"key": "resourceAccessIdentity", "type": "IdentityModel"}, - "is_responsive": {"key": "isResponsive", "type": "bool"}, - "last_heartbeat": {"key": "lastHeartbeat", "type": "iso-8601"}, - "version_number": {"key": "versionNumber", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, - "custom_properties": {"key": "customProperties", "type": "DraModelCustomProperties"}, - } - - def __init__( - self, - *, - machine_id: str, - machine_name: str, - authentication_identity: "_models.IdentityModel", - resource_access_identity: "_models.IdentityModel", - custom_properties: "_models.DraModelCustomProperties", - **kwargs: Any - ) -> None: - """ - :keyword machine_id: Gets or sets the machine Id where Dra is running. Required. - :paramtype machine_id: str - :keyword machine_name: Gets or sets the machine name where Dra is running. Required. - :paramtype machine_name: str - :keyword authentication_identity: Identity model. Required. - :paramtype authentication_identity: - ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel - :keyword resource_access_identity: Identity model. Required. - :paramtype resource_access_identity: - ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel - :keyword custom_properties: Dra model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.DraModelCustomProperties - """ - super().__init__(**kwargs) - self.correlation_id = None - self.machine_id = machine_id - self.machine_name = machine_name - self.authentication_identity = authentication_identity - self.resource_access_identity = resource_access_identity - self.is_responsive = None - self.last_heartbeat = None - self.version_number = None - self.provisioning_state = None - self.health_errors = None - self.custom_properties = custom_properties - - -class SystemDataModel(_serialization.Model): - """System data required to be defined for Azure resources. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class DraModelSystemData(SystemDataModel): - """DraModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData """ - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - -class EmailConfigurationModel(_serialization.Model): +class EmailConfigurationModel(ProxyResource): """Email configuration model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Email configuration model properties. Required. - :vartype properties: - ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModelProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -700,54 +513,54 @@ class EmailConfigurationModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "EmailConfigurationModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "EmailConfigurationModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "EmailConfigurationModelProperties"}, } - def __init__(self, *, properties: "_models.EmailConfigurationModelProperties", **kwargs: Any) -> None: + def __init__( + self, *, properties: Optional["_models.EmailConfigurationModelProperties"] = None, **kwargs: Any + ) -> None: """ - :keyword properties: Email configuration model properties. Required. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModelProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class EmailConfigurationModelCollection(_serialization.Model): - """Email configuration model collection. +class EmailConfigurationModelListResult(_serialization.Model): + """The response of a EmailConfigurationModel list operation. + + All required parameters must be populated in order to send to server. - :ivar value: Gets or sets the list of email configurations. + :ivar value: The EmailConfigurationModel items on this page. Required. :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] - :ivar next_link: Gets or sets the value of next link. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[EmailConfigurationModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.EmailConfigurationModel"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.EmailConfigurationModel"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of email configurations. + :keyword value: The EmailConfigurationModel items on this page. Required. :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] - :keyword next_link: Gets or sets the value of next link. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -758,7 +571,9 @@ def __init__( class EmailConfigurationModelProperties(_serialization.Model): """Email configuration model properties. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. :ivar send_to_owners: Gets or sets a value indicating whether to send email to subscription administrator. Required. @@ -767,16 +582,23 @@ class EmailConfigurationModelProperties(_serialization.Model): :vartype custom_email_addresses: list[str] :ivar locale: Gets or sets the locale for the email notification. :vartype locale: str + :ivar provisioning_state: Gets or sets the provisioning state of the email configuration. Known + values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and + "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState """ _validation = { "send_to_owners": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { "send_to_owners": {"key": "sendToOwners", "type": "bool"}, "custom_email_addresses": {"key": "customEmailAddresses", "type": "[str]"}, "locale": {"key": "locale", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -800,76 +622,7 @@ def __init__( self.send_to_owners = send_to_owners self.custom_email_addresses = custom_email_addresses self.locale = locale - - -class EmailConfigurationModelSystemData(SystemDataModel): - """EmailConfigurationModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None class ErrorAdditionalInfo(_serialization.Model): @@ -896,8 +649,8 @@ class ErrorAdditionalInfo(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.info = None + self.type: Optional[str] = None + self.info: Optional[JSON] = None class ErrorDetail(_serialization.Model): @@ -937,11 +690,11 @@ class ErrorDetail(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDetail"]] = None + self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = None class ErrorModel(_serialization.Model): @@ -988,13 +741,13 @@ class ErrorModel(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.type = None - self.severity = None - self.creation_time = None - self.message = None - self.causes = None - self.recommendation = None + self.code: Optional[str] = None + self.type: Optional[str] = None + self.severity: Optional[str] = None + self.creation_time: Optional[datetime.datetime] = None + self.message: Optional[str] = None + self.causes: Optional[str] = None + self.recommendation: Optional[str] = None class ErrorResponse(_serialization.Model): @@ -1018,27 +771,27 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error -class EventModel(_serialization.Model): +class EventModel(ProxyResource): """Event model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Event model properties. Required. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.EventModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.EventModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.EventModelProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -1046,75 +799,48 @@ class EventModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "EventModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "EventModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "EventModelProperties"}, } - def __init__(self, *, properties: "_models.EventModelProperties", **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.EventModelProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Event model properties. Required. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.EventModelProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class EventModelCollection(_serialization.Model): - """Event model collection. - - :ivar value: Gets or sets the list of events. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] - :ivar next_link: Gets or sets the value of next link. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[EventModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.EventModel"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets the list of events. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] - :keyword next_link: Gets or sets the value of next link. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link class EventModelCustomProperties(_serialization.Model): """Event model custom properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - HyperVToAzStackHCIEventModelCustomProperties + HyperVToAzStackHCIEventModelCustomProperties, VMwareToAzStackHCIEventModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for EventModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, } - _subtype_map = {"instance_type": {"HyperVToAzStackHCI": "HyperVToAzStackHCIEventModelCustomProperties"}} + _subtype_map = { + "instance_type": { + "HyperVToAzStackHCI": "HyperVToAzStackHCIEventModelCustomProperties", + "VMwareToAzStackHCI": "VMwareToAzStackHCIEventModelCustomProperties", + } + } def __init__(self, **kwargs: Any) -> None: """ """ @@ -1122,12 +848,44 @@ def __init__(self, **kwargs: Any) -> None: self.instance_type: Optional[str] = None +class EventModelListResult(_serialization.Model): + """The response of a EventModel list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The EventModel items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.EventModel"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The EventModel items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class EventModelProperties(_serialization.Model): """Event model properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar resource_type: Gets or sets the resource type. :vartype resource_type: str @@ -1151,6 +909,10 @@ class EventModelProperties(_serialization.Model): :ivar custom_properties: Event model custom properties. Required. :vartype custom_properties: ~azure.mgmt.recoveryservicesdatareplication.models.EventModelCustomProperties + :ivar provisioning_state: Gets or sets the provisioning state of the event. Known values are: + "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState """ _validation = { @@ -1164,6 +926,7 @@ class EventModelProperties(_serialization.Model): "correlation_id": {"readonly": True}, "health_errors": {"readonly": True}, "custom_properties": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1177,6 +940,7 @@ class EventModelProperties(_serialization.Model): "correlation_id": {"key": "correlationId", "type": "str"}, "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, "custom_properties": {"key": "customProperties", "type": "EventModelCustomProperties"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__(self, *, custom_properties: "_models.EventModelCustomProperties", **kwargs: Any) -> None: @@ -1186,114 +950,41 @@ def __init__(self, *, custom_properties: "_models.EventModelCustomProperties", * ~azure.mgmt.recoveryservicesdatareplication.models.EventModelCustomProperties """ super().__init__(**kwargs) - self.resource_type = None - self.resource_name = None - self.event_type = None - self.event_name = None - self.time_of_occurrence = None - self.severity = None - self.description = None - self.correlation_id = None - self.health_errors = None + self.resource_type: Optional[str] = None + self.resource_name: Optional[str] = None + self.event_type: Optional[str] = None + self.event_name: Optional[str] = None + self.time_of_occurrence: Optional[datetime.datetime] = None + self.severity: Optional[str] = None + self.description: Optional[str] = None + self.correlation_id: Optional[str] = None + self.health_errors: Optional[List["_models.HealthErrorModel"]] = None self.custom_properties = custom_properties + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None -class EventModelSystemData(SystemDataModel): - """EventModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class FabricModel(_serialization.Model): - """Fabric model. +class FabricAgentModel(ProxyResource): + """Fabric agent model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar location: Gets or sets the location of the fabric. Required. - :vartype location: str - :ivar tags: Gets or sets the resource tags. - :vartype tags: dict[str, str] - :ivar properties: Fabric model properties. Required. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModelProperties """ _validation = { - "location": {"required": True, "min_length": 1}, - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -1301,62 +992,78 @@ class FabricModel(_serialization.Model): } _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "FabricModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "FabricModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "FabricAgentModelProperties"}, } - def __init__( - self, - *, - location: str, - properties: "_models.FabricModelProperties", - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, properties: Optional["_models.FabricAgentModelProperties"] = None, **kwargs: Any) -> None: """ - :keyword location: Gets or sets the location of the fabric. Required. - :paramtype location: str - :keyword tags: Gets or sets the resource tags. - :paramtype tags: dict[str, str] - :keyword properties: Fabric model properties. Required. - :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModelProperties """ super().__init__(**kwargs) - self.location = location - self.tags = tags self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class FabricModelCollection(_serialization.Model): - """Fabric model collection. +class FabricAgentModelCustomProperties(_serialization.Model): + """Fabric agent model custom properties. - :ivar value: Gets or sets the list of fabrics. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :ivar next_link: Gets or sets the value of next link. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VMwareFabricAgentModelCustomProperties + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for FabricAgentModelCustomProperties. Required. + :vartype instance_type: str + """ + + _validation = { + "instance_type": {"required": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + } + + _subtype_map = {"instance_type": {"VMware": "VMwareFabricAgentModelCustomProperties"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.instance_type: Optional[str] = None + + +class FabricAgentModelListResult(_serialization.Model): + """The response of a FabricAgentModel list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The FabricAgentModel items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[FabricModel]"}, + "value": {"key": "value", "type": "[FabricAgentModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, value: Optional[List["_models.FabricModel"]] = None, next_link: Optional[str] = None, **kwargs: Any + self, *, value: List["_models.FabricAgentModel"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of fabrics. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :keyword next_link: Gets or sets the value of next link. + :keyword value: The FabricAgentModel items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1364,153 +1071,188 @@ def __init__( self.next_link = next_link -class FabricModelProperties(_serialization.Model): - """Fabric model properties. +class FabricAgentModelProperties(_serialization.Model): + """Fabric agent model properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar provisioning_state: Gets or sets the provisioning state of the fabric. Known values are: - "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :ivar correlation_id: Gets or sets the fabric agent correlation Id. + :vartype correlation_id: str + :ivar machine_id: Gets or sets the machine Id where fabric agent is running. Required. + :vartype machine_id: str + :ivar machine_name: Gets or sets the machine name where fabric agent is running. Required. + :vartype machine_name: str + :ivar authentication_identity: Identity model. Required. + :vartype authentication_identity: + ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel + :ivar resource_access_identity: Identity model. Required. + :vartype resource_access_identity: + ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel + :ivar is_responsive: Gets or sets a value indicating whether the fabric agent is responsive. + :vartype is_responsive: bool + :ivar last_heartbeat: Gets or sets the time when last heartbeat was sent by the fabric agent. + :vartype last_heartbeat: ~datetime.datetime + :ivar version_number: Gets or sets the fabric agent version. + :vartype version_number: str + :ivar provisioning_state: Gets or sets the provisioning state of the fabric agent. Known values + are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState - :ivar service_endpoint: Gets or sets the service endpoint. - :vartype service_endpoint: str - :ivar service_resource_id: Gets or sets the service resource Id. - :vartype service_resource_id: str - :ivar health: Gets or sets the fabric health. Known values are: "Normal", "Warning", and - "Critical". - :vartype health: str or ~azure.mgmt.recoveryservicesdatareplication.models.HealthStatus :ivar health_errors: Gets or sets the list of health errors. :vartype health_errors: list[~azure.mgmt.recoveryservicesdatareplication.models.HealthErrorModel] - :ivar custom_properties: Fabric model custom properties. Required. + :ivar custom_properties: Fabric agent model custom properties. Required. :vartype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelCustomProperties + ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModelCustomProperties """ _validation = { + "correlation_id": {"readonly": True}, + "machine_id": {"required": True, "min_length": 1}, + "machine_name": {"required": True, "min_length": 1}, + "authentication_identity": {"required": True}, + "resource_access_identity": {"required": True}, + "is_responsive": {"readonly": True}, + "last_heartbeat": {"readonly": True}, + "version_number": {"readonly": True}, "provisioning_state": {"readonly": True}, - "service_endpoint": {"readonly": True}, - "service_resource_id": {"readonly": True}, - "health": {"readonly": True}, "health_errors": {"readonly": True}, "custom_properties": {"required": True}, } _attribute_map = { + "correlation_id": {"key": "correlationId", "type": "str"}, + "machine_id": {"key": "machineId", "type": "str"}, + "machine_name": {"key": "machineName", "type": "str"}, + "authentication_identity": {"key": "authenticationIdentity", "type": "IdentityModel"}, + "resource_access_identity": {"key": "resourceAccessIdentity", "type": "IdentityModel"}, + "is_responsive": {"key": "isResponsive", "type": "bool"}, + "last_heartbeat": {"key": "lastHeartbeat", "type": "iso-8601"}, + "version_number": {"key": "versionNumber", "type": "str"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, - "service_endpoint": {"key": "serviceEndpoint", "type": "str"}, - "service_resource_id": {"key": "serviceResourceId", "type": "str"}, - "health": {"key": "health", "type": "str"}, "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, - "custom_properties": {"key": "customProperties", "type": "FabricModelCustomProperties"}, + "custom_properties": {"key": "customProperties", "type": "FabricAgentModelCustomProperties"}, } - def __init__(self, *, custom_properties: "_models.FabricModelCustomProperties", **kwargs: Any) -> None: + def __init__( + self, + *, + machine_id: str, + machine_name: str, + authentication_identity: "_models.IdentityModel", + resource_access_identity: "_models.IdentityModel", + custom_properties: "_models.FabricAgentModelCustomProperties", + **kwargs: Any + ) -> None: """ - :keyword custom_properties: Fabric model custom properties. Required. + :keyword machine_id: Gets or sets the machine Id where fabric agent is running. Required. + :paramtype machine_id: str + :keyword machine_name: Gets or sets the machine name where fabric agent is running. Required. + :paramtype machine_name: str + :keyword authentication_identity: Identity model. Required. + :paramtype authentication_identity: + ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel + :keyword resource_access_identity: Identity model. Required. + :paramtype resource_access_identity: + ~azure.mgmt.recoveryservicesdatareplication.models.IdentityModel + :keyword custom_properties: Fabric agent model custom properties. Required. :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelCustomProperties + ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModelCustomProperties """ super().__init__(**kwargs) - self.provisioning_state = None - self.service_endpoint = None - self.service_resource_id = None - self.health = None - self.health_errors = None - self.custom_properties = custom_properties + self.correlation_id: Optional[str] = None + self.machine_id = machine_id + self.machine_name = machine_name + self.authentication_identity = authentication_identity + self.resource_access_identity = resource_access_identity + self.is_responsive: Optional[bool] = None + self.last_heartbeat: Optional[datetime.datetime] = None + self.version_number: Optional[str] = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.health_errors: Optional[List["_models.HealthErrorModel"]] = None + self.custom_properties = custom_properties -class FabricModelSystemData(SystemDataModel): - """FabricModelSystemData. +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + super().__init__(**kwargs) + self.tags = tags + self.location = location -class FabricModelUpdate(_serialization.Model): - """Fabric model for update. +class FabricModel(TrackedResource): + """Fabric model. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: Gets or sets the resource tags. - :vartype tags: dict[str, str] - :ivar properties: Fabric model properties. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties - :ivar id: Gets or sets the Id of the resource. + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdateSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.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. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties """ _validation = { @@ -1518,194 +1260,223 @@ class FabricModelUpdate(_serialization.Model): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "FabricModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "FabricModelUpdateSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "FabricModelProperties"}, } def __init__( self, *, + location: str, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.FabricModelProperties"] = None, **kwargs: Any ) -> None: """ - :keyword tags: Gets or sets the resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: Fabric model properties. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties """ - super().__init__(**kwargs) - self.tags = tags + super().__init__(tags=tags, location=location, **kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class FabricModelUpdateSystemData(SystemDataModel): - """FabricModelUpdateSystemData. +class FabricModelListResult(_serialization.Model): + """The response of a FabricModel list operation. - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + All required parameters must be populated in order to send to server. + + :ivar value: The FabricModel items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :ivar next_link: The link to the next page of items. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "value": {"key": "value", "type": "[FabricModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, value: List["_models.FabricModel"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword value: The FabricModel items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + super().__init__(**kwargs) + self.value = value + self.next_link = next_link -class FailoverProtectedItemProperties(_serialization.Model): - """Failover properties of the protected item. +class FabricModelProperties(_serialization.Model): + """Fabric model properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar protected_item_name: Gets or sets the protected item name. - :vartype protected_item_name: str - :ivar vm_name: Gets or sets the VM name. - :vartype vm_name: str - :ivar test_vm_name: Gets or sets the test VM name. - :vartype test_vm_name: str - :ivar recovery_point_id: Gets or sets the recovery point Id. - :vartype recovery_point_id: str - :ivar recovery_point_time: Gets or sets the recovery point time. - :vartype recovery_point_time: ~datetime.datetime - :ivar network_name: Gets or sets the network name. - :vartype network_name: str - :ivar subnet: Gets or sets the network subnet. - :vartype subnet: str + All required parameters must be populated in order to send to server. + + :ivar provisioning_state: Gets or sets the provisioning state of the fabric. Known values are: + "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState + :ivar service_endpoint: Gets or sets the service endpoint. + :vartype service_endpoint: str + :ivar service_resource_id: Gets or sets the service resource Id. + :vartype service_resource_id: str + :ivar health: Gets or sets the fabric health. Known values are: "Normal", "Warning", and + "Critical". + :vartype health: str or ~azure.mgmt.recoveryservicesdatareplication.models.HealthStatus + :ivar health_errors: Gets or sets the list of health errors. + :vartype health_errors: + list[~azure.mgmt.recoveryservicesdatareplication.models.HealthErrorModel] + :ivar custom_properties: Fabric model custom properties. Required. + :vartype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelCustomProperties """ _validation = { - "protected_item_name": {"readonly": True}, - "vm_name": {"readonly": True}, - "test_vm_name": {"readonly": True}, - "recovery_point_id": {"readonly": True}, - "recovery_point_time": {"readonly": True}, - "network_name": {"readonly": True}, - "subnet": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "service_endpoint": {"readonly": True}, + "service_resource_id": {"readonly": True}, + "health": {"readonly": True}, + "health_errors": {"readonly": True}, + "custom_properties": {"required": True}, } _attribute_map = { - "protected_item_name": {"key": "protectedItemName", "type": "str"}, - "vm_name": {"key": "vmName", "type": "str"}, - "test_vm_name": {"key": "testVmName", "type": "str"}, - "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, - "recovery_point_time": {"key": "recoveryPointTime", "type": "iso-8601"}, - "network_name": {"key": "networkName", "type": "str"}, - "subnet": {"key": "subnet", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "service_endpoint": {"key": "serviceEndpoint", "type": "str"}, + "service_resource_id": {"key": "serviceResourceId", "type": "str"}, + "health": {"key": "health", "type": "str"}, + "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, + "custom_properties": {"key": "customProperties", "type": "FabricModelCustomProperties"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, custom_properties: "_models.FabricModelCustomProperties", **kwargs: Any) -> None: + """ + :keyword custom_properties: Fabric model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelCustomProperties + """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.service_endpoint: Optional[str] = None + self.service_resource_id: Optional[str] = None + self.health: Optional[Union[str, "_models.HealthStatus"]] = None + self.health_errors: Optional[List["_models.HealthErrorModel"]] = None + self.custom_properties = custom_properties + + +class FabricModelUpdate(_serialization.Model): + """Fabric model update. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Gets or sets the resource tags. + :vartype tags: dict[str, str] + :ivar properties: Fabric model properties. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties + :ivar id: Gets or sets the Id of the resource. + :vartype id: str + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "FabricModelProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.FabricModelProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Gets or sets the resource tags. + :paramtype tags: dict[str, str] + :keyword properties: Fabric model properties. + :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelProperties + """ super().__init__(**kwargs) - self.protected_item_name = None - self.vm_name = None - self.test_vm_name = None - self.recovery_point_id = None - self.recovery_point_time = None - self.network_name = None - self.subnet = None + self.tags = tags + self.properties = properties + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None -class WorkflowModelCustomProperties(_serialization.Model): - """Workflow model custom properties. +class JobModelCustomProperties(_serialization.Model): + """Job model custom properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - FailoverWorkflowModelCustomProperties, TestFailoverCleanupWorkflowModelCustomProperties, - TestFailoverWorkflowModelCustomProperties + FailoverJobModelCustomProperties, TestFailoverCleanupJobModelCustomProperties, + TestFailoverJobModelCustomProperties Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for JobModelCustomProperties. Required. :vartype instance_type: str :ivar affected_object_details: Gets or sets any custom properties of the affected object. - :vartype affected_object_details: dict[str, str] + :vartype affected_object_details: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomPropertiesAffectedObjectDetails """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "affected_object_details": {"readonly": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, - "affected_object_details": {"key": "affectedObjectDetails", "type": "{str}"}, + "affected_object_details": { + "key": "affectedObjectDetails", + "type": "JobModelCustomPropertiesAffectedObjectDetails", + }, } _subtype_map = { "instance_type": { - "FailoverWorkflowDetails": "FailoverWorkflowModelCustomProperties", - "TestFailoverCleanupWorkflowDetails": "TestFailoverCleanupWorkflowModelCustomProperties", - "TestFailoverWorkflowDetails": "TestFailoverWorkflowModelCustomProperties", + "FailoverJobDetails": "FailoverJobModelCustomProperties", + "TestFailoverCleanupJobDetails": "TestFailoverCleanupJobModelCustomProperties", + "TestFailoverJobDetails": "TestFailoverJobModelCustomProperties", } } @@ -1713,66 +1484,182 @@ def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.instance_type: Optional[str] = None - self.affected_object_details = None + self.affected_object_details: Optional["_models.JobModelCustomPropertiesAffectedObjectDetails"] = None -class FailoverWorkflowModelCustomProperties(WorkflowModelCustomProperties): - """Failover workflow model custom properties. +class FailoverJobModelCustomProperties(JobModelCustomProperties): + """Failover job model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for JobModelCustomProperties. Required. :vartype instance_type: str :ivar affected_object_details: Gets or sets any custom properties of the affected object. - :vartype affected_object_details: dict[str, str] + :vartype affected_object_details: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomPropertiesAffectedObjectDetails :ivar protected_item_details: Gets or sets the failed over protected item details. :vartype protected_item_details: list[~azure.mgmt.recoveryservicesdatareplication.models.FailoverProtectedItemProperties] """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "affected_object_details": {"readonly": True}, "protected_item_details": {"readonly": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, - "affected_object_details": {"key": "affectedObjectDetails", "type": "{str}"}, + "affected_object_details": { + "key": "affectedObjectDetails", + "type": "JobModelCustomPropertiesAffectedObjectDetails", + }, "protected_item_details": {"key": "protectedItemDetails", "type": "[FailoverProtectedItemProperties]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.instance_type: str = "FailoverWorkflowDetails" - self.protected_item_details = None + self.instance_type: str = "FailoverJobDetails" + self.protected_item_details: Optional[List["_models.FailoverProtectedItemProperties"]] = None -class HealthErrorModel(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Health error model. +class FailoverProtectedItemProperties(_serialization.Model): + """Failover properties of the protected item. Variables are only populated by the server, and will be ignored when sending a request. - :ivar affected_resource_type: Gets or sets the type of affected resource type. - :vartype affected_resource_type: str - :ivar affected_resource_correlation_ids: Gets or sets the list of affected resource correlation - Ids. This can be used to - uniquely identify the count of items affected by a specific category and severity - as well as count of item affected by an specific issue. - :vartype affected_resource_correlation_ids: list[str] - :ivar child_errors: Gets or sets a list of child health errors associated with this error. - :vartype child_errors: - list[~azure.mgmt.recoveryservicesdatareplication.models.InnerHealthErrorModel] - :ivar code: Gets or sets the error code. - :vartype code: str - :ivar health_category: Gets or sets the health category. - :vartype health_category: str - :ivar category: Gets or sets the error category. - :vartype category: str - :ivar severity: Gets or sets the error severity. + :ivar protected_item_name: Gets or sets the protected item name. + :vartype protected_item_name: str + :ivar vm_name: Gets or sets the VM name. + :vartype vm_name: str + :ivar test_vm_name: Gets or sets the test VM name. + :vartype test_vm_name: str + :ivar recovery_point_id: Gets or sets the recovery point Id. + :vartype recovery_point_id: str + :ivar recovery_point_time: Gets or sets the recovery point time. + :vartype recovery_point_time: ~datetime.datetime + :ivar network_name: Gets or sets the network name. + :vartype network_name: str + :ivar subnet: Gets or sets the network subnet. + :vartype subnet: str + """ + + _validation = { + "protected_item_name": {"readonly": True}, + "vm_name": {"readonly": True}, + "test_vm_name": {"readonly": True}, + "recovery_point_id": {"readonly": True}, + "recovery_point_time": {"readonly": True}, + "network_name": {"readonly": True}, + "subnet": {"readonly": True}, + } + + _attribute_map = { + "protected_item_name": {"key": "protectedItemName", "type": "str"}, + "vm_name": {"key": "vmName", "type": "str"}, + "test_vm_name": {"key": "testVmName", "type": "str"}, + "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, + "recovery_point_time": {"key": "recoveryPointTime", "type": "iso-8601"}, + "network_name": {"key": "networkName", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.protected_item_name: Optional[str] = None + self.vm_name: Optional[str] = None + self.test_vm_name: Optional[str] = None + self.recovery_point_id: Optional[str] = None + self.recovery_point_time: Optional[datetime.datetime] = None + self.network_name: Optional[str] = None + self.subnet: Optional[str] = None + + +class GroupConnectivityInformation(_serialization.Model): + """Represents of a connection's group information. + + :ivar group_id: Gets or sets group id. + :vartype group_id: str + :ivar member_name: Gets or sets member name. + :vartype member_name: str + :ivar customer_visible_fqdns: Gets or sets customer visible FQDNs. + :vartype customer_visible_fqdns: list[str] + :ivar internal_fqdn: Gets or sets Internal Fqdn. + :vartype internal_fqdn: str + :ivar redirect_map_id: Gets or sets the redirect map id. + :vartype redirect_map_id: str + :ivar private_link_service_arm_region: Gets or sets the private link service arm region. + :vartype private_link_service_arm_region: str + """ + + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "member_name": {"key": "memberName", "type": "str"}, + "customer_visible_fqdns": {"key": "customerVisibleFqdns", "type": "[str]"}, + "internal_fqdn": {"key": "internalFqdn", "type": "str"}, + "redirect_map_id": {"key": "redirectMapId", "type": "str"}, + "private_link_service_arm_region": {"key": "privateLinkServiceArmRegion", "type": "str"}, + } + + def __init__( + self, + *, + group_id: Optional[str] = None, + member_name: Optional[str] = None, + customer_visible_fqdns: Optional[List[str]] = None, + internal_fqdn: Optional[str] = None, + redirect_map_id: Optional[str] = None, + private_link_service_arm_region: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword group_id: Gets or sets group id. + :paramtype group_id: str + :keyword member_name: Gets or sets member name. + :paramtype member_name: str + :keyword customer_visible_fqdns: Gets or sets customer visible FQDNs. + :paramtype customer_visible_fqdns: list[str] + :keyword internal_fqdn: Gets or sets Internal Fqdn. + :paramtype internal_fqdn: str + :keyword redirect_map_id: Gets or sets the redirect map id. + :paramtype redirect_map_id: str + :keyword private_link_service_arm_region: Gets or sets the private link service arm region. + :paramtype private_link_service_arm_region: str + """ + super().__init__(**kwargs) + self.group_id = group_id + self.member_name = member_name + self.customer_visible_fqdns = customer_visible_fqdns + self.internal_fqdn = internal_fqdn + self.redirect_map_id = redirect_map_id + self.private_link_service_arm_region = private_link_service_arm_region + + +class HealthErrorModel(_serialization.Model): + """Health error model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar affected_resource_type: Gets or sets the type of affected resource type. + :vartype affected_resource_type: str + :ivar affected_resource_correlation_ids: Gets or sets the list of affected resource correlation + Ids. This can be used to uniquely identify the count of items affected by a specific category + and severity as well as count of item affected by an specific issue. + :vartype affected_resource_correlation_ids: list[str] + :ivar child_errors: Gets or sets a list of child health errors associated with this error. + :vartype child_errors: + list[~azure.mgmt.recoveryservicesdatareplication.models.InnerHealthErrorModel] + :ivar code: Gets or sets the error code. + :vartype code: str + :ivar health_category: Gets or sets the health category. + :vartype health_category: str + :ivar category: Gets or sets the error category. + :vartype category: str + :ivar severity: Gets or sets the error severity. :vartype severity: str :ivar source: Gets or sets the error source. :vartype source: str @@ -1834,9 +1721,8 @@ def __init__( :keyword affected_resource_type: Gets or sets the type of affected resource type. :paramtype affected_resource_type: str :keyword affected_resource_correlation_ids: Gets or sets the list of affected resource - correlation Ids. This can be used to - uniquely identify the count of items affected by a specific category and severity - as well as count of item affected by an specific issue. + correlation Ids. This can be used to uniquely identify the count of items affected by a + specific category and severity as well as count of item affected by an specific issue. :paramtype affected_resource_correlation_ids: list[str] :keyword child_errors: Gets or sets a list of child health errors associated with this error. :paramtype child_errors: @@ -1846,17 +1732,17 @@ def __init__( self.affected_resource_type = affected_resource_type self.affected_resource_correlation_ids = affected_resource_correlation_ids self.child_errors = child_errors - self.code = None - self.health_category = None - self.category = None - self.severity = None - self.source = None - self.creation_time = None - self.is_customer_resolvable = None - self.summary = None - self.message = None - self.causes = None - self.recommendation = None + self.code: Optional[str] = None + self.health_category: Optional[str] = None + self.category: Optional[str] = None + self.severity: Optional[str] = None + self.source: Optional[str] = None + self.creation_time: Optional[datetime.datetime] = None + self.is_customer_resolvable: Optional[bool] = None + self.summary: Optional[str] = None + self.message: Optional[str] = None + self.causes: Optional[str] = None + self.recommendation: Optional[str] = None class HyperVMigrateFabricModelCustomProperties(FabricModelCustomProperties): @@ -1864,9 +1750,9 @@ class HyperVMigrateFabricModelCustomProperties(FabricModelCustomProperties): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for FabricModelCustomProperties. Required. :vartype instance_type: str :ivar hyper_v_site_id: Gets or sets the ARM Id of the HyperV site. Required. :vartype hyper_v_site_id: str @@ -1881,11 +1767,11 @@ class HyperVMigrateFabricModelCustomProperties(FabricModelCustomProperties): """ _validation = { - "instance_type": {"required": True, "min_length": 1}, - "hyper_v_site_id": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, + "hyper_v_site_id": {"required": True}, "fabric_resource_id": {"readonly": True}, "fabric_container_id": {"readonly": True}, - "migration_solution_id": {"required": True, "min_length": 1}, + "migration_solution_id": {"required": True}, "migration_hub_uri": {"readonly": True}, } @@ -1908,24 +1794,23 @@ def __init__(self, *, hyper_v_site_id: str, migration_solution_id: str, **kwargs super().__init__(**kwargs) self.instance_type: str = "HyperVMigrate" self.hyper_v_site_id = hyper_v_site_id - self.fabric_resource_id = None - self.fabric_container_id = None + self.fabric_resource_id: Optional[str] = None + self.fabric_container_id: Optional[str] = None self.migration_solution_id = migration_solution_id - self.migration_hub_uri = None + self.migration_hub_uri: Optional[str] = None class HyperVToAzStackHCIDiskInput(_serialization.Model): """HyperVToAzStack disk input. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar disk_id: Gets or sets the disk Id. Required. :vartype disk_id: str :ivar storage_container_id: Gets or sets the target storage account ARM Id. :vartype storage_container_id: str :ivar is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :vartype is_dynamic: bool :ivar disk_size_gb: Gets or sets the disk size in GB. Required. :vartype disk_size_gb: int @@ -1933,6 +1818,17 @@ class HyperVToAzStackHCIDiskInput(_serialization.Model): :vartype disk_file_format: str :ivar is_os_disk: Gets or sets a value indicating whether disk is os disk. Required. :vartype is_os_disk: bool + :ivar disk_block_size: Gets or sets a value of disk block size. + :vartype disk_block_size: int + :ivar disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :vartype disk_logical_sector_size: int + :ivar disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :vartype disk_physical_sector_size: int + :ivar disk_identifier: Gets or sets a value of disk identifier. + :vartype disk_identifier: str + :ivar disk_controller: Disk controller. + :vartype disk_controller: + ~azure.mgmt.recoveryservicesdatareplication.models.DiskControllerInputs """ _validation = { @@ -1949,6 +1845,11 @@ class HyperVToAzStackHCIDiskInput(_serialization.Model): "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, "disk_file_format": {"key": "diskFileFormat", "type": "str"}, "is_os_disk": {"key": "isOsDisk", "type": "bool"}, + "disk_block_size": {"key": "diskBlockSize", "type": "int"}, + "disk_logical_sector_size": {"key": "diskLogicalSectorSize", "type": "int"}, + "disk_physical_sector_size": {"key": "diskPhysicalSectorSize", "type": "int"}, + "disk_identifier": {"key": "diskIdentifier", "type": "str"}, + "disk_controller": {"key": "diskController", "type": "DiskControllerInputs"}, } def __init__( @@ -1960,6 +1861,11 @@ def __init__( is_os_disk: bool, storage_container_id: Optional[str] = None, is_dynamic: Optional[bool] = None, + disk_block_size: Optional[int] = None, + disk_logical_sector_size: Optional[int] = None, + disk_physical_sector_size: Optional[int] = None, + disk_identifier: Optional[str] = None, + disk_controller: Optional["_models.DiskControllerInputs"] = None, **kwargs: Any ) -> None: """ @@ -1968,8 +1874,7 @@ def __init__( :keyword storage_container_id: Gets or sets the target storage account ARM Id. :paramtype storage_container_id: str :keyword is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :paramtype is_dynamic: bool :keyword disk_size_gb: Gets or sets the disk size in GB. Required. :paramtype disk_size_gb: int @@ -1978,6 +1883,17 @@ def __init__( :paramtype disk_file_format: str :keyword is_os_disk: Gets or sets a value indicating whether disk is os disk. Required. :paramtype is_os_disk: bool + :keyword disk_block_size: Gets or sets a value of disk block size. + :paramtype disk_block_size: int + :keyword disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :paramtype disk_logical_sector_size: int + :keyword disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :paramtype disk_physical_sector_size: int + :keyword disk_identifier: Gets or sets a value of disk identifier. + :paramtype disk_identifier: str + :keyword disk_controller: Disk controller. + :paramtype disk_controller: + ~azure.mgmt.recoveryservicesdatareplication.models.DiskControllerInputs """ super().__init__(**kwargs) self.disk_id = disk_id @@ -1986,18 +1902,23 @@ def __init__( self.disk_size_gb = disk_size_gb self.disk_file_format = disk_file_format self.is_os_disk = is_os_disk + self.disk_block_size = disk_block_size + self.disk_logical_sector_size = disk_logical_sector_size + self.disk_physical_sector_size = disk_physical_sector_size + self.disk_identifier = disk_identifier + self.disk_controller = disk_controller -class HyperVToAzStackHCIEventModelCustomProperties(EventModelCustomProperties): +class HyperVToAzStackHCIEventModelCustomProperties(EventModelCustomProperties): # pylint: disable=name-too-long """HyperV to AzStackHCI event model custom properties. This class provides provider specific details for events of type DataContract.HealthEvents.HealthEventType.ProtectedItemHealth and DataContract.HealthEvents.HealthEventType.AgentHealth. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for EventModelCustomProperties. Required. :vartype instance_type: str :ivar event_source_friendly_name: Gets or sets the friendly name of the source which has raised this health event. @@ -2013,7 +1934,7 @@ class HyperVToAzStackHCIEventModelCustomProperties(EventModelCustomProperties): """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "event_source_friendly_name": {"readonly": True}, "protected_item_friendly_name": {"readonly": True}, "source_appliance_name": {"readonly": True}, @@ -2034,11 +1955,11 @@ def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.instance_type: str = "HyperVToAzStackHCI" - self.event_source_friendly_name = None - self.protected_item_friendly_name = None - self.source_appliance_name = None - self.target_appliance_name = None - self.server_type = None + self.event_source_friendly_name: Optional[str] = None + self.protected_item_friendly_name: Optional[str] = None + self.source_appliance_name: Optional[str] = None + self.target_appliance_name: Optional[str] = None + self.server_type: Optional[str] = None class HyperVToAzStackHCINicInput(_serialization.Model): @@ -2046,29 +1967,31 @@ class HyperVToAzStackHCINicInput(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar nic_id: Gets or sets the NIC Id. Required. :vartype nic_id: str :ivar network_name: Gets or sets the network name. :vartype network_name: str :ivar target_network_id: Gets or sets the target network Id within AzStackHCI Cluster. - Required. :vartype target_network_id: str :ivar test_network_id: Gets or sets the target test network Id within AzStackHCI Cluster. - Required. :vartype test_network_id: str :ivar selection_type_for_failover: Gets or sets the selection type of the NIC. Required. Known values are: "NotSelected", "SelectedByUser", "SelectedByDefault", and "SelectedByUserOverride". :vartype selection_type_for_failover: str or ~azure.mgmt.recoveryservicesdatareplication.models.VMNicSelection + :ivar is_static_ip_migration_enabled: Gets or sets a value indicating whether static ip + migration is enabled. + :vartype is_static_ip_migration_enabled: bool + :ivar is_mac_migration_enabled: Gets or sets a value indicating whether mac address migration + is enabled. + :vartype is_mac_migration_enabled: bool """ _validation = { "nic_id": {"required": True, "min_length": 1}, "network_name": {"readonly": True}, - "target_network_id": {"required": True, "min_length": 1}, - "test_network_id": {"required": True, "min_length": 1}, "selection_type_for_failover": {"required": True}, } @@ -2078,38 +2001,48 @@ class HyperVToAzStackHCINicInput(_serialization.Model): "target_network_id": {"key": "targetNetworkId", "type": "str"}, "test_network_id": {"key": "testNetworkId", "type": "str"}, "selection_type_for_failover": {"key": "selectionTypeForFailover", "type": "str"}, + "is_static_ip_migration_enabled": {"key": "isStaticIpMigrationEnabled", "type": "bool"}, + "is_mac_migration_enabled": {"key": "isMacMigrationEnabled", "type": "bool"}, } def __init__( self, *, nic_id: str, - target_network_id: str, - test_network_id: str, selection_type_for_failover: Union[str, "_models.VMNicSelection"], + target_network_id: Optional[str] = None, + test_network_id: Optional[str] = None, + is_static_ip_migration_enabled: Optional[bool] = None, + is_mac_migration_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword nic_id: Gets or sets the NIC Id. Required. :paramtype nic_id: str :keyword target_network_id: Gets or sets the target network Id within AzStackHCI Cluster. - Required. :paramtype target_network_id: str :keyword test_network_id: Gets or sets the target test network Id within AzStackHCI Cluster. - Required. :paramtype test_network_id: str :keyword selection_type_for_failover: Gets or sets the selection type of the NIC. Required. Known values are: "NotSelected", "SelectedByUser", "SelectedByDefault", and "SelectedByUserOverride". :paramtype selection_type_for_failover: str or ~azure.mgmt.recoveryservicesdatareplication.models.VMNicSelection + :keyword is_static_ip_migration_enabled: Gets or sets a value indicating whether static ip + migration is enabled. + :paramtype is_static_ip_migration_enabled: bool + :keyword is_mac_migration_enabled: Gets or sets a value indicating whether mac address + migration is enabled. + :paramtype is_mac_migration_enabled: bool """ super().__init__(**kwargs) self.nic_id = nic_id - self.network_name = None + self.network_name: Optional[str] = None self.target_network_id = target_network_id self.test_network_id = test_network_id self.selection_type_for_failover = selection_type_for_failover + self.is_static_ip_migration_enabled = is_static_ip_migration_enabled + self.is_mac_migration_enabled = is_mac_migration_enabled class PlannedFailoverModelCustomProperties(_serialization.Model): @@ -2119,14 +2052,14 @@ class PlannedFailoverModelCustomProperties(_serialization.Model): HyperVToAzStackHCIPlannedFailoverModelCustomProperties, VMwareToAzStackHCIPlannedFailoverModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PlannedFailoverModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { @@ -2146,12 +2079,14 @@ def __init__(self, **kwargs: Any) -> None: self.instance_type: Optional[str] = None -class HyperVToAzStackHCIPlannedFailoverModelCustomProperties(PlannedFailoverModelCustomProperties): +class HyperVToAzStackHCIPlannedFailoverModelCustomProperties( + PlannedFailoverModelCustomProperties +): # pylint: disable=name-too-long """HyperV to AzStackHCI planned failover model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PlannedFailoverModelCustomProperties. Required. :vartype instance_type: str :ivar shutdown_source_vm: Gets or sets a value indicating whether VM needs to be shut down. Required. @@ -2159,7 +2094,7 @@ class HyperVToAzStackHCIPlannedFailoverModelCustomProperties(PlannedFailoverMode """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "shutdown_source_vm": {"required": True}, } @@ -2185,14 +2120,14 @@ class PolicyModelCustomProperties(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: HyperVToAzStackHCIPolicyModelCustomProperties, VMwareToAzStackHCIPolicyModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PolicyModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { @@ -2212,16 +2147,15 @@ def __init__(self, **kwargs: Any) -> None: self.instance_type: Optional[str] = None -class HyperVToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties): +class HyperVToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties): # pylint: disable=name-too-long """HyperV To AzStackHCI Policy model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PolicyModelCustomProperties. Required. :vartype instance_type: str :ivar recovery_point_history_in_minutes: Gets or sets the duration in minutes until which the - recovery points need to be - stored. Required. + recovery points need to be stored. Required. :vartype recovery_point_history_in_minutes: int :ivar crash_consistent_frequency_in_minutes: Gets or sets the crash consistent snapshot frequency (in minutes). Required. @@ -2232,7 +2166,7 @@ class HyperVToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties) """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "recovery_point_history_in_minutes": {"required": True}, "crash_consistent_frequency_in_minutes": {"required": True}, "app_consistent_frequency_in_minutes": {"required": True}, @@ -2255,8 +2189,7 @@ def __init__( ) -> None: """ :keyword recovery_point_history_in_minutes: Gets or sets the duration in minutes until which - the recovery points need to be - stored. Required. + the recovery points need to be stored. Required. :paramtype recovery_point_history_in_minutes: int :keyword crash_consistent_frequency_in_minutes: Gets or sets the crash consistent snapshot frequency (in minutes). Required. @@ -2272,7 +2205,7 @@ def __init__( self.app_consistent_frequency_in_minutes = app_consistent_frequency_in_minutes -class HyperVToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class HyperVToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint: disable=name-too-long """HyperVToAzStackHCI protected disk properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2296,11 +2229,16 @@ class HyperVToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint :ivar capacity_in_bytes: Gets or sets the disk capacity in bytes. :vartype capacity_in_bytes: int :ivar is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :vartype is_dynamic: bool :ivar disk_type: Gets or sets the disk type. :vartype disk_type: str + :ivar disk_block_size: Gets or sets a value of disk block size. + :vartype disk_block_size: int + :ivar disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :vartype disk_logical_sector_size: int + :ivar disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :vartype disk_physical_sector_size: int """ _validation = { @@ -2315,6 +2253,9 @@ class HyperVToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint "capacity_in_bytes": {"readonly": True}, "is_dynamic": {"readonly": True}, "disk_type": {"readonly": True}, + "disk_block_size": {"readonly": True}, + "disk_logical_sector_size": {"readonly": True}, + "disk_physical_sector_size": {"readonly": True}, } _attribute_map = { @@ -2329,22 +2270,28 @@ class HyperVToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint "capacity_in_bytes": {"key": "capacityInBytes", "type": "int"}, "is_dynamic": {"key": "isDynamic", "type": "bool"}, "disk_type": {"key": "diskType", "type": "str"}, + "disk_block_size": {"key": "diskBlockSize", "type": "int"}, + "disk_logical_sector_size": {"key": "diskLogicalSectorSize", "type": "int"}, + "disk_physical_sector_size": {"key": "diskPhysicalSectorSize", "type": "int"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.storage_container_id = None - self.storage_container_local_path = None - self.source_disk_id = None - self.source_disk_name = None - self.seed_disk_name = None - self.test_migrate_disk_name = None - self.migrate_disk_name = None - self.is_os_disk = None - self.capacity_in_bytes = None - self.is_dynamic = None - self.disk_type = None + self.storage_container_id: Optional[str] = None + self.storage_container_local_path: Optional[str] = None + self.source_disk_id: Optional[str] = None + self.source_disk_name: Optional[str] = None + self.seed_disk_name: Optional[str] = None + self.test_migrate_disk_name: Optional[str] = None + self.migrate_disk_name: Optional[str] = None + self.is_os_disk: Optional[bool] = None + self.capacity_in_bytes: Optional[int] = None + self.is_dynamic: Optional[bool] = None + self.disk_type: Optional[str] = None + self.disk_block_size: Optional[int] = None + self.disk_logical_sector_size: Optional[int] = None + self.disk_physical_sector_size: Optional[int] = None class ProtectedItemModelCustomProperties(_serialization.Model): @@ -2354,14 +2301,14 @@ class ProtectedItemModelCustomProperties(_serialization.Model): HyperVToAzStackHCIProtectedItemModelCustomProperties, VMwareToAzStackHCIProtectedItemModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ProtectedItemModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { @@ -2383,14 +2330,14 @@ def __init__(self, **kwargs: Any) -> None: class HyperVToAzStackHCIProtectedItemModelCustomProperties( ProtectedItemModelCustomProperties -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=name-too-long """HyperV to AzStackHCI Protected item model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ProtectedItemModelCustomProperties. Required. :vartype instance_type: str :ivar active_location: Gets or sets the location of the protected item. Known values are: "Primary" and "Recovery". @@ -2441,10 +2388,10 @@ class HyperVToAzStackHCIProtectedItemModelCustomProperties( :vartype target_memory_in_mega_bytes: int :ivar run_as_account_id: Gets or sets the Run As account Id. Required. :vartype run_as_account_id: str - :ivar source_dra_name: Gets or sets the source DRA name. Required. - :vartype source_dra_name: str - :ivar target_dra_name: Gets or sets the target DRA name. Required. - :vartype target_dra_name: str + :ivar source_fabric_agent_name: Gets or sets the source fabric agent name. Required. + :vartype source_fabric_agent_name: str + :ivar target_fabric_agent_name: Gets or sets the target fabric agent name. Required. + :vartype target_fabric_agent_name: str :ivar source_appliance_name: Gets or sets the source appliance name. :vartype source_appliance_name: str :ivar target_appliance_name: Gets or sets the target appliance name. @@ -2468,12 +2415,10 @@ class HyperVToAzStackHCIProtectedItemModelCustomProperties( :ivar last_recovery_point_id: Gets or sets the last recovery point Id. :vartype last_recovery_point_id: str :ivar initial_replication_progress_percentage: Gets or sets the initial replication progress - percentage. This is calculated based on - total bytes processed for all disks in the source VM. + percentage. This is calculated based on total bytes processed for all disks in the source VM. :vartype initial_replication_progress_percentage: int :ivar resync_progress_percentage: Gets or sets the resync progress percentage. This is - calculated based on total bytes - processed for all disks in the source VM. + calculated based on total bytes processed for all disks in the source VM. :vartype resync_progress_percentage: int :ivar protected_disks: Gets or sets the list of protected disks. :vartype protected_disks: @@ -2489,23 +2434,23 @@ class HyperVToAzStackHCIProtectedItemModelCustomProperties( """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "active_location": {"readonly": True}, - "target_hci_cluster_id": {"required": True, "min_length": 1}, - "target_arc_cluster_custom_location_id": {"required": True, "min_length": 1}, + "target_hci_cluster_id": {"required": True}, + "target_arc_cluster_custom_location_id": {"required": True}, "target_az_stack_hci_cluster_name": {"readonly": True}, - "fabric_discovery_machine_id": {"required": True, "min_length": 1}, - "disks_to_include": {"required": True, "min_items": 1}, - "nics_to_include": {"required": True, "min_items": 1}, + "fabric_discovery_machine_id": {"required": True}, + "disks_to_include": {"required": True}, + "nics_to_include": {"required": True}, "source_vm_name": {"readonly": True}, "source_cpu_cores": {"readonly": True}, "source_memory_in_mega_bytes": {"readonly": True}, - "target_resource_group_id": {"required": True, "min_length": 1}, - "storage_container_id": {"required": True, "min_length": 1}, + "target_resource_group_id": {"required": True}, + "storage_container_id": {"required": True}, "hyper_v_generation": {"required": True, "min_length": 1}, "run_as_account_id": {"required": True, "min_length": 1}, - "source_dra_name": {"required": True, "min_length": 1}, - "target_dra_name": {"required": True, "min_length": 1}, + "source_fabric_agent_name": {"required": True, "min_length": 1}, + "target_fabric_agent_name": {"required": True, "min_length": 1}, "source_appliance_name": {"readonly": True}, "target_appliance_name": {"readonly": True}, "os_type": {"readonly": True}, @@ -2547,8 +2492,8 @@ class HyperVToAzStackHCIProtectedItemModelCustomProperties( "dynamic_memory_config": {"key": "dynamicMemoryConfig", "type": "ProtectedItemDynamicMemoryConfig"}, "target_memory_in_mega_bytes": {"key": "targetMemoryInMegaBytes", "type": "int"}, "run_as_account_id": {"key": "runAsAccountId", "type": "str"}, - "source_dra_name": {"key": "sourceDraName", "type": "str"}, - "target_dra_name": {"key": "targetDraName", "type": "str"}, + "source_fabric_agent_name": {"key": "sourceFabricAgentName", "type": "str"}, + "target_fabric_agent_name": {"key": "targetFabricAgentName", "type": "str"}, "source_appliance_name": {"key": "sourceApplianceName", "type": "str"}, "target_appliance_name": {"key": "targetApplianceName", "type": "str"}, "os_type": {"key": "osType", "type": "str"}, @@ -2579,8 +2524,8 @@ def __init__( # pylint: disable=too-many-locals storage_container_id: str, hyper_v_generation: str, run_as_account_id: str, - source_dra_name: str, - target_dra_name: str, + source_fabric_agent_name: str, + target_fabric_agent_name: str, custom_location_region: str, target_vm_name: Optional[str] = None, target_network_id: Optional[str] = None, @@ -2630,26 +2575,26 @@ def __init__( # pylint: disable=too-many-locals :paramtype target_memory_in_mega_bytes: int :keyword run_as_account_id: Gets or sets the Run As account Id. Required. :paramtype run_as_account_id: str - :keyword source_dra_name: Gets or sets the source DRA name. Required. - :paramtype source_dra_name: str - :keyword target_dra_name: Gets or sets the target DRA name. Required. - :paramtype target_dra_name: str + :keyword source_fabric_agent_name: Gets or sets the source fabric agent name. Required. + :paramtype source_fabric_agent_name: str + :keyword target_fabric_agent_name: Gets or sets the target fabric agent name. Required. + :paramtype target_fabric_agent_name: str :keyword custom_location_region: Gets or sets the location of Azure Arc HCI custom location resource. Required. :paramtype custom_location_region: str """ super().__init__(**kwargs) self.instance_type: str = "HyperVToAzStackHCI" - self.active_location = None + self.active_location: Optional[Union[str, "_models.ProtectedItemActiveLocation"]] = None self.target_hci_cluster_id = target_hci_cluster_id self.target_arc_cluster_custom_location_id = target_arc_cluster_custom_location_id - self.target_az_stack_hci_cluster_name = None + self.target_az_stack_hci_cluster_name: Optional[str] = None self.fabric_discovery_machine_id = fabric_discovery_machine_id self.disks_to_include = disks_to_include self.nics_to_include = nics_to_include - self.source_vm_name = None - self.source_cpu_cores = None - self.source_memory_in_mega_bytes = None + self.source_vm_name: Optional[str] = None + self.source_cpu_cores: Optional[int] = None + self.source_memory_in_mega_bytes: Optional[float] = None self.target_vm_name = target_vm_name self.target_resource_group_id = target_resource_group_id self.storage_container_id = storage_container_id @@ -2661,24 +2606,136 @@ def __init__( # pylint: disable=too-many-locals self.dynamic_memory_config = dynamic_memory_config self.target_memory_in_mega_bytes = target_memory_in_mega_bytes self.run_as_account_id = run_as_account_id - self.source_dra_name = source_dra_name - self.target_dra_name = target_dra_name - self.source_appliance_name = None - self.target_appliance_name = None - self.os_type = None - self.os_name = None - self.firmware_type = None - self.target_location = None + self.source_fabric_agent_name = source_fabric_agent_name + self.target_fabric_agent_name = target_fabric_agent_name + self.source_appliance_name: Optional[str] = None + self.target_appliance_name: Optional[str] = None + self.os_type: Optional[str] = None + self.os_name: Optional[str] = None + self.firmware_type: Optional[str] = None + self.target_location: Optional[str] = None self.custom_location_region = custom_location_region - self.failover_recovery_point_id = None - self.last_recovery_point_received = None - self.last_recovery_point_id = None - self.initial_replication_progress_percentage = None - self.resync_progress_percentage = None - self.protected_disks = None - self.protected_nics = None - self.target_vm_bios_id = None - self.last_replication_update_time = None + self.failover_recovery_point_id: Optional[str] = None + self.last_recovery_point_received: Optional[datetime.datetime] = None + self.last_recovery_point_id: Optional[str] = None + self.initial_replication_progress_percentage: Optional[int] = None + self.resync_progress_percentage: Optional[int] = None + self.protected_disks: Optional[List["_models.HyperVToAzStackHCIProtectedDiskProperties"]] = None + self.protected_nics: Optional[List["_models.HyperVToAzStackHCIProtectedNicProperties"]] = None + self.target_vm_bios_id: Optional[str] = None + self.last_replication_update_time: Optional[datetime.datetime] = None + + +class ProtectedItemModelCustomPropertiesUpdate(_serialization.Model): + """Protected item model custom properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate, + VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for ProtectedItemModelCustomPropertiesUpdate. + Required. + :vartype instance_type: str + """ + + _validation = { + "instance_type": {"required": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + } + + _subtype_map = { + "instance_type": { + "HyperVToAzStackHCI": "HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate", + "VMwareToAzStackHCI": "VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.instance_type: Optional[str] = None + + +class HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate( + ProtectedItemModelCustomPropertiesUpdate +): # pylint: disable=name-too-long + """HyperV to AzStackHCI Protected item model custom properties. + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for ProtectedItemModelCustomPropertiesUpdate. + Required. + :vartype instance_type: str + :ivar nics_to_include: Gets or sets the list of VM NIC to replicate. + :vartype nics_to_include: + list[~azure.mgmt.recoveryservicesdatareplication.models.HyperVToAzStackHCINicInput] + :ivar target_cpu_cores: Gets or sets the target CPU cores. + :vartype target_cpu_cores: int + :ivar is_dynamic_ram: Gets or sets a value indicating whether memory is dynamical. + :vartype is_dynamic_ram: bool + :ivar dynamic_memory_config: Protected item dynamic memory config. + :vartype dynamic_memory_config: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemDynamicMemoryConfig + :ivar target_memory_in_mega_bytes: Gets or sets the target memory in mega-bytes. + :vartype target_memory_in_mega_bytes: int + :ivar os_type: Gets or sets the type of the OS. + :vartype os_type: str + """ + + _validation = { + "instance_type": {"required": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + "nics_to_include": {"key": "nicsToInclude", "type": "[HyperVToAzStackHCINicInput]"}, + "target_cpu_cores": {"key": "targetCpuCores", "type": "int"}, + "is_dynamic_ram": {"key": "isDynamicRam", "type": "bool"}, + "dynamic_memory_config": {"key": "dynamicMemoryConfig", "type": "ProtectedItemDynamicMemoryConfig"}, + "target_memory_in_mega_bytes": {"key": "targetMemoryInMegaBytes", "type": "int"}, + "os_type": {"key": "osType", "type": "str"}, + } + + def __init__( + self, + *, + nics_to_include: Optional[List["_models.HyperVToAzStackHCINicInput"]] = None, + target_cpu_cores: Optional[int] = None, + is_dynamic_ram: Optional[bool] = None, + dynamic_memory_config: Optional["_models.ProtectedItemDynamicMemoryConfig"] = None, + target_memory_in_mega_bytes: Optional[int] = None, + os_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword nics_to_include: Gets or sets the list of VM NIC to replicate. + :paramtype nics_to_include: + list[~azure.mgmt.recoveryservicesdatareplication.models.HyperVToAzStackHCINicInput] + :keyword target_cpu_cores: Gets or sets the target CPU cores. + :paramtype target_cpu_cores: int + :keyword is_dynamic_ram: Gets or sets a value indicating whether memory is dynamical. + :paramtype is_dynamic_ram: bool + :keyword dynamic_memory_config: Protected item dynamic memory config. + :paramtype dynamic_memory_config: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemDynamicMemoryConfig + :keyword target_memory_in_mega_bytes: Gets or sets the target memory in mega-bytes. + :paramtype target_memory_in_mega_bytes: int + :keyword os_type: Gets or sets the type of the OS. + :paramtype os_type: str + """ + super().__init__(**kwargs) + self.instance_type: str = "HyperVToAzStackHCI" + self.nics_to_include = nics_to_include + self.target_cpu_cores = target_cpu_cores + self.is_dynamic_ram = is_dynamic_ram + self.dynamic_memory_config = dynamic_memory_config + self.target_memory_in_mega_bytes = target_memory_in_mega_bytes + self.os_type = os_type class HyperVToAzStackHCIProtectedNicProperties(_serialization.Model): @@ -2723,35 +2780,41 @@ class HyperVToAzStackHCIProtectedNicProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.nic_id = None - self.mac_address = None - self.network_name = None - self.target_network_id = None - self.test_network_id = None - self.selection_type_for_failover = None + self.nic_id: Optional[str] = None + self.mac_address: Optional[str] = None + self.network_name: Optional[str] = None + self.target_network_id: Optional[str] = None + self.test_network_id: Optional[str] = None + self.selection_type_for_failover: Optional[Union[str, "_models.VMNicSelection"]] = None class RecoveryPointModelCustomProperties(_serialization.Model): """Recovery point model custom properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - HyperVToAzStackHCIRecoveryPointModelCustomProperties + HyperVToAzStackHCIRecoveryPointModelCustomProperties, + VMwareToAzStackHCIRecoveryPointModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for RecoveryPointModelCustomProperties. Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, } - _subtype_map = {"instance_type": {"HyperVToAzStackHCI": "HyperVToAzStackHCIRecoveryPointModelCustomProperties"}} + _subtype_map = { + "instance_type": { + "HyperVToAzStackHCI": "HyperVToAzStackHCIRecoveryPointModelCustomProperties", + "VMwareToAzStackHCIRecoveryPointModelCustomProperties": "VMwareToAzStackHCIRecoveryPointModelCustomProperties", + } + } def __init__(self, **kwargs: Any) -> None: """ """ @@ -2759,21 +2822,23 @@ def __init__(self, **kwargs: Any) -> None: self.instance_type: Optional[str] = None -class HyperVToAzStackHCIRecoveryPointModelCustomProperties(RecoveryPointModelCustomProperties): +class HyperVToAzStackHCIRecoveryPointModelCustomProperties( + RecoveryPointModelCustomProperties +): # pylint: disable=name-too-long """HyperV to AzStackHCI recovery point model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for RecoveryPointModelCustomProperties. Required. :vartype instance_type: str :ivar disk_ids: Gets or sets the list of the disk Ids. :vartype disk_ids: list[str] """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "disk_ids": {"readonly": True}, } @@ -2786,24 +2851,25 @@ def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.instance_type: str = "HyperVToAzStackHCI" - self.disk_ids = None + self.disk_ids: Optional[List[str]] = None -class ReplicationExtensionModelCustomProperties(_serialization.Model): +class ReplicationExtensionModelCustomProperties(_serialization.Model): # pylint: disable=name-too-long """Replication extension model custom properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: HyperVToAzStackHCIReplicationExtensionModelCustomProperties, VMwareToAzStackHCIReplicationExtensionModelCustomProperties - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ReplicationExtensionModelCustomProperties. + Required. :vartype instance_type: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, } _attribute_map = { @@ -2825,14 +2891,15 @@ def __init__(self, **kwargs: Any) -> None: class HyperVToAzStackHCIReplicationExtensionModelCustomProperties( ReplicationExtensionModelCustomProperties -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=name-too-long """HyperV to AzStackHCI Replication extension model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ReplicationExtensionModelCustomProperties. + Required. :vartype instance_type: str :ivar hyper_v_fabric_arm_id: Gets or sets the ARM Id of the source HyperV fabric. Required. :vartype hyper_v_fabric_arm_id: str @@ -2870,10 +2937,10 @@ class HyperVToAzStackHCIReplicationExtensionModelCustomProperties( """ _validation = { - "instance_type": {"required": True, "min_length": 1}, - "hyper_v_fabric_arm_id": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, + "hyper_v_fabric_arm_id": {"required": True}, "hyper_v_site_id": {"readonly": True}, - "az_stack_hci_fabric_arm_id": {"required": True, "min_length": 1}, + "az_stack_hci_fabric_arm_id": {"required": True}, "az_stack_hci_site_id": {"readonly": True}, "asr_service_uri": {"readonly": True}, "rcm_service_uri": {"readonly": True}, @@ -2930,43 +2997,42 @@ def __init__( super().__init__(**kwargs) self.instance_type: str = "HyperVToAzStackHCI" self.hyper_v_fabric_arm_id = hyper_v_fabric_arm_id - self.hyper_v_site_id = None + self.hyper_v_site_id: Optional[str] = None self.az_stack_hci_fabric_arm_id = az_stack_hci_fabric_arm_id - self.az_stack_hci_site_id = None + self.az_stack_hci_site_id: Optional[str] = None self.storage_account_id = storage_account_id self.storage_account_sas_secret_name = storage_account_sas_secret_name - self.asr_service_uri = None - self.rcm_service_uri = None - self.gateway_service_uri = None - self.source_gateway_service_id = None - self.target_gateway_service_id = None - self.source_storage_container_name = None - self.target_storage_container_name = None - self.resource_location = None - self.subscription_id = None - self.resource_group = None + self.asr_service_uri: Optional[str] = None + self.rcm_service_uri: Optional[str] = None + self.gateway_service_uri: Optional[str] = None + self.source_gateway_service_id: Optional[str] = None + self.target_gateway_service_id: Optional[str] = None + self.source_storage_container_name: Optional[str] = None + self.target_storage_container_name: Optional[str] = None + self.resource_location: Optional[str] = None + self.subscription_id: Optional[str] = None + self.resource_group: Optional[str] = None class IdentityModel(_serialization.Model): """Identity model. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar tenant_id: Gets or sets the tenant Id of the SPN with which Dra communicates to service. - Required. - :vartype tenant_id: str - :ivar application_id: Gets or sets the client/application Id of the SPN with which Dra - communicates to + :ivar tenant_id: Gets or sets the tenant Id of the SPN with which fabric agent communicates to service. Required. + :vartype tenant_id: str + :ivar application_id: Gets or sets the client/application Id of the SPN with which fabric agent + communicates to service. Required. :vartype application_id: str - :ivar object_id: Gets or sets the object Id of the SPN with which Dra communicates to service. - Required. + :ivar object_id: Gets or sets the object Id of the SPN with which fabric agent communicates to + service. Required. :vartype object_id: str - :ivar audience: Gets or sets the audience of the SPN with which Dra communicates to service. - Required. - :vartype audience: str - :ivar aad_authority: Gets or sets the authority of the SPN with which Dra communicates to + :ivar audience: Gets or sets the audience of the SPN with which fabric agent communicates to service. Required. + :vartype audience: str + :ivar aad_authority: Gets or sets the authority of the SPN with which fabric agent communicates + to service. Required. :vartype aad_authority: str """ @@ -2990,21 +3056,20 @@ def __init__( self, *, tenant_id: str, application_id: str, object_id: str, audience: str, aad_authority: str, **kwargs: Any ) -> None: """ - :keyword tenant_id: Gets or sets the tenant Id of the SPN with which Dra communicates to - service. Required. + :keyword tenant_id: Gets or sets the tenant Id of the SPN with which fabric agent communicates + to service. Required. :paramtype tenant_id: str - :keyword application_id: Gets or sets the client/application Id of the SPN with which Dra - communicates to - service. Required. + :keyword application_id: Gets or sets the client/application Id of the SPN with which fabric + agent communicates to service. Required. :paramtype application_id: str - :keyword object_id: Gets or sets the object Id of the SPN with which Dra communicates to - service. Required. + :keyword object_id: Gets or sets the object Id of the SPN with which fabric agent communicates + to service. Required. :paramtype object_id: str - :keyword audience: Gets or sets the audience of the SPN with which Dra communicates to service. - Required. - :paramtype audience: str - :keyword aad_authority: Gets or sets the authority of the SPN with which Dra communicates to + :keyword audience: Gets or sets the audience of the SPN with which fabric agent communicates to service. Required. + :paramtype audience: str + :keyword aad_authority: Gets or sets the authority of the SPN with which fabric agent + communicates to service. Required. :paramtype aad_authority: str """ super().__init__(**kwargs) @@ -3015,7 +3080,7 @@ def __init__( self.aad_authority = aad_authority -class InnerHealthErrorModel(_serialization.Model): # pylint: disable=too-many-instance-attributes +class InnerHealthErrorModel(_serialization.Model): """Inner health error model. Variables are only populated by the server, and will be ignored when sending a request. @@ -3076,231 +3141,386 @@ class InnerHealthErrorModel(_serialization.Model): # pylint: disable=too-many-i def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.health_category = None - self.category = None - self.severity = None - self.source = None - self.creation_time = None - self.is_customer_resolvable = None - self.summary = None - self.message = None - self.causes = None - self.recommendation = None - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. + self.code: Optional[str] = None + self.health_category: Optional[str] = None + self.category: Optional[str] = None + self.severity: Optional[str] = None + self.source: Optional[str] = None + self.creation_time: Optional[datetime.datetime] = None + self.is_customer_resolvable: Optional[bool] = None + self.summary: Optional[str] = None + self.message: Optional[str] = None + self.causes: Optional[str] = None + self.recommendation: Optional[str] = None + + +class JobModel(ProxyResource): + """Job model. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationDisplay - :ivar origin: 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". - :vartype origin: str or ~azure.mgmt.recoveryservicesdatareplication.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.recoveryservicesdatareplication.models.ActionType + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.JobModelProperties """ _validation = { + "id": {"readonly": True}, "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "JobModelProperties"}, } - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.JobModelProperties"] = None, **kwargs: Any) -> None: """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationDisplay + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.JobModelProperties """ super().__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = display - self.origin = None - self.action_type = None + self.properties = properties -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. +class JobModelCustomPropertiesAffectedObjectDetails(_serialization.Model): # pylint: disable=name-too-long + """Gets or sets any custom properties of the affected object. - Variables are only populated by the server, and will be ignored when sending a request. + :ivar description: + :vartype description: str + :ivar type: Default value is "object". + :vartype type: str + """ - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, *, description: Optional[str] = None, type: Optional[Literal["object"]] = None, **kwargs: Any + ) -> None: + """ + :keyword description: + :paramtype description: str + :keyword type: Default value is "object". + :paramtype type: str + """ + super().__init__(**kwargs) + self.description = description + self.type = type + + +class JobModelListResult(_serialization.Model): + """The response of a JobModel list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The JobModel items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] + :ivar next_link: The link to the next page of items. + :vartype next_link: str """ _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, + "value": {"key": "value", "type": "[JobModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: List["_models.JobModel"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The JobModel items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None + self.value = value + self.next_link = next_link -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. +class JobModelProperties(_serialization.Model): + """Job model properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str + All required parameters must be populated in order to send to server. + + :ivar display_name: Gets or sets the friendly display name. + :vartype display_name: str + :ivar state: Gets or sets the job state. Known values are: "Pending", "Started", "Cancelling", + "Succeeded", "Failed", "Cancelled", "CompletedWithInformation", "CompletedWithWarnings", and + "CompletedWithErrors". + :vartype state: str or ~azure.mgmt.recoveryservicesdatareplication.models.JobState + :ivar start_time: Gets or sets the start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Gets or sets the end time. + :vartype end_time: ~datetime.datetime + :ivar object_id: Gets or sets the affected object Id. + :vartype object_id: str + :ivar object_name: Gets or sets the affected object name. + :vartype object_name: str + :ivar object_internal_id: Gets or sets the affected object internal Id. + :vartype object_internal_id: str + :ivar object_internal_name: Gets or sets the affected object internal name. + :vartype object_internal_name: str + :ivar object_type: Gets or sets the object type. Known values are: "AvsDiskPool", + "FabricAgent", "Fabric", "Policy", "ProtectedItem", "RecoveryPlan", "ReplicationExtension", and + "Vault". + :vartype object_type: str or ~azure.mgmt.recoveryservicesdatareplication.models.JobObjectType + :ivar replication_provider_id: Gets or sets the replication provider. + :vartype replication_provider_id: str + :ivar source_fabric_provider_id: Gets or sets the source fabric provider. + :vartype source_fabric_provider_id: str + :ivar target_fabric_provider_id: Gets or sets the target fabric provider. + :vartype target_fabric_provider_id: str + :ivar allowed_actions: Gets or sets the list of allowed actions on the job. + :vartype allowed_actions: list[str] + :ivar activity_id: Gets or sets the job activity id. + :vartype activity_id: str + :ivar tasks: Gets or sets the list of tasks. + :vartype tasks: list[~azure.mgmt.recoveryservicesdatareplication.models.TaskModel] + :ivar errors: Gets or sets the list of errors. + :vartype errors: list[~azure.mgmt.recoveryservicesdatareplication.models.ErrorModel] + :ivar custom_properties: Job model custom properties. Required. + :vartype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomProperties + :ivar provisioning_state: Gets or sets the provisioning state of the job. Known values are: + "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "display_name": {"readonly": True}, + "state": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "object_id": {"readonly": True}, + "object_name": {"readonly": True}, + "object_internal_id": {"readonly": True}, + "object_internal_name": {"readonly": True}, + "object_type": {"readonly": True}, + "replication_provider_id": {"readonly": True}, + "source_fabric_provider_id": {"readonly": True}, + "target_fabric_provider_id": {"readonly": True}, + "allowed_actions": {"readonly": True}, + "activity_id": {"readonly": True}, + "tasks": {"readonly": True}, + "errors": {"readonly": True}, + "custom_properties": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "object_id": {"key": "objectId", "type": "str"}, + "object_name": {"key": "objectName", "type": "str"}, + "object_internal_id": {"key": "objectInternalId", "type": "str"}, + "object_internal_name": {"key": "objectInternalName", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "replication_provider_id": {"key": "replicationProviderId", "type": "str"}, + "source_fabric_provider_id": {"key": "sourceFabricProviderId", "type": "str"}, + "target_fabric_provider_id": {"key": "targetFabricProviderId", "type": "str"}, + "allowed_actions": {"key": "allowedActions", "type": "[str]"}, + "activity_id": {"key": "activityId", "type": "str"}, + "tasks": {"key": "tasks", "type": "[TaskModel]"}, + "errors": {"key": "errors", "type": "[ErrorModel]"}, + "custom_properties": {"key": "customProperties", "type": "JobModelCustomProperties"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, custom_properties: "_models.JobModelCustomProperties", **kwargs: Any) -> None: + """ + :keyword custom_properties: Job model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomProperties + """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.display_name: Optional[str] = None + self.state: Optional[Union[str, "_models.JobState"]] = None + self.start_time: Optional[datetime.datetime] = None + self.end_time: Optional[datetime.datetime] = None + self.object_id: Optional[str] = None + self.object_name: Optional[str] = None + self.object_internal_id: Optional[str] = None + self.object_internal_name: Optional[str] = None + self.object_type: Optional[Union[str, "_models.JobObjectType"]] = None + self.replication_provider_id: Optional[str] = None + self.source_fabric_provider_id: Optional[str] = None + self.target_fabric_provider_id: Optional[str] = None + self.allowed_actions: Optional[List[str]] = None + self.activity_id: Optional[str] = None + self.tasks: Optional[List["_models.TaskModel"]] = None + self.errors: Optional[List["_models.ErrorModel"]] = None + self.custom_properties = custom_properties + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None -class OperationModel(_serialization.Model): - """Operation model. +class ManagedServiceIdentity(_serialization.Model): + """Managed service identity (system assigned and/or user assigned identities). - :ivar name: Gets or sets the name of the operation. - :vartype name: str - :ivar is_data_action: Gets or sets a value indicating whether the action is specific to data - plane or - control plane. - :vartype is_data_action: bool - :ivar origin: Gets or sets the executor of the operation. - :vartype origin: str - :ivar display: Operation model properties. - :vartype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationModelProperties + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :vartype type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.recoveryservicesdatareplication.models.UserAssignedIdentity] """ + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, + } + _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "origin": {"key": "origin", "type": "str"}, - "display": {"key": "display", "type": "OperationModelProperties"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - origin: Optional[str] = None, - display: Optional["_models.OperationModelProperties"] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs: Any ) -> None: """ - :keyword name: Gets or sets the name of the operation. - :paramtype name: str - :keyword is_data_action: Gets or sets a value indicating whether the action is specific to data - plane or - control plane. - :paramtype is_data_action: bool - :keyword origin: Gets or sets the executor of the operation. - :paramtype origin: str - :keyword display: Operation model properties. - :paramtype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationModelProperties + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :paramtype type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.recoveryservicesdatareplication.models.UserAssignedIdentity] """ super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.origin = origin - self.display = display + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + self.type = type + self.user_assigned_identities = user_assigned_identities + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. -class OperationModelCollection(_serialization.Model): - """Available operations of the service. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Gets or sets the list of operations. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.OperationModel] - :ivar next_link: Gets or sets the value of next link. - :vartype next_link: str + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationDisplay + :ivar origin: 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". + :vartype origin: str or ~azure.mgmt.recoveryservicesdatareplication.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.recoveryservicesdatareplication.models.ActionType """ + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[OperationModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, } - def __init__( - self, *, value: Optional[List["_models.OperationModel"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: """ - :keyword value: Gets or sets the list of operations. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.OperationModel] - :keyword next_link: Gets or sets the value of next link. - :paramtype next_link: str + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.recoveryservicesdatareplication.models.OperationDisplay """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.name: Optional[str] = None + self.is_data_action: Optional[bool] = None + self.display = display + self.origin: Optional[Union[str, "_models.Origin"]] = None + self.action_type: Optional[Union[str, "_models.ActionType"]] = None + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. -class OperationModelProperties(_serialization.Model): - """Operation model properties. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: Gets or sets the resource provider name. + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". :vartype provider: str - :ivar resource: Gets or sets resource name. + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". :vartype resource: str - :ivar operation: Gets or sets the operation. + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". :vartype operation: str - :ivar description: Gets or sets the description. + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. :vartype description: str """ + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, @@ -3308,30 +3528,42 @@ class OperationModelProperties(_serialization.Model): "description": {"key": "description", "type": "str"}, } - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Gets or sets the resource provider name. - :paramtype provider: str - :keyword resource: Gets or sets resource name. - :paramtype resource: str - :keyword operation: Gets or sets the operation. - :paramtype operation: str - :keyword description: Gets or sets the description. - :paramtype description: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.Operation"]] = None + self.next_link: Optional[str] = None class OperationStatus(_serialization.Model): @@ -3342,8 +3574,7 @@ class OperationStatus(_serialization.Model): :ivar name: Gets or sets the operation name. :vartype name: str :ivar status: Gets or sets the status of the operation. ARM expects the terminal status to be - one of - Succeeded/ Failed/ Canceled. All other values imply that the operation is still running. + one of Succeeded/ Failed/ Canceled. All other values imply that the operation is still running. :vartype status: str :ivar start_time: Gets or sets the start time. :vartype start_time: str @@ -3375,8 +3606,8 @@ def __init__( :keyword name: Gets or sets the operation name. :paramtype name: str :keyword status: Gets or sets the status of the operation. ARM expects the terminal status to - be one of - Succeeded/ Failed/ Canceled. All other values imply that the operation is still running. + be one of Succeeded/ Failed/ Canceled. All other values imply that the operation is still + running. :paramtype status: str :keyword start_time: Gets or sets the start time. :paramtype start_time: str @@ -3394,7 +3625,7 @@ def __init__( class PlannedFailoverModel(_serialization.Model): """Planned failover model. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar properties: Planned failover model properties. Required. :vartype properties: @@ -3422,7 +3653,7 @@ def __init__(self, *, properties: "_models.PlannedFailoverModelProperties", **kw class PlannedFailoverModelProperties(_serialization.Model): """Planned failover model properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar custom_properties: Planned failover model custom properties. Required. :vartype custom_properties: @@ -3437,37 +3668,441 @@ class PlannedFailoverModelProperties(_serialization.Model): "custom_properties": {"key": "customProperties", "type": "PlannedFailoverModelCustomProperties"}, } - def __init__(self, *, custom_properties: "_models.PlannedFailoverModelCustomProperties", **kwargs: Any) -> None: + def __init__(self, *, custom_properties: "_models.PlannedFailoverModelCustomProperties", **kwargs: Any) -> None: + """ + :keyword custom_properties: Planned failover model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModelCustomProperties + """ + super().__init__(**kwargs) + self.custom_properties = custom_properties + + +class PolicyModel(ProxyResource): + """Policy model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PolicyModelProperties"}, + } + + def __init__(self, *, properties: Optional["_models.PolicyModelProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class PolicyModelListResult(_serialization.Model): + """The response of a PolicyModel list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The PolicyModel items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PolicyModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.PolicyModel"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The PolicyModel items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyModelProperties(_serialization.Model): + """Policy model properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar provisioning_state: Gets or sets the provisioning state of the policy. Known values are: + "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState + :ivar custom_properties: Policy model custom properties. Required. + :vartype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelCustomProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "custom_properties": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "custom_properties": {"key": "customProperties", "type": "PolicyModelCustomProperties"}, + } + + def __init__(self, *, custom_properties: "_models.PolicyModelCustomProperties", **kwargs: Any) -> None: + """ + :keyword custom_properties: Policy model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelCustomProperties + """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.custom_properties = custom_properties + + +class PrivateEndpoint(_serialization.Model): + """Represent private Endpoint network resource that is linked to the Private Endpoint connection. + + :ivar id: Gets or sets the id. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Gets or sets the id. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class PrivateEndpointConnection(ProxyResource): + """Represents private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionResponseProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionResponseProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.PrivateEndpointConnectionResponseProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionResponseProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """The response of a PrivateEndpointConnection list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The PrivateEndpointConnection items on this page. Required. + :vartype value: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The PrivateEndpointConnection items on this page. Required. + :paramtype value: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateEndpointConnectionProxy(ProxyResource): + """Represents private endpoint connection proxy request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxyProperties + :ivar etag: Gets or sets ETag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProxyProperties"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProxyProperties"] = None, + etag: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxyProperties + :keyword etag: Gets or sets ETag. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.properties = properties + self.etag = etag + + +class PrivateEndpointConnectionProxyListResult(_serialization.Model): + """The response of a PrivateEndpointConnectionProxy list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The PrivateEndpointConnectionProxy items on this page. Required. + :vartype value: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnectionProxy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.PrivateEndpointConnectionProxy"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The PrivateEndpointConnectionProxy items on this page. Required. + :paramtype value: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateEndpointConnectionProxyProperties(_serialization.Model): + """Represents private endpoint connection proxy request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Gets or sets the provisioning state of the private endpoint + connection proxy. Known values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", + "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState + :ivar remote_private_endpoint: Represent remote private endpoint information for the private + endpoint connection proxy. + :vartype remote_private_endpoint: + ~azure.mgmt.recoveryservicesdatareplication.models.RemotePrivateEndpoint + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "remote_private_endpoint": {"key": "remotePrivateEndpoint", "type": "RemotePrivateEndpoint"}, + } + + def __init__( + self, *, remote_private_endpoint: Optional["_models.RemotePrivateEndpoint"] = None, **kwargs: Any + ) -> None: + """ + :keyword remote_private_endpoint: Represent remote private endpoint information for the private + endpoint connection proxy. + :paramtype remote_private_endpoint: + ~azure.mgmt.recoveryservicesdatareplication.models.RemotePrivateEndpoint + """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.remote_private_endpoint = remote_private_endpoint + + +class PrivateEndpointConnectionResponseProperties(_serialization.Model): # pylint: disable=name-too-long + """Represents Private endpoint connection response properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Gets or sets provisioning state of the private endpoint connection. + Known values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and + "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState + :ivar private_endpoint: Represent private Endpoint network resource that is linked to the + Private Endpoint connection. + :vartype private_endpoint: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpoint + :ivar private_link_service_connection_state: Represents Private link service connection state. + :vartype private_link_service_connection_state: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: """ - :keyword custom_properties: Planned failover model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModelCustomProperties + :keyword private_endpoint: Represent private Endpoint network resource that is linked to the + Private Endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpoint + :keyword private_link_service_connection_state: Represents Private link service connection + state. + :paramtype private_link_service_connection_state: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnectionState """ super().__init__(**kwargs) - self.custom_properties = custom_properties + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state -class PolicyModel(_serialization.Model): - """Policy model. +class PrivateLinkResource(ProxyResource): + """Represents private link resource. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Policy model properties. Required. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResourceProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -3475,47 +4110,50 @@ class PolicyModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "PolicyModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "PolicyModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, } - def __init__(self, *, properties: "_models.PolicyModelProperties", **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.PrivateLinkResourceProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Policy model properties. Required. - :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelProperties + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResourceProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class PolicyModelCollection(_serialization.Model): - """Policy model collection. +class PrivateLinkResourceListResult(_serialization.Model): + """The response of a PrivateLinkResource list operation. - :ivar value: Gets or sets the list of policies. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] - :ivar next_link: Gets or sets the value of next link. + All required parameters must be populated in order to send to server. + + :ivar value: The PrivateLinkResource items on this page. Required. + :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource] + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[PolicyModel]"}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, value: Optional[List["_models.PolicyModel"]] = None, next_link: Optional[str] = None, **kwargs: Any + self, *, value: List["_models.PrivateLinkResource"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of policies. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] - :keyword next_link: Gets or sets the value of next link. + :keyword value: The PrivateLinkResource items on this page. Required. + :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource] + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -3523,117 +4161,211 @@ def __init__( self.next_link = next_link -class PolicyModelProperties(_serialization.Model): - """Policy model properties. +class PrivateLinkResourceProperties(_serialization.Model): + """Represents private link resource properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar provisioning_state: Gets or sets the provisioning state of the policy. Known values are: - "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :ivar group_id: Gets or sets the group id. + :vartype group_id: str + :ivar required_members: Gets or sets the required member. This translates to how many Private + IPs should be created for each privately linkable resource. + :vartype required_members: list[str] + :ivar required_zone_names: Gets or sets the private DNS zone names. + :vartype required_zone_names: list[str] + :ivar provisioning_state: Gets or sets the provisioning state of the private link resource. + Known values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and + "Updating". :vartype provisioning_state: str or ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState - :ivar custom_properties: Policy model custom properties. Required. - :vartype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelCustomProperties """ _validation = { "provisioning_state": {"readonly": True}, - "custom_properties": {"required": True}, } _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, - "custom_properties": {"key": "customProperties", "type": "PolicyModelCustomProperties"}, } - def __init__(self, *, custom_properties: "_models.PolicyModelCustomProperties", **kwargs: Any) -> None: + def __init__( + self, + *, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs: Any + ) -> None: """ - :keyword custom_properties: Policy model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModelCustomProperties + :keyword group_id: Gets or sets the group id. + :paramtype group_id: str + :keyword required_members: Gets or sets the required member. This translates to how many + Private IPs should be created for each privately linkable resource. + :paramtype required_members: list[str] + :keyword required_zone_names: Gets or sets the private DNS zone names. + :paramtype required_zone_names: list[str] """ super().__init__(**kwargs) - self.provisioning_state = None - self.custom_properties = custom_properties + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None -class PolicyModelSystemData(SystemDataModel): - """PolicyModelSystemData. +class PrivateLinkServiceConnection(_serialization.Model): + """Represents of an NRP private link service connection. - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + :ivar name: Gets or sets private link service connection name. + :vartype name: str + :ivar group_ids: Gets or sets group ids. + :vartype group_ids: list[str] + :ivar request_message: Gets or sets the request message for the private link service + connection. + :vartype request_message: str """ _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "group_ids": {"key": "groupIds", "type": "[str]"}, + "request_message": {"key": "requestMessage", "type": "str"}, } def __init__( self, *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, + name: Optional[str] = None, + group_ids: Optional[List[str]] = None, + request_message: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword name: Gets or sets private link service connection name. + :paramtype name: str + :keyword group_ids: Gets or sets group ids. + :paramtype group_ids: list[str] + :keyword request_message: Gets or sets the request message for the private link service + connection. + :paramtype request_message: str + """ + super().__init__(**kwargs) + self.name = name + self.group_ids = group_ids + self.request_message = request_message + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """Represents Private link service connection state. + + :ivar status: Gets or sets the status. Known values are: "Approved", "Disconnected", "Pending", + and "Rejected". + :vartype status: str or + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionStatus + :ivar description: Gets or sets description. + :vartype description: str + :ivar actions_required: Gets or sets actions required. + :vartype actions_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Gets or sets the status. Known values are: "Approved", "Disconnected", + "Pending", and "Rejected". + :paramtype status: str or + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionStatus + :keyword description: Gets or sets description. + :paramtype description: str + :keyword actions_required: Gets or sets actions required. + :paramtype actions_required: str """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class PrivateLinkServiceProxy(_serialization.Model): + """Represents NRP private link service proxy. + + :ivar id: Gets or sets private link service proxy id. + :vartype id: str + :ivar remote_private_link_service_connection_state: Represents Private link service connection + state. + :vartype remote_private_link_service_connection_state: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnectionState + :ivar remote_private_endpoint_connection: Represent remote private endpoint connection. + :vartype remote_private_endpoint_connection: + ~azure.mgmt.recoveryservicesdatareplication.models.RemotePrivateEndpointConnection + :ivar group_connectivity_information: Gets or sets group connectivity information. + :vartype group_connectivity_information: + list[~azure.mgmt.recoveryservicesdatareplication.models.GroupConnectivityInformation] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "remote_private_link_service_connection_state": { + "key": "remotePrivateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "remote_private_endpoint_connection": { + "key": "remotePrivateEndpointConnection", + "type": "RemotePrivateEndpointConnection", + }, + "group_connectivity_information": { + "key": "groupConnectivityInformation", + "type": "[GroupConnectivityInformation]", + }, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + remote_private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + remote_private_endpoint_connection: Optional["_models.RemotePrivateEndpointConnection"] = None, + group_connectivity_information: Optional[List["_models.GroupConnectivityInformation"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Gets or sets private link service proxy id. + :paramtype id: str + :keyword remote_private_link_service_connection_state: Represents Private link service + connection state. + :paramtype remote_private_link_service_connection_state: + ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnectionState + :keyword remote_private_endpoint_connection: Represent remote private endpoint connection. + :paramtype remote_private_endpoint_connection: + ~azure.mgmt.recoveryservicesdatareplication.models.RemotePrivateEndpointConnection + :keyword group_connectivity_information: Gets or sets group connectivity information. + :paramtype group_connectivity_information: + list[~azure.mgmt.recoveryservicesdatareplication.models.GroupConnectivityInformation] + """ + super().__init__(**kwargs) + self.id = id + self.remote_private_link_service_connection_state = remote_private_link_service_connection_state + self.remote_private_endpoint_connection = remote_private_endpoint_connection + self.group_connectivity_information = group_connectivity_information class ProtectedItemDynamicMemoryConfig(_serialization.Model): """Protected item dynamic memory config. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar maximum_memory_in_mega_bytes: Gets or sets maximum memory in MB. Required. :vartype maximum_memory_in_mega_bytes: int @@ -3684,17 +4416,17 @@ class ProtectedItemJobProperties(_serialization.Model): :ivar scenario_name: Gets or sets protection scenario name. :vartype scenario_name: str - :ivar id: Gets or sets workflow Id. + :ivar id: Gets or sets job Id. :vartype id: str - :ivar name: Gets or sets workflow name. + :ivar name: Gets or sets job name. :vartype name: str - :ivar display_name: Gets or sets the workflow friendly display name. + :ivar display_name: Gets or sets the job friendly display name. :vartype display_name: str - :ivar state: Gets or sets workflow state. + :ivar state: Gets or sets job state. :vartype state: str - :ivar start_time: Gets or sets start time of the workflow. + :ivar start_time: Gets or sets start time of the job. :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets end time of the workflow. + :ivar end_time: Gets or sets end time of the job. :vartype end_time: ~datetime.datetime """ @@ -3721,38 +4453,37 @@ class ProtectedItemJobProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.scenario_name = None - self.id = None - self.name = None - self.display_name = None - self.state = None - self.start_time = None - self.end_time = None + self.scenario_name: Optional[str] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.display_name: Optional[str] = None + self.state: Optional[str] = None + self.start_time: Optional[datetime.datetime] = None + self.end_time: Optional[datetime.datetime] = None -class ProtectedItemModel(_serialization.Model): +class ProtectedItemModel(ProxyResource): """Protected item model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Protected item model properties. Required. - :vartype properties: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -3760,52 +4491,50 @@ class ProtectedItemModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "ProtectedItemModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "ProtectedItemModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ProtectedItemModelProperties"}, } - def __init__(self, *, properties: "_models.ProtectedItemModelProperties", **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.ProtectedItemModelProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Protected item model properties. Required. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class ProtectedItemModelCollection(_serialization.Model): - """Protected item model collection. +class ProtectedItemModelListResult(_serialization.Model): + """The response of a ProtectedItemModel list operation. - :ivar value: Gets or sets the list of protected items. + All required parameters must be populated in order to send to server. + + :ivar value: The ProtectedItemModel items on this page. Required. :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] - :ivar next_link: Gets or sets the value of next link. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[ProtectedItemModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ProtectedItemModel"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.ProtectedItemModel"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of protected items. + :keyword value: The ProtectedItemModel items on this page. Required. :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] - :keyword next_link: Gets or sets the value of next link. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -3813,12 +4542,12 @@ def __init__( self.next_link = next_link -class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ProtectedItemModelProperties(_serialization.Model): """Protected item model properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar policy_name: Gets or sets the policy name. Required. :vartype policy_name: str @@ -3826,8 +4555,8 @@ class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too :vartype replication_extension_name: str :ivar correlation_id: Gets or sets the protected item correlation Id. :vartype correlation_id: str - :ivar provisioning_state: Gets or sets the provisioning state of the Dra. Known values are: - "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". + :ivar provisioning_state: Gets or sets the provisioning state of the fabric agent. Known values + are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState :ivar protection_state: Gets or sets the protection state. Known values are: @@ -3880,10 +4609,10 @@ class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too :vartype fabric_id: str :ivar target_fabric_id: Gets or sets the target fabric Id. :vartype target_fabric_id: str - :ivar dra_id: Gets or sets the DRA Id. - :vartype dra_id: str - :ivar target_dra_id: Gets or sets the target DRA Id. - :vartype target_dra_id: str + :ivar fabric_agent_id: Gets or sets the fabric agent Id. + :vartype fabric_agent_id: str + :ivar target_fabric_agent_id: Gets or sets the target fabric agent Id. + :vartype target_fabric_agent_id: str :ivar resync_required: Gets or sets a value indicating whether resynchronization is required or not. :vartype resync_required: bool @@ -3895,20 +4624,20 @@ class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too :vartype last_successful_unplanned_failover_time: ~datetime.datetime :ivar last_successful_test_failover_time: Gets or sets the Last successful test failover time. :vartype last_successful_test_failover_time: ~datetime.datetime - :ivar current_job: + :ivar current_job: Gets or sets the current scenario. :vartype current_job: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesCurrentJob + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemJobProperties :ivar allowed_jobs: Gets or sets the allowed scenarios on the protected item. :vartype allowed_jobs: list[str] - :ivar last_failed_enable_protection_job: + :ivar last_failed_enable_protection_job: Gets or sets the last failed enabled protection job. :vartype last_failed_enable_protection_job: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesLastFailedEnableProtectionJob - :ivar last_failed_planned_failover_job: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemJobProperties + :ivar last_failed_planned_failover_job: Gets or sets the last failed planned failover job. :vartype last_failed_planned_failover_job: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesLastFailedPlannedFailoverJob - :ivar last_test_failover_job: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemJobProperties + :ivar last_test_failover_job: Gets or sets the last test failover job. :vartype last_test_failover_job: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesLastTestFailoverJob + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemJobProperties :ivar replication_health: Gets or sets protected item replication health. Known values are: "Normal", "Warning", and "Critical". :vartype replication_health: str or @@ -3937,8 +4666,8 @@ class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too "target_fabric_provider_id": {"readonly": True}, "fabric_id": {"readonly": True}, "target_fabric_id": {"readonly": True}, - "dra_id": {"readonly": True}, - "target_dra_id": {"readonly": True}, + "fabric_agent_id": {"readonly": True}, + "target_fabric_agent_id": {"readonly": True}, "resync_required": {"readonly": True}, "last_successful_planned_failover_time": {"readonly": True}, "last_successful_unplanned_failover_time": {"readonly": True}, @@ -3964,362 +4693,177 @@ class ProtectedItemModelProperties(_serialization.Model): # pylint: disable=too "test_failover_state_description": {"key": "testFailoverStateDescription", "type": "str"}, "resynchronization_state": {"key": "resynchronizationState", "type": "str"}, "fabric_object_id": {"key": "fabricObjectId", "type": "str"}, - "fabric_object_name": {"key": "fabricObjectName", "type": "str"}, - "source_fabric_provider_id": {"key": "sourceFabricProviderId", "type": "str"}, - "target_fabric_provider_id": {"key": "targetFabricProviderId", "type": "str"}, - "fabric_id": {"key": "fabricId", "type": "str"}, - "target_fabric_id": {"key": "targetFabricId", "type": "str"}, - "dra_id": {"key": "draId", "type": "str"}, - "target_dra_id": {"key": "targetDraId", "type": "str"}, - "resync_required": {"key": "resyncRequired", "type": "bool"}, - "last_successful_planned_failover_time": {"key": "lastSuccessfulPlannedFailoverTime", "type": "iso-8601"}, - "last_successful_unplanned_failover_time": {"key": "lastSuccessfulUnplannedFailoverTime", "type": "iso-8601"}, - "last_successful_test_failover_time": {"key": "lastSuccessfulTestFailoverTime", "type": "iso-8601"}, - "current_job": {"key": "currentJob", "type": "ProtectedItemModelPropertiesCurrentJob"}, - "allowed_jobs": {"key": "allowedJobs", "type": "[str]"}, - "last_failed_enable_protection_job": { - "key": "lastFailedEnableProtectionJob", - "type": "ProtectedItemModelPropertiesLastFailedEnableProtectionJob", - }, - "last_failed_planned_failover_job": { - "key": "lastFailedPlannedFailoverJob", - "type": "ProtectedItemModelPropertiesLastFailedPlannedFailoverJob", - }, - "last_test_failover_job": { - "key": "lastTestFailoverJob", - "type": "ProtectedItemModelPropertiesLastTestFailoverJob", - }, - "replication_health": {"key": "replicationHealth", "type": "str"}, - "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, - "custom_properties": {"key": "customProperties", "type": "ProtectedItemModelCustomProperties"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - policy_name: str, - replication_extension_name: str, - custom_properties: "_models.ProtectedItemModelCustomProperties", - **kwargs: Any - ) -> None: - """ - :keyword policy_name: Gets or sets the policy name. Required. - :paramtype policy_name: str - :keyword replication_extension_name: Gets or sets the replication extension name. Required. - :paramtype replication_extension_name: str - :keyword custom_properties: Protected item model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelCustomProperties - """ - super().__init__(**kwargs) - self.policy_name = policy_name - self.replication_extension_name = replication_extension_name - self.correlation_id = None - self.provisioning_state = None - self.protection_state = None - self.protection_state_description = None - self.test_failover_state = None - self.test_failover_state_description = None - self.resynchronization_state = None - self.fabric_object_id = None - self.fabric_object_name = None - self.source_fabric_provider_id = None - self.target_fabric_provider_id = None - self.fabric_id = None - self.target_fabric_id = None - self.dra_id = None - self.target_dra_id = None - self.resync_required = None - self.last_successful_planned_failover_time = None - self.last_successful_unplanned_failover_time = None - self.last_successful_test_failover_time = None - self.current_job = None - self.allowed_jobs = None - self.last_failed_enable_protection_job = None - self.last_failed_planned_failover_job = None - self.last_test_failover_job = None - self.replication_health = None - self.health_errors = None - self.custom_properties = custom_properties - - -class ProtectedItemModelPropertiesCurrentJob(ProtectedItemJobProperties): - """ProtectedItemModelPropertiesCurrentJob. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar scenario_name: Gets or sets protection scenario name. - :vartype scenario_name: str - :ivar id: Gets or sets workflow Id. - :vartype id: str - :ivar name: Gets or sets workflow name. - :vartype name: str - :ivar display_name: Gets or sets the workflow friendly display name. - :vartype display_name: str - :ivar state: Gets or sets workflow state. - :vartype state: str - :ivar start_time: Gets or sets start time of the workflow. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets end time of the workflow. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "scenario_name": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "display_name": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "scenario_name": {"key": "scenarioName", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class ProtectedItemModelPropertiesLastFailedEnableProtectionJob(ProtectedItemJobProperties): - """ProtectedItemModelPropertiesLastFailedEnableProtectionJob. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar scenario_name: Gets or sets protection scenario name. - :vartype scenario_name: str - :ivar id: Gets or sets workflow Id. - :vartype id: str - :ivar name: Gets or sets workflow name. - :vartype name: str - :ivar display_name: Gets or sets the workflow friendly display name. - :vartype display_name: str - :ivar state: Gets or sets workflow state. - :vartype state: str - :ivar start_time: Gets or sets start time of the workflow. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets end time of the workflow. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "scenario_name": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "display_name": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "scenario_name": {"key": "scenarioName", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, + "fabric_object_name": {"key": "fabricObjectName", "type": "str"}, + "source_fabric_provider_id": {"key": "sourceFabricProviderId", "type": "str"}, + "target_fabric_provider_id": {"key": "targetFabricProviderId", "type": "str"}, + "fabric_id": {"key": "fabricId", "type": "str"}, + "target_fabric_id": {"key": "targetFabricId", "type": "str"}, + "fabric_agent_id": {"key": "fabricAgentId", "type": "str"}, + "target_fabric_agent_id": {"key": "targetFabricAgentId", "type": "str"}, + "resync_required": {"key": "resyncRequired", "type": "bool"}, + "last_successful_planned_failover_time": {"key": "lastSuccessfulPlannedFailoverTime", "type": "iso-8601"}, + "last_successful_unplanned_failover_time": {"key": "lastSuccessfulUnplannedFailoverTime", "type": "iso-8601"}, + "last_successful_test_failover_time": {"key": "lastSuccessfulTestFailoverTime", "type": "iso-8601"}, + "current_job": {"key": "currentJob", "type": "ProtectedItemJobProperties"}, + "allowed_jobs": {"key": "allowedJobs", "type": "[str]"}, + "last_failed_enable_protection_job": { + "key": "lastFailedEnableProtectionJob", + "type": "ProtectedItemJobProperties", + }, + "last_failed_planned_failover_job": { + "key": "lastFailedPlannedFailoverJob", + "type": "ProtectedItemJobProperties", + }, + "last_test_failover_job": {"key": "lastTestFailoverJob", "type": "ProtectedItemJobProperties"}, + "replication_health": {"key": "replicationHealth", "type": "str"}, + "health_errors": {"key": "healthErrors", "type": "[HealthErrorModel]"}, + "custom_properties": {"key": "customProperties", "type": "ProtectedItemModelCustomProperties"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( # pylint: disable=too-many-locals + self, + *, + policy_name: str, + replication_extension_name: str, + custom_properties: "_models.ProtectedItemModelCustomProperties", + **kwargs: Any + ) -> None: + """ + :keyword policy_name: Gets or sets the policy name. Required. + :paramtype policy_name: str + :keyword replication_extension_name: Gets or sets the replication extension name. Required. + :paramtype replication_extension_name: str + :keyword custom_properties: Protected item model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelCustomProperties + """ super().__init__(**kwargs) + self.policy_name = policy_name + self.replication_extension_name = replication_extension_name + self.correlation_id: Optional[str] = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.protection_state: Optional[Union[str, "_models.ProtectionState"]] = None + self.protection_state_description: Optional[str] = None + self.test_failover_state: Optional[Union[str, "_models.TestFailoverState"]] = None + self.test_failover_state_description: Optional[str] = None + self.resynchronization_state: Optional[Union[str, "_models.ResynchronizationState"]] = None + self.fabric_object_id: Optional[str] = None + self.fabric_object_name: Optional[str] = None + self.source_fabric_provider_id: Optional[str] = None + self.target_fabric_provider_id: Optional[str] = None + self.fabric_id: Optional[str] = None + self.target_fabric_id: Optional[str] = None + self.fabric_agent_id: Optional[str] = None + self.target_fabric_agent_id: Optional[str] = None + self.resync_required: Optional[bool] = None + self.last_successful_planned_failover_time: Optional[datetime.datetime] = None + self.last_successful_unplanned_failover_time: Optional[datetime.datetime] = None + self.last_successful_test_failover_time: Optional[datetime.datetime] = None + self.current_job: Optional["_models.ProtectedItemJobProperties"] = None + self.allowed_jobs: Optional[List[str]] = None + self.last_failed_enable_protection_job: Optional["_models.ProtectedItemJobProperties"] = None + self.last_failed_planned_failover_job: Optional["_models.ProtectedItemJobProperties"] = None + self.last_test_failover_job: Optional["_models.ProtectedItemJobProperties"] = None + self.replication_health: Optional[Union[str, "_models.HealthStatus"]] = None + self.health_errors: Optional[List["_models.HealthErrorModel"]] = None + self.custom_properties = custom_properties -class ProtectedItemModelPropertiesLastFailedPlannedFailoverJob(ProtectedItemJobProperties): - """ProtectedItemModelPropertiesLastFailedPlannedFailoverJob. - - Variables are only populated by the server, and will be ignored when sending a request. +class ProtectedItemModelPropertiesUpdate(_serialization.Model): + """Protected item model properties update. - :ivar scenario_name: Gets or sets protection scenario name. - :vartype scenario_name: str - :ivar id: Gets or sets workflow Id. - :vartype id: str - :ivar name: Gets or sets workflow name. - :vartype name: str - :ivar display_name: Gets or sets the workflow friendly display name. - :vartype display_name: str - :ivar state: Gets or sets workflow state. - :vartype state: str - :ivar start_time: Gets or sets start time of the workflow. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets end time of the workflow. - :vartype end_time: ~datetime.datetime + :ivar custom_properties: Protected item model custom properties update. + :vartype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelCustomPropertiesUpdate """ - _validation = { - "scenario_name": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "display_name": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - _attribute_map = { - "scenario_name": {"key": "scenarioName", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, + "custom_properties": {"key": "customProperties", "type": "ProtectedItemModelCustomPropertiesUpdate"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, custom_properties: Optional["_models.ProtectedItemModelCustomPropertiesUpdate"] = None, **kwargs: Any + ) -> None: + """ + :keyword custom_properties: Protected item model custom properties update. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelCustomPropertiesUpdate + """ super().__init__(**kwargs) + self.custom_properties = custom_properties -class ProtectedItemModelPropertiesLastTestFailoverJob(ProtectedItemJobProperties): - """ProtectedItemModelPropertiesLastTestFailoverJob. +class ProtectedItemModelUpdate(_serialization.Model): + """Protected item model update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar scenario_name: Gets or sets protection scenario name. - :vartype scenario_name: str - :ivar id: Gets or sets workflow Id. + :ivar properties: Protected item model properties. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesUpdate + :ivar id: Gets or sets the Id of the resource. :vartype id: str - :ivar name: Gets or sets workflow name. + :ivar name: Gets or sets the name of the resource. :vartype name: str - :ivar display_name: Gets or sets the workflow friendly display name. - :vartype display_name: str - :ivar state: Gets or sets workflow state. - :vartype state: str - :ivar start_time: Gets or sets start time of the workflow. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets end time of the workflow. - :vartype end_time: ~datetime.datetime + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData """ _validation = { - "scenario_name": {"readonly": True}, "id": {"readonly": True}, "name": {"readonly": True}, - "display_name": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - "scenario_name": {"key": "scenarioName", "type": "str"}, + "properties": {"key": "properties", "type": "ProtectedItemModelPropertiesUpdate"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class ProtectedItemModelSystemData(SystemDataModel): - """ProtectedItemModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any + self, *, properties: Optional["_models.ProtectedItemModelPropertiesUpdate"] = None, **kwargs: Any ) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword properties: Protected item model properties. + :paramtype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelPropertiesUpdate """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + super().__init__(**kwargs) + self.properties = properties + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None -class RecoveryPointModel(_serialization.Model): +class RecoveryPointModel(ProxyResource): """Recovery point model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Recovery point model properties. Required. - :vartype properties: - ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModelProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -4327,52 +4871,50 @@ class RecoveryPointModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "RecoveryPointModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "RecoveryPointModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "RecoveryPointModelProperties"}, } - def __init__(self, *, properties: "_models.RecoveryPointModelProperties", **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.RecoveryPointModelProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Recovery point model properties. Required. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModelProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class RecoveryPointModelCollection(_serialization.Model): - """Recovery point model collection. +class RecoveryPointModelListResult(_serialization.Model): + """The response of a RecoveryPointModel list operation. + + All required parameters must be populated in order to send to server. - :ivar value: Gets or sets the list of recovery points. + :ivar value: The RecoveryPointModel items on this page. Required. :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel] - :ivar next_link: Gets or sets the value of next link. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[RecoveryPointModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.RecoveryPointModel"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.RecoveryPointModel"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of recovery points. + :keyword value: The RecoveryPointModel items on this page. Required. :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel] - :keyword next_link: Gets or sets the value of next link. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -4383,7 +4925,9 @@ def __init__( class RecoveryPointModelProperties(_serialization.Model): """Recovery point model properties. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. :ivar recovery_point_time: Gets or sets the recovery point time. Required. :vartype recovery_point_time: ~datetime.datetime @@ -4394,18 +4938,25 @@ class RecoveryPointModelProperties(_serialization.Model): :ivar custom_properties: Recovery point model custom properties. Required. :vartype custom_properties: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModelCustomProperties + :ivar provisioning_state: Gets or sets the provisioning state of the recovery point item. Known + values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and + "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.recoveryservicesdatareplication.models.ProvisioningState """ _validation = { "recovery_point_time": {"required": True}, "recovery_point_type": {"required": True}, "custom_properties": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { "recovery_point_time": {"key": "recoveryPointTime", "type": "iso-8601"}, "recovery_point_type": {"key": "recoveryPointType", "type": "str"}, "custom_properties": {"key": "customProperties", "type": "RecoveryPointModelCustomProperties"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -4431,101 +4982,130 @@ def __init__( self.recovery_point_time = recovery_point_time self.recovery_point_type = recovery_point_type self.custom_properties = custom_properties + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None -class RecoveryPointModelSystemData(SystemDataModel): - """RecoveryPointModelSystemData. +class RemotePrivateEndpoint(_serialization.Model): + """Represent remote private endpoint information for the private endpoint connection proxy. - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + All required parameters must be populated in order to send to server. + + :ivar id: Gets or sets private link service proxy id. Required. + :vartype id: str + :ivar private_link_service_connections: Gets or sets the list of Private Link Service + Connections and gets populated for Auto approval flow. + :vartype private_link_service_connections: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnection] + :ivar manual_private_link_service_connections: Gets or sets the list of Manual Private Link + Service Connections and gets populated for Manual approval flow. + :vartype manual_private_link_service_connections: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnection] + :ivar private_link_service_proxies: Gets or sets the list of private link service proxies. + :vartype private_link_service_proxies: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceProxy] + :ivar connection_details: Gets or sets the list of Connection Details. This is the connection + details for private endpoint. + :vartype connection_details: + list[~azure.mgmt.recoveryservicesdatareplication.models.ConnectionDetails] """ + _validation = { + "id": {"required": True, "min_length": 1}, + } + _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "id": {"key": "id", "type": "str"}, + "private_link_service_connections": { + "key": "privateLinkServiceConnections", + "type": "[PrivateLinkServiceConnection]", + }, + "manual_private_link_service_connections": { + "key": "manualPrivateLinkServiceConnections", + "type": "[PrivateLinkServiceConnection]", + }, + "private_link_service_proxies": {"key": "privateLinkServiceProxies", "type": "[PrivateLinkServiceProxy]"}, + "connection_details": {"key": "connectionDetails", "type": "[ConnectionDetails]"}, } def __init__( self, *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, + id: str, # pylint: disable=redefined-builtin + private_link_service_connections: Optional[List["_models.PrivateLinkServiceConnection"]] = None, + manual_private_link_service_connections: Optional[List["_models.PrivateLinkServiceConnection"]] = None, + private_link_service_proxies: Optional[List["_models.PrivateLinkServiceProxy"]] = None, + connection_details: Optional[List["_models.ConnectionDetails"]] = None, **kwargs: Any ) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword id: Gets or sets private link service proxy id. Required. + :paramtype id: str + :keyword private_link_service_connections: Gets or sets the list of Private Link Service + Connections and gets populated for Auto approval flow. + :paramtype private_link_service_connections: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnection] + :keyword manual_private_link_service_connections: Gets or sets the list of Manual Private Link + Service Connections and gets populated for Manual approval flow. + :paramtype manual_private_link_service_connections: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceConnection] + :keyword private_link_service_proxies: Gets or sets the list of private link service proxies. + :paramtype private_link_service_proxies: + list[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkServiceProxy] + :keyword connection_details: Gets or sets the list of Connection Details. This is the + connection details for private endpoint. + :paramtype connection_details: + list[~azure.mgmt.recoveryservicesdatareplication.models.ConnectionDetails] + """ + super().__init__(**kwargs) + self.id = id + self.private_link_service_connections = private_link_service_connections + self.manual_private_link_service_connections = manual_private_link_service_connections + self.private_link_service_proxies = private_link_service_proxies + self.connection_details = connection_details + + +class RemotePrivateEndpointConnection(_serialization.Model): + """Represent remote private endpoint connection. + + :ivar id: Gets or sets the remote private endpoint connection id. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Gets or sets the remote private endpoint connection id. + :paramtype id: str """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + super().__init__(**kwargs) + self.id = id -class ReplicationExtensionModel(_serialization.Model): +class ReplicationExtensionModel(ProxyResource): """Replication extension model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar properties: Replication extension model properties. Required. - :vartype properties: - ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelProperties """ _validation = { - "properties": {"required": True}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, @@ -4533,54 +5113,54 @@ class ReplicationExtensionModel(_serialization.Model): } _attribute_map = { - "properties": {"key": "properties", "type": "ReplicationExtensionModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "ReplicationExtensionModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ReplicationExtensionModelProperties"}, } - def __init__(self, *, properties: "_models.ReplicationExtensionModelProperties", **kwargs: Any) -> None: + def __init__( + self, *, properties: Optional["_models.ReplicationExtensionModelProperties"] = None, **kwargs: Any + ) -> None: """ - :keyword properties: Replication extension model properties. Required. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None -class ReplicationExtensionModelCollection(_serialization.Model): - """Replication extension model collection. +class ReplicationExtensionModelListResult(_serialization.Model): + """The response of a ReplicationExtensionModel list operation. - :ivar value: Gets or sets the list of replication extensions. + All required parameters must be populated in order to send to server. + + :ivar value: The ReplicationExtensionModel items on this page. Required. :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] - :ivar next_link: Gets or sets the value of next link. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[ReplicationExtensionModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ReplicationExtensionModel"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.ReplicationExtensionModel"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets or sets the list of replication extensions. + :keyword value: The ReplicationExtensionModel items on this page. Required. :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] - :keyword next_link: Gets or sets the value of next link. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -4593,7 +5173,7 @@ class ReplicationExtensionModelProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar provisioning_state: Gets or sets the provisioning state of the replication extension. Known values are: "Canceled", "Creating", "Deleting", "Deleted", "Failed", "Succeeded", and @@ -4606,46 +5186,79 @@ class ReplicationExtensionModelProperties(_serialization.Model): """ _validation = { - "provisioning_state": {"readonly": True}, - "custom_properties": {"required": True}, + "provisioning_state": {"readonly": True}, + "custom_properties": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "custom_properties": {"key": "customProperties", "type": "ReplicationExtensionModelCustomProperties"}, + } + + def __init__( + self, *, custom_properties: "_models.ReplicationExtensionModelCustomProperties", **kwargs: Any + ) -> None: + """ + :keyword custom_properties: Replication extension model custom properties. Required. + :paramtype custom_properties: + ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelCustomProperties + """ + super().__init__(**kwargs) + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.custom_properties = custom_properties + + +class StorageContainerProperties(_serialization.Model): + """Storage container properties. + + All required parameters must be populated in order to send to server. + + :ivar name: Gets or sets the Name. Required. + :vartype name: str + :ivar cluster_shared_volume_path: Gets or sets the ClusterSharedVolumePath. Required. + :vartype cluster_shared_volume_path: str + """ + + _validation = { + "name": {"required": True, "min_length": 1}, + "cluster_shared_volume_path": {"required": True, "min_length": 1}, } _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "custom_properties": {"key": "customProperties", "type": "ReplicationExtensionModelCustomProperties"}, + "name": {"key": "name", "type": "str"}, + "cluster_shared_volume_path": {"key": "clusterSharedVolumePath", "type": "str"}, } - def __init__( - self, *, custom_properties: "_models.ReplicationExtensionModelCustomProperties", **kwargs: Any - ) -> None: + def __init__(self, *, name: str, cluster_shared_volume_path: str, **kwargs: Any) -> None: """ - :keyword custom_properties: Replication extension model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModelCustomProperties + :keyword name: Gets or sets the Name. Required. + :paramtype name: str + :keyword cluster_shared_volume_path: Gets or sets the ClusterSharedVolumePath. Required. + :paramtype cluster_shared_volume_path: str """ super().__init__(**kwargs) - self.provisioning_state = None - self.custom_properties = custom_properties + self.name = name + self.cluster_shared_volume_path = cluster_shared_volume_path -class ReplicationExtensionModelSystemData(SystemDataModel): - """ReplicationExtensionModelSystemData. +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. - :ivar created_by: Gets or sets identity that created the resource. + :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. + :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -4662,73 +5275,38 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs: Any ) -> None: """ - :keyword created_by: Gets or sets identity that created the resource. + :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. + :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.recoveryservicesdatareplication.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class StorageContainerProperties(_serialization.Model): - """Storage container properties. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Gets or sets the Name. Required. - :vartype name: str - :ivar cluster_shared_volume_path: Gets or sets the ClusterSharedVolumePath. Required. - :vartype cluster_shared_volume_path: str - """ - - _validation = { - "name": {"required": True, "min_length": 1}, - "cluster_shared_volume_path": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "cluster_shared_volume_path": {"key": "clusterSharedVolumePath", "type": "str"}, - } - - def __init__(self, *, name: str, cluster_shared_volume_path: str, **kwargs: Any) -> None: - """ - :keyword name: Gets or sets the Name. Required. - :paramtype name: str - :keyword cluster_shared_volume_path: Gets or sets the ClusterSharedVolumePath. Required. - :paramtype cluster_shared_volume_path: str - """ super().__init__(**kwargs) - self.name = name - self.cluster_shared_volume_path = cluster_shared_volume_path + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at class TaskModel(_serialization.Model): @@ -4748,9 +5326,8 @@ class TaskModel(_serialization.Model): :ivar custom_properties: Task model custom properties. :vartype custom_properties: ~azure.mgmt.recoveryservicesdatareplication.models.TaskModelCustomProperties - :ivar children_workflows: Gets or sets the list of children workflow models. - :vartype children_workflows: - list[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] + :ivar children_jobs: Gets or sets the list of children job models. + :vartype children_jobs: list[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] """ _validation = { @@ -4766,37 +5343,36 @@ class TaskModel(_serialization.Model): "start_time": {"key": "startTime", "type": "iso-8601"}, "end_time": {"key": "endTime", "type": "iso-8601"}, "custom_properties": {"key": "customProperties", "type": "TaskModelCustomProperties"}, - "children_workflows": {"key": "childrenWorkflows", "type": "[WorkflowModel]"}, + "children_jobs": {"key": "childrenJobs", "type": "[JobModel]"}, } def __init__( self, *, custom_properties: Optional["_models.TaskModelCustomProperties"] = None, - children_workflows: Optional[List["_models.WorkflowModel"]] = None, + children_jobs: Optional[List["_models.JobModel"]] = None, **kwargs: Any ) -> None: """ :keyword custom_properties: Task model custom properties. :paramtype custom_properties: ~azure.mgmt.recoveryservicesdatareplication.models.TaskModelCustomProperties - :keyword children_workflows: Gets or sets the list of children workflow models. - :paramtype children_workflows: - list[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] + :keyword children_jobs: Gets or sets the list of children job models. + :paramtype children_jobs: list[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] """ super().__init__(**kwargs) - self.task_name = None - self.state = None - self.start_time = None - self.end_time = None + self.task_name: Optional[str] = None + self.state: Optional[Union[str, "_models.TaskState"]] = None + self.start_time: Optional[datetime.datetime] = None + self.end_time: Optional[datetime.datetime] = None self.custom_properties = custom_properties - self.children_workflows = children_workflows + self.children_jobs = children_jobs class TaskModelCustomProperties(_serialization.Model): """Task model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar instance_type: Gets or sets the instance type. Required. :vartype instance_type: str @@ -4819,114 +5395,198 @@ def __init__(self, *, instance_type: str, **kwargs: Any) -> None: self.instance_type = instance_type -class TestFailoverCleanupWorkflowModelCustomProperties(WorkflowModelCustomProperties): - """Test failover cleanup workflow model custom properties. +class TestFailoverCleanupJobModelCustomProperties(JobModelCustomProperties): # pylint: disable=name-too-long + """Test failover cleanup job model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for JobModelCustomProperties. Required. :vartype instance_type: str :ivar affected_object_details: Gets or sets any custom properties of the affected object. - :vartype affected_object_details: dict[str, str] + :vartype affected_object_details: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomPropertiesAffectedObjectDetails :ivar comments: Gets or sets the test failover cleanup comments. :vartype comments: str """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "affected_object_details": {"readonly": True}, "comments": {"readonly": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, - "affected_object_details": {"key": "affectedObjectDetails", "type": "{str}"}, + "affected_object_details": { + "key": "affectedObjectDetails", + "type": "JobModelCustomPropertiesAffectedObjectDetails", + }, "comments": {"key": "comments", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.instance_type: str = "TestFailoverCleanupWorkflowDetails" - self.comments = None + self.instance_type: str = "TestFailoverCleanupJobDetails" + self.comments: Optional[str] = None -class TestFailoverWorkflowModelCustomProperties(WorkflowModelCustomProperties): - """Test failover workflow model custom properties. +class TestFailoverJobModelCustomProperties(JobModelCustomProperties): + """Test failover job model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for JobModelCustomProperties. Required. :vartype instance_type: str :ivar affected_object_details: Gets or sets any custom properties of the affected object. - :vartype affected_object_details: dict[str, str] + :vartype affected_object_details: + ~azure.mgmt.recoveryservicesdatareplication.models.JobModelCustomPropertiesAffectedObjectDetails :ivar protected_item_details: Gets or sets the test VM details. :vartype protected_item_details: list[~azure.mgmt.recoveryservicesdatareplication.models.FailoverProtectedItemProperties] """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "affected_object_details": {"readonly": True}, "protected_item_details": {"readonly": True}, } _attribute_map = { "instance_type": {"key": "instanceType", "type": "str"}, - "affected_object_details": {"key": "affectedObjectDetails", "type": "{str}"}, + "affected_object_details": { + "key": "affectedObjectDetails", + "type": "JobModelCustomPropertiesAffectedObjectDetails", + }, "protected_item_details": {"key": "protectedItemDetails", "type": "[FailoverProtectedItemProperties]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.instance_type: str = "TestFailoverWorkflowDetails" - self.protected_item_details = None + self.instance_type: str = "TestFailoverJobDetails" + self.protected_item_details: Optional[List["_models.FailoverProtectedItemProperties"]] = None + + +class UserAssignedIdentity(_serialization.Model): + """User assigned identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.client_id: Optional[str] = None -class VaultModel(_serialization.Model): +class VaultIdentityModel(_serialization.Model): """Vault model. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar location: Gets or sets the location of the vault. Required. - :vartype location: str - :ivar tags: Gets or sets the resource tags. - :vartype tags: dict[str, str] - :ivar properties: Vault properties. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelProperties - :ivar id: Gets or sets the Id of the resource. + :ivar type: Gets or sets the identityType which can be either SystemAssigned or None. Required. + Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.recoveryservicesdatareplication.models.VaultIdentityType + :ivar principal_id: Gets or sets the object ID of the service principal object for the managed + identity that is used to grant role-based access to an Azure resource. + :vartype principal_id: str + :ivar tenant_id: Gets or sets a Globally Unique Identifier (GUID) that represents the Azure AD + tenant where the resource is now a member. + :vartype tenant_id: str + """ + + _validation = { + "type": {"required": True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, *, type: Union[str, "_models.VaultIdentityType"], **kwargs: Any) -> None: + """ + :keyword type: Gets or sets the identityType which can be either SystemAssigned or None. + Required. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.recoveryservicesdatareplication.models.VaultIdentityType + """ + super().__init__(**kwargs) + self.type = type + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + + +class VaultModel(TrackedResource): + """Vault model. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Gets or sets the name of the resource. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Gets or sets the type of the resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: - :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelSystemData + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.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. + :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelProperties + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.recoveryservicesdatareplication.models.ManagedServiceIdentity """ _validation = { - "location": {"required": True, "min_length": 1}, "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "VaultModelProperties"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "VaultModelSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "VaultModelProperties"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, } def __init__( @@ -4935,47 +5595,49 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.VaultModelProperties"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, **kwargs: Any ) -> None: """ - :keyword location: Gets or sets the location of the vault. Required. - :paramtype location: str - :keyword tags: Gets or sets the resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: Vault properties. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelProperties + :keyword identity: The managed service identities assigned to this resource. + :paramtype identity: ~azure.mgmt.recoveryservicesdatareplication.models.ManagedServiceIdentity """ - super().__init__(**kwargs) - self.location = location - self.tags = tags + super().__init__(tags=tags, location=location, **kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None + self.identity = identity -class VaultModelCollection(_serialization.Model): - """Vault model collection. +class VaultModelListResult(_serialization.Model): + """The response of a VaultModel list operation. - :ivar value: Gets or sets the list of vaults. + All required parameters must be populated in order to send to server. + + :ivar value: The VaultModel items on this page. Required. :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :ivar next_link: Gets or sets the value of next link. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[VaultModel]"}, "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, *, value: Optional[List["_models.VaultModel"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: + def __init__(self, *, value: List["_models.VaultModel"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword value: Gets or sets the list of vaults. + :keyword value: The VaultModel items on this page. Required. :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :keyword next_link: Gets or sets the value of next link. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -5021,83 +5683,13 @@ def __init__( ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationVaultType """ super().__init__(**kwargs) - self.provisioning_state = None - self.service_resource_id = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.service_resource_id: Optional[str] = None self.vault_type = vault_type -class VaultModelSystemData(SystemDataModel): - """VaultModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - class VaultModelUpdate(_serialization.Model): - """Vault model for update. + """Vault model update. Variables are only populated by the server, and will be ignored when sending a request. @@ -5105,15 +5697,16 @@ class VaultModelUpdate(_serialization.Model): :vartype tags: dict[str, str] :ivar properties: Vault properties. :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelProperties + :ivar identity: Vault identity. + :vartype identity: ~azure.mgmt.recoveryservicesdatareplication.models.VaultIdentityModel :ivar id: Gets or sets the Id of the resource. :vartype id: str :ivar name: Gets or sets the name of the resource. :vartype name: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdateSystemData + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.recoveryservicesdatareplication.models.SystemData """ _validation = { @@ -5126,10 +5719,11 @@ class VaultModelUpdate(_serialization.Model): _attribute_map = { "tags": {"key": "tags", "type": "{str}"}, "properties": {"key": "properties", "type": "VaultModelProperties"}, + "identity": {"key": "identity", "type": "VaultIdentityModel"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "VaultModelUpdateSystemData"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( @@ -5137,6 +5731,7 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.VaultModelProperties"] = None, + identity: Optional["_models.VaultIdentityModel"] = None, **kwargs: Any ) -> None: """ @@ -5144,94 +5739,27 @@ def __init__( :paramtype tags: dict[str, str] :keyword properties: Vault properties. :paramtype properties: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelProperties + :keyword identity: Vault identity. + :paramtype identity: ~azure.mgmt.recoveryservicesdatareplication.models.VaultIdentityModel """ super().__init__(**kwargs) self.tags = tags self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class VaultModelUpdateSystemData(SystemDataModel): - """VaultModelUpdateSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + self.identity = identity + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None -class VMwareDraModelCustomProperties(DraModelCustomProperties): - """VMware DRA model custom properties. +class VMwareFabricAgentModelCustomProperties(FabricAgentModelCustomProperties): + """VMware fabric agent model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for FabricAgentModelCustomProperties. Required. :vartype instance_type: str - :ivar bios_id: Gets or sets the BIOS Id of the DRA machine. Required. + :ivar bios_id: Gets or sets the BIOS Id of the fabric agent machine. Required. :vartype bios_id: str :ivar mars_authentication_identity: Identity model. Required. :vartype mars_authentication_identity: @@ -5239,7 +5767,7 @@ class VMwareDraModelCustomProperties(DraModelCustomProperties): """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "bios_id": {"required": True, "min_length": 1}, "mars_authentication_identity": {"required": True}, } @@ -5252,7 +5780,7 @@ class VMwareDraModelCustomProperties(DraModelCustomProperties): def __init__(self, *, bios_id: str, mars_authentication_identity: "_models.IdentityModel", **kwargs: Any) -> None: """ - :keyword bios_id: Gets or sets the BIOS Id of the DRA machine. Required. + :keyword bios_id: Gets or sets the BIOS Id of the fabric agent machine. Required. :paramtype bios_id: str :keyword mars_authentication_identity: Identity model. Required. :paramtype mars_authentication_identity: @@ -5267,9 +5795,9 @@ def __init__(self, *, bios_id: str, mars_authentication_identity: "_models.Ident class VMwareMigrateFabricModelCustomProperties(FabricModelCustomProperties): """VMware migrate fabric model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for FabricModelCustomProperties. Required. :vartype instance_type: str :ivar vmware_site_id: Gets or sets the ARM Id of the VMware site. Required. :vartype vmware_site_id: str @@ -5278,9 +5806,9 @@ class VMwareMigrateFabricModelCustomProperties(FabricModelCustomProperties): """ _validation = { - "instance_type": {"required": True, "min_length": 1}, - "vmware_site_id": {"required": True, "min_length": 1}, - "migration_solution_id": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, + "vmware_site_id": {"required": True}, + "migration_solution_id": {"required": True}, } _attribute_map = { @@ -5305,15 +5833,14 @@ def __init__(self, *, vmware_site_id: str, migration_solution_id: str, **kwargs: class VMwareToAzStackHCIDiskInput(_serialization.Model): """VMwareToAzStack disk input. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar disk_id: Gets or sets the disk Id. Required. :vartype disk_id: str :ivar storage_container_id: Gets or sets the target storage account ARM Id. :vartype storage_container_id: str :ivar is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :vartype is_dynamic: bool :ivar disk_size_gb: Gets or sets the disk size in GB. Required. :vartype disk_size_gb: int @@ -5321,6 +5848,17 @@ class VMwareToAzStackHCIDiskInput(_serialization.Model): :vartype disk_file_format: str :ivar is_os_disk: Gets or sets a value indicating whether disk is os disk. Required. :vartype is_os_disk: bool + :ivar disk_block_size: Gets or sets a value of disk block size. + :vartype disk_block_size: int + :ivar disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :vartype disk_logical_sector_size: int + :ivar disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :vartype disk_physical_sector_size: int + :ivar disk_identifier: Gets or sets a value of disk identifier. + :vartype disk_identifier: str + :ivar disk_controller: Disk controller. + :vartype disk_controller: + ~azure.mgmt.recoveryservicesdatareplication.models.DiskControllerInputs """ _validation = { @@ -5337,6 +5875,11 @@ class VMwareToAzStackHCIDiskInput(_serialization.Model): "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, "disk_file_format": {"key": "diskFileFormat", "type": "str"}, "is_os_disk": {"key": "isOsDisk", "type": "bool"}, + "disk_block_size": {"key": "diskBlockSize", "type": "int"}, + "disk_logical_sector_size": {"key": "diskLogicalSectorSize", "type": "int"}, + "disk_physical_sector_size": {"key": "diskPhysicalSectorSize", "type": "int"}, + "disk_identifier": {"key": "diskIdentifier", "type": "str"}, + "disk_controller": {"key": "diskController", "type": "DiskControllerInputs"}, } def __init__( @@ -5348,6 +5891,11 @@ def __init__( is_os_disk: bool, storage_container_id: Optional[str] = None, is_dynamic: Optional[bool] = None, + disk_block_size: Optional[int] = None, + disk_logical_sector_size: Optional[int] = None, + disk_physical_sector_size: Optional[int] = None, + disk_identifier: Optional[str] = None, + disk_controller: Optional["_models.DiskControllerInputs"] = None, **kwargs: Any ) -> None: """ @@ -5356,8 +5904,7 @@ def __init__( :keyword storage_container_id: Gets or sets the target storage account ARM Id. :paramtype storage_container_id: str :keyword is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :paramtype is_dynamic: bool :keyword disk_size_gb: Gets or sets the disk size in GB. Required. :paramtype disk_size_gb: int @@ -5366,6 +5913,17 @@ def __init__( :paramtype disk_file_format: str :keyword is_os_disk: Gets or sets a value indicating whether disk is os disk. Required. :paramtype is_os_disk: bool + :keyword disk_block_size: Gets or sets a value of disk block size. + :paramtype disk_block_size: int + :keyword disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :paramtype disk_logical_sector_size: int + :keyword disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :paramtype disk_physical_sector_size: int + :keyword disk_identifier: Gets or sets a value of disk identifier. + :paramtype disk_identifier: str + :keyword disk_controller: Disk controller. + :paramtype disk_controller: + ~azure.mgmt.recoveryservicesdatareplication.models.DiskControllerInputs """ super().__init__(**kwargs) self.disk_id = disk_id @@ -5374,6 +5932,64 @@ def __init__( self.disk_size_gb = disk_size_gb self.disk_file_format = disk_file_format self.is_os_disk = is_os_disk + self.disk_block_size = disk_block_size + self.disk_logical_sector_size = disk_logical_sector_size + self.disk_physical_sector_size = disk_physical_sector_size + self.disk_identifier = disk_identifier + self.disk_controller = disk_controller + + +class VMwareToAzStackHCIEventModelCustomProperties(EventModelCustomProperties): # pylint: disable=name-too-long + """VMware to AzStackHCI event model custom properties. This class provides provider specific + details for events of type DataContract.HealthEvents.HealthEventType.ProtectedItemHealth and + DataContract.HealthEvents.HealthEventType.AgentHealth. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for EventModelCustomProperties. Required. + :vartype instance_type: str + :ivar event_source_friendly_name: Gets or sets the friendly name of the source which has raised + this health event. + :vartype event_source_friendly_name: str + :ivar protected_item_friendly_name: Gets or sets the protected item friendly name. + :vartype protected_item_friendly_name: str + :ivar source_appliance_name: Gets or sets the source appliance name. + :vartype source_appliance_name: str + :ivar target_appliance_name: Gets or sets the source target name. + :vartype target_appliance_name: str + :ivar server_type: Gets or sets the server type. + :vartype server_type: str + """ + + _validation = { + "instance_type": {"required": True}, + "event_source_friendly_name": {"readonly": True}, + "protected_item_friendly_name": {"readonly": True}, + "source_appliance_name": {"readonly": True}, + "target_appliance_name": {"readonly": True}, + "server_type": {"readonly": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + "event_source_friendly_name": {"key": "eventSourceFriendlyName", "type": "str"}, + "protected_item_friendly_name": {"key": "protectedItemFriendlyName", "type": "str"}, + "source_appliance_name": {"key": "sourceApplianceName", "type": "str"}, + "target_appliance_name": {"key": "targetApplianceName", "type": "str"}, + "server_type": {"key": "serverType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.instance_type: str = "VMwareToAzStackHCI" + self.event_source_friendly_name: Optional[str] = None + self.protected_item_friendly_name: Optional[str] = None + self.source_appliance_name: Optional[str] = None + self.target_appliance_name: Optional[str] = None + self.server_type: Optional[str] = None class VMwareToAzStackHCINicInput(_serialization.Model): @@ -5381,7 +5997,7 @@ class VMwareToAzStackHCINicInput(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar nic_id: Gets or sets the NIC Id. Required. :vartype nic_id: str @@ -5390,23 +6006,25 @@ class VMwareToAzStackHCINicInput(_serialization.Model): :ivar network_name: Gets or sets the network name. :vartype network_name: str :ivar target_network_id: Gets or sets the target network Id within AzStackHCI Cluster. - Required. :vartype target_network_id: str :ivar test_network_id: Gets or sets the target test network Id within AzStackHCI Cluster. - Required. :vartype test_network_id: str :ivar selection_type_for_failover: Gets or sets the selection type of the NIC. Required. Known values are: "NotSelected", "SelectedByUser", "SelectedByDefault", and "SelectedByUserOverride". :vartype selection_type_for_failover: str or ~azure.mgmt.recoveryservicesdatareplication.models.VMNicSelection + :ivar is_static_ip_migration_enabled: Gets or sets a value indicating whether static ip + migration is enabled. + :vartype is_static_ip_migration_enabled: bool + :ivar is_mac_migration_enabled: Gets or sets a value indicating whether mac address migration + is enabled. + :vartype is_mac_migration_enabled: bool """ _validation = { "nic_id": {"required": True, "min_length": 1}, "label": {"required": True, "min_length": 1}, "network_name": {"readonly": True}, - "target_network_id": {"required": True, "min_length": 1}, - "test_network_id": {"required": True, "min_length": 1}, "selection_type_for_failover": {"required": True}, } @@ -5417,6 +6035,8 @@ class VMwareToAzStackHCINicInput(_serialization.Model): "target_network_id": {"key": "targetNetworkId", "type": "str"}, "test_network_id": {"key": "testNetworkId", "type": "str"}, "selection_type_for_failover": {"key": "selectionTypeForFailover", "type": "str"}, + "is_static_ip_migration_enabled": {"key": "isStaticIpMigrationEnabled", "type": "bool"}, + "is_mac_migration_enabled": {"key": "isMacMigrationEnabled", "type": "bool"}, } def __init__( @@ -5424,9 +6044,11 @@ def __init__( *, nic_id: str, label: str, - target_network_id: str, - test_network_id: str, selection_type_for_failover: Union[str, "_models.VMNicSelection"], + target_network_id: Optional[str] = None, + test_network_id: Optional[str] = None, + is_static_ip_migration_enabled: Optional[bool] = None, + is_mac_migration_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -5435,32 +6057,40 @@ def __init__( :keyword label: Gets or sets the NIC label. Required. :paramtype label: str :keyword target_network_id: Gets or sets the target network Id within AzStackHCI Cluster. - Required. :paramtype target_network_id: str :keyword test_network_id: Gets or sets the target test network Id within AzStackHCI Cluster. - Required. :paramtype test_network_id: str :keyword selection_type_for_failover: Gets or sets the selection type of the NIC. Required. Known values are: "NotSelected", "SelectedByUser", "SelectedByDefault", and "SelectedByUserOverride". :paramtype selection_type_for_failover: str or ~azure.mgmt.recoveryservicesdatareplication.models.VMNicSelection + :keyword is_static_ip_migration_enabled: Gets or sets a value indicating whether static ip + migration is enabled. + :paramtype is_static_ip_migration_enabled: bool + :keyword is_mac_migration_enabled: Gets or sets a value indicating whether mac address + migration is enabled. + :paramtype is_mac_migration_enabled: bool """ super().__init__(**kwargs) self.nic_id = nic_id self.label = label - self.network_name = None + self.network_name: Optional[str] = None self.target_network_id = target_network_id self.test_network_id = test_network_id self.selection_type_for_failover = selection_type_for_failover + self.is_static_ip_migration_enabled = is_static_ip_migration_enabled + self.is_mac_migration_enabled = is_mac_migration_enabled -class VMwareToAzStackHCIPlannedFailoverModelCustomProperties(PlannedFailoverModelCustomProperties): +class VMwareToAzStackHCIPlannedFailoverModelCustomProperties( + PlannedFailoverModelCustomProperties +): # pylint: disable=name-too-long """VMware to AzStackHCI planned failover model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PlannedFailoverModelCustomProperties. Required. :vartype instance_type: str :ivar shutdown_source_vm: Gets or sets a value indicating whether VM needs to be shut down. Required. @@ -5468,7 +6098,7 @@ class VMwareToAzStackHCIPlannedFailoverModelCustomProperties(PlannedFailoverMode """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "shutdown_source_vm": {"required": True}, } @@ -5488,16 +6118,15 @@ def __init__(self, *, shutdown_source_vm: bool, **kwargs: Any) -> None: self.shutdown_source_vm = shutdown_source_vm -class VMwareToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties): +class VMwareToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties): # pylint: disable=name-too-long """VMware To AzStackHCI Policy model custom properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for PolicyModelCustomProperties. Required. :vartype instance_type: str :ivar recovery_point_history_in_minutes: Gets or sets the duration in minutes until which the - recovery points need to be - stored. Required. + recovery points need to be stored. Required. :vartype recovery_point_history_in_minutes: int :ivar crash_consistent_frequency_in_minutes: Gets or sets the crash consistent snapshot frequency (in minutes). Required. @@ -5508,7 +6137,7 @@ class VMwareToAzStackHCIPolicyModelCustomProperties(PolicyModelCustomProperties) """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "recovery_point_history_in_minutes": {"required": True}, "crash_consistent_frequency_in_minutes": {"required": True}, "app_consistent_frequency_in_minutes": {"required": True}, @@ -5531,8 +6160,7 @@ def __init__( ) -> None: """ :keyword recovery_point_history_in_minutes: Gets or sets the duration in minutes until which - the recovery points need to be - stored. Required. + the recovery points need to be stored. Required. :paramtype recovery_point_history_in_minutes: int :keyword crash_consistent_frequency_in_minutes: Gets or sets the crash consistent snapshot frequency (in minutes). Required. @@ -5548,7 +6176,7 @@ def __init__( self.app_consistent_frequency_in_minutes = app_consistent_frequency_in_minutes -class VMwareToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class VMwareToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint: disable=name-too-long """VMwareToAzStackHCI protected disk properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -5572,11 +6200,16 @@ class VMwareToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint :ivar capacity_in_bytes: Gets or sets the disk capacity in bytes. :vartype capacity_in_bytes: int :ivar is_dynamic: Gets or sets a value indicating whether dynamic sizing is enabled on the - virtual hard - disk. + virtual hard disk. :vartype is_dynamic: bool :ivar disk_type: Gets or sets the disk type. :vartype disk_type: str + :ivar disk_block_size: Gets or sets a value of disk block size. + :vartype disk_block_size: int + :ivar disk_logical_sector_size: Gets or sets a value of disk logical sector size. + :vartype disk_logical_sector_size: int + :ivar disk_physical_sector_size: Gets or sets a value of disk physical sector size. + :vartype disk_physical_sector_size: int """ _validation = { @@ -5591,6 +6224,9 @@ class VMwareToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint "capacity_in_bytes": {"readonly": True}, "is_dynamic": {"readonly": True}, "disk_type": {"readonly": True}, + "disk_block_size": {"readonly": True}, + "disk_logical_sector_size": {"readonly": True}, + "disk_physical_sector_size": {"readonly": True}, } _attribute_map = { @@ -5605,34 +6241,40 @@ class VMwareToAzStackHCIProtectedDiskProperties(_serialization.Model): # pylint "capacity_in_bytes": {"key": "capacityInBytes", "type": "int"}, "is_dynamic": {"key": "isDynamic", "type": "bool"}, "disk_type": {"key": "diskType", "type": "str"}, + "disk_block_size": {"key": "diskBlockSize", "type": "int"}, + "disk_logical_sector_size": {"key": "diskLogicalSectorSize", "type": "int"}, + "disk_physical_sector_size": {"key": "diskPhysicalSectorSize", "type": "int"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.storage_container_id = None - self.storage_container_local_path = None - self.source_disk_id = None - self.source_disk_name = None - self.seed_disk_name = None - self.test_migrate_disk_name = None - self.migrate_disk_name = None - self.is_os_disk = None - self.capacity_in_bytes = None - self.is_dynamic = None - self.disk_type = None + self.storage_container_id: Optional[str] = None + self.storage_container_local_path: Optional[str] = None + self.source_disk_id: Optional[str] = None + self.source_disk_name: Optional[str] = None + self.seed_disk_name: Optional[str] = None + self.test_migrate_disk_name: Optional[str] = None + self.migrate_disk_name: Optional[str] = None + self.is_os_disk: Optional[bool] = None + self.capacity_in_bytes: Optional[int] = None + self.is_dynamic: Optional[bool] = None + self.disk_type: Optional[str] = None + self.disk_block_size: Optional[int] = None + self.disk_logical_sector_size: Optional[int] = None + self.disk_physical_sector_size: Optional[int] = None class VMwareToAzStackHCIProtectedItemModelCustomProperties( ProtectedItemModelCustomProperties -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=name-too-long """VMware to AzStackHCI Protected item model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ProtectedItemModelCustomProperties. Required. :vartype instance_type: str :ivar active_location: Gets or sets the location of the protected item. Known values are: "Primary" and "Recovery". @@ -5702,10 +6344,10 @@ class VMwareToAzStackHCIProtectedItemModelCustomProperties( :vartype source_memory_in_mega_bytes: float :ivar run_as_account_id: Gets or sets the run as account Id. Required. :vartype run_as_account_id: str - :ivar source_dra_name: Gets or sets the source DRA name. Required. - :vartype source_dra_name: str - :ivar target_dra_name: Gets or sets the target DRA name. Required. - :vartype target_dra_name: str + :ivar source_fabric_agent_name: Gets or sets the source fabric agent name. Required. + :vartype source_fabric_agent_name: str + :ivar target_fabric_agent_name: Gets or sets the target fabric agent name. Required. + :vartype target_fabric_agent_name: str :ivar source_appliance_name: Gets or sets the source appliance name. :vartype source_appliance_name: str :ivar target_appliance_name: Gets or sets the target appliance name. @@ -5718,16 +6360,14 @@ class VMwareToAzStackHCIProtectedItemModelCustomProperties( :ivar last_recovery_point_id: Gets or sets the last recovery point Id. :vartype last_recovery_point_id: str :ivar initial_replication_progress_percentage: Gets or sets the initial replication progress - percentage. This is calculated based on - total bytes processed for all disks in the source VM. + percentage. This is calculated based on total bytes processed for all disks in the source VM. :vartype initial_replication_progress_percentage: int :ivar migration_progress_percentage: Gets or sets the migration progress percentage. :vartype migration_progress_percentage: int :ivar resume_progress_percentage: Gets or sets the resume progress percentage. :vartype resume_progress_percentage: int :ivar resync_progress_percentage: Gets or sets the resync progress percentage. This is - calculated based on total bytes - processed for all disks in the source VM. + calculated based on total bytes processed for all disks in the source VM. :vartype resync_progress_percentage: int :ivar resync_retry_count: Gets or sets the resync retry count. :vartype resync_retry_count: int @@ -5747,17 +6387,17 @@ class VMwareToAzStackHCIProtectedItemModelCustomProperties( """ _validation = { - "instance_type": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, "active_location": {"readonly": True}, - "target_hci_cluster_id": {"required": True, "min_length": 1}, - "target_arc_cluster_custom_location_id": {"required": True, "min_length": 1}, + "target_hci_cluster_id": {"required": True}, + "target_arc_cluster_custom_location_id": {"required": True}, "target_az_stack_hci_cluster_name": {"readonly": True}, - "storage_container_id": {"required": True, "min_length": 1}, - "target_resource_group_id": {"required": True, "min_length": 1}, + "storage_container_id": {"required": True}, + "target_resource_group_id": {"required": True}, "target_location": {"readonly": True}, "custom_location_region": {"required": True, "min_length": 1}, - "disks_to_include": {"required": True, "min_items": 1}, - "nics_to_include": {"required": True, "min_items": 1}, + "disks_to_include": {"required": True}, + "nics_to_include": {"required": True}, "protected_disks": {"readonly": True}, "protected_nics": {"readonly": True}, "target_vm_bios_id": {"readonly": True}, @@ -5765,13 +6405,13 @@ class VMwareToAzStackHCIProtectedItemModelCustomProperties( "os_type": {"readonly": True}, "os_name": {"readonly": True}, "firmware_type": {"readonly": True}, - "fabric_discovery_machine_id": {"required": True, "min_length": 1}, + "fabric_discovery_machine_id": {"required": True}, "source_vm_name": {"readonly": True}, "source_cpu_cores": {"readonly": True}, "source_memory_in_mega_bytes": {"readonly": True}, "run_as_account_id": {"required": True, "min_length": 1}, - "source_dra_name": {"required": True, "min_length": 1}, - "target_dra_name": {"required": True, "min_length": 1}, + "source_fabric_agent_name": {"required": True, "min_length": 1}, + "target_fabric_agent_name": {"required": True, "min_length": 1}, "source_appliance_name": {"readonly": True}, "target_appliance_name": {"readonly": True}, "failover_recovery_point_id": {"readonly": True}, @@ -5819,8 +6459,8 @@ class VMwareToAzStackHCIProtectedItemModelCustomProperties( "source_cpu_cores": {"key": "sourceCpuCores", "type": "int"}, "source_memory_in_mega_bytes": {"key": "sourceMemoryInMegaBytes", "type": "float"}, "run_as_account_id": {"key": "runAsAccountId", "type": "str"}, - "source_dra_name": {"key": "sourceDraName", "type": "str"}, - "target_dra_name": {"key": "targetDraName", "type": "str"}, + "source_fabric_agent_name": {"key": "sourceFabricAgentName", "type": "str"}, + "target_fabric_agent_name": {"key": "targetFabricAgentName", "type": "str"}, "source_appliance_name": {"key": "sourceApplianceName", "type": "str"}, "target_appliance_name": {"key": "targetApplianceName", "type": "str"}, "failover_recovery_point_id": {"key": "failoverRecoveryPointId", "type": "str"}, @@ -5851,8 +6491,8 @@ def __init__( # pylint: disable=too-many-locals hyper_v_generation: str, fabric_discovery_machine_id: str, run_as_account_id: str, - source_dra_name: str, - target_dra_name: str, + source_fabric_agent_name: str, + target_fabric_agent_name: str, target_vm_name: Optional[str] = None, target_network_id: Optional[str] = None, test_network_id: Optional[str] = None, @@ -5905,29 +6545,29 @@ def __init__( # pylint: disable=too-many-locals :paramtype fabric_discovery_machine_id: str :keyword run_as_account_id: Gets or sets the run as account Id. Required. :paramtype run_as_account_id: str - :keyword source_dra_name: Gets or sets the source DRA name. Required. - :paramtype source_dra_name: str - :keyword target_dra_name: Gets or sets the target DRA name. Required. - :paramtype target_dra_name: str + :keyword source_fabric_agent_name: Gets or sets the source fabric agent name. Required. + :paramtype source_fabric_agent_name: str + :keyword target_fabric_agent_name: Gets or sets the target fabric agent name. Required. + :paramtype target_fabric_agent_name: str :keyword perform_auto_resync: Gets or sets a value indicating whether auto resync is to be done. :paramtype perform_auto_resync: bool """ super().__init__(**kwargs) self.instance_type: str = "VMwareToAzStackHCI" - self.active_location = None + self.active_location: Optional[Union[str, "_models.ProtectedItemActiveLocation"]] = None self.target_hci_cluster_id = target_hci_cluster_id self.target_arc_cluster_custom_location_id = target_arc_cluster_custom_location_id - self.target_az_stack_hci_cluster_name = None + self.target_az_stack_hci_cluster_name: Optional[str] = None self.storage_container_id = storage_container_id self.target_resource_group_id = target_resource_group_id - self.target_location = None + self.target_location: Optional[str] = None self.custom_location_region = custom_location_region self.disks_to_include = disks_to_include self.nics_to_include = nics_to_include - self.protected_disks = None - self.protected_nics = None - self.target_vm_bios_id = None + self.protected_disks: Optional[List["_models.VMwareToAzStackHCIProtectedDiskProperties"]] = None + self.protected_nics: Optional[List["_models.VMwareToAzStackHCIProtectedNicProperties"]] = None + self.target_vm_bios_id: Optional[str] = None self.target_vm_name = target_vm_name self.hyper_v_generation = hyper_v_generation self.target_network_id = target_network_id @@ -5936,31 +6576,108 @@ def __init__( # pylint: disable=too-many-locals self.is_dynamic_ram = is_dynamic_ram self.dynamic_memory_config = dynamic_memory_config self.target_memory_in_mega_bytes = target_memory_in_mega_bytes - self.os_type = None - self.os_name = None - self.firmware_type = None + self.os_type: Optional[str] = None + self.os_name: Optional[str] = None + self.firmware_type: Optional[str] = None self.fabric_discovery_machine_id = fabric_discovery_machine_id - self.source_vm_name = None - self.source_cpu_cores = None - self.source_memory_in_mega_bytes = None + self.source_vm_name: Optional[str] = None + self.source_cpu_cores: Optional[int] = None + self.source_memory_in_mega_bytes: Optional[float] = None self.run_as_account_id = run_as_account_id - self.source_dra_name = source_dra_name - self.target_dra_name = target_dra_name - self.source_appliance_name = None - self.target_appliance_name = None - self.failover_recovery_point_id = None - self.last_recovery_point_received = None - self.last_recovery_point_id = None - self.initial_replication_progress_percentage = None - self.migration_progress_percentage = None - self.resume_progress_percentage = None - self.resync_progress_percentage = None - self.resync_retry_count = None - self.resync_required = None - self.resync_state = None + self.source_fabric_agent_name = source_fabric_agent_name + self.target_fabric_agent_name = target_fabric_agent_name + self.source_appliance_name: Optional[str] = None + self.target_appliance_name: Optional[str] = None + self.failover_recovery_point_id: Optional[str] = None + self.last_recovery_point_received: Optional[datetime.datetime] = None + self.last_recovery_point_id: Optional[str] = None + self.initial_replication_progress_percentage: Optional[int] = None + self.migration_progress_percentage: Optional[int] = None + self.resume_progress_percentage: Optional[int] = None + self.resync_progress_percentage: Optional[int] = None + self.resync_retry_count: Optional[int] = None + self.resync_required: Optional[bool] = None + self.resync_state: Optional[Union[str, "_models.VMwareToAzureMigrateResyncState"]] = None self.perform_auto_resync = perform_auto_resync - self.resume_retry_count = None - self.last_replication_update_time = None + self.resume_retry_count: Optional[int] = None + self.last_replication_update_time: Optional[datetime.datetime] = None + + +class VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate( + ProtectedItemModelCustomPropertiesUpdate +): # pylint: disable=name-too-long + """VMware to AzStackHCI Protected item model custom properties. + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for ProtectedItemModelCustomPropertiesUpdate. + Required. + :vartype instance_type: str + :ivar nics_to_include: Gets or sets the list of VM NIC to replicate. + :vartype nics_to_include: + list[~azure.mgmt.recoveryservicesdatareplication.models.VMwareToAzStackHCINicInput] + :ivar target_cpu_cores: Gets or sets the target CPU cores. + :vartype target_cpu_cores: int + :ivar is_dynamic_ram: Gets or sets a value indicating whether memory is dynamical. + :vartype is_dynamic_ram: bool + :ivar dynamic_memory_config: Protected item dynamic memory config. + :vartype dynamic_memory_config: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemDynamicMemoryConfig + :ivar target_memory_in_mega_bytes: Gets or sets the target memory in mega-bytes. + :vartype target_memory_in_mega_bytes: int + :ivar os_type: Gets or sets the type of the OS. + :vartype os_type: str + """ + + _validation = { + "instance_type": {"required": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + "nics_to_include": {"key": "nicsToInclude", "type": "[VMwareToAzStackHCINicInput]"}, + "target_cpu_cores": {"key": "targetCpuCores", "type": "int"}, + "is_dynamic_ram": {"key": "isDynamicRam", "type": "bool"}, + "dynamic_memory_config": {"key": "dynamicMemoryConfig", "type": "ProtectedItemDynamicMemoryConfig"}, + "target_memory_in_mega_bytes": {"key": "targetMemoryInMegaBytes", "type": "int"}, + "os_type": {"key": "osType", "type": "str"}, + } + + def __init__( + self, + *, + nics_to_include: Optional[List["_models.VMwareToAzStackHCINicInput"]] = None, + target_cpu_cores: Optional[int] = None, + is_dynamic_ram: Optional[bool] = None, + dynamic_memory_config: Optional["_models.ProtectedItemDynamicMemoryConfig"] = None, + target_memory_in_mega_bytes: Optional[int] = None, + os_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword nics_to_include: Gets or sets the list of VM NIC to replicate. + :paramtype nics_to_include: + list[~azure.mgmt.recoveryservicesdatareplication.models.VMwareToAzStackHCINicInput] + :keyword target_cpu_cores: Gets or sets the target CPU cores. + :paramtype target_cpu_cores: int + :keyword is_dynamic_ram: Gets or sets a value indicating whether memory is dynamical. + :paramtype is_dynamic_ram: bool + :keyword dynamic_memory_config: Protected item dynamic memory config. + :paramtype dynamic_memory_config: + ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemDynamicMemoryConfig + :keyword target_memory_in_mega_bytes: Gets or sets the target memory in mega-bytes. + :paramtype target_memory_in_mega_bytes: int + :keyword os_type: Gets or sets the type of the OS. + :paramtype os_type: str + """ + super().__init__(**kwargs) + self.instance_type: str = "VMwareToAzStackHCI" + self.nics_to_include = nics_to_include + self.target_cpu_cores = target_cpu_cores + self.is_dynamic_ram = is_dynamic_ram + self.dynamic_memory_config = dynamic_memory_config + self.target_memory_in_mega_bytes = target_memory_in_mega_bytes + self.os_type = os_type class VMwareToAzStackHCIProtectedNicProperties(_serialization.Model): @@ -6015,26 +6732,59 @@ def __init__(self, *, is_primary_nic: Optional[bool] = None, **kwargs: Any) -> N :paramtype is_primary_nic: bool """ super().__init__(**kwargs) - self.nic_id = None - self.mac_address = None - self.label = None + self.nic_id: Optional[str] = None + self.mac_address: Optional[str] = None + self.label: Optional[str] = None self.is_primary_nic = is_primary_nic - self.network_name = None - self.target_network_id = None - self.test_network_id = None - self.selection_type_for_failover = None + self.network_name: Optional[str] = None + self.target_network_id: Optional[str] = None + self.test_network_id: Optional[str] = None + self.selection_type_for_failover: Optional[Union[str, "_models.VMNicSelection"]] = None + + +class VMwareToAzStackHCIRecoveryPointModelCustomProperties( + RecoveryPointModelCustomProperties +): # pylint: disable=name-too-long + """VMware to AzStackHCI recovery point model custom properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar instance_type: Discriminator property for RecoveryPointModelCustomProperties. Required. + :vartype instance_type: str + :ivar disk_ids: Gets or sets the list of the disk Ids. + :vartype disk_ids: list[str] + """ + + _validation = { + "instance_type": {"required": True}, + "disk_ids": {"readonly": True}, + } + + _attribute_map = { + "instance_type": {"key": "instanceType", "type": "str"}, + "disk_ids": {"key": "diskIds", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.instance_type: str = "VMwareToAzStackHCIRecoveryPointModelCustomProperties" + self.disk_ids: Optional[List[str]] = None class VMwareToAzStackHCIReplicationExtensionModelCustomProperties( ReplicationExtensionModelCustomProperties -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=name-too-long """VMware to AzStackHCI Replication extension model custom properties. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar instance_type: Gets or sets the instance type. Required. + :ivar instance_type: Discriminator property for ReplicationExtensionModelCustomProperties. + Required. :vartype instance_type: str :ivar vmware_fabric_arm_id: Gets or sets the ARM Id of the source VMware fabric. Required. :vartype vmware_fabric_arm_id: str @@ -6072,10 +6822,10 @@ class VMwareToAzStackHCIReplicationExtensionModelCustomProperties( """ _validation = { - "instance_type": {"required": True, "min_length": 1}, - "vmware_fabric_arm_id": {"required": True, "min_length": 1}, + "instance_type": {"required": True}, + "vmware_fabric_arm_id": {"required": True}, "vmware_site_id": {"readonly": True}, - "az_stack_hci_fabric_arm_id": {"required": True, "min_length": 1}, + "az_stack_hci_fabric_arm_id": {"required": True}, "az_stack_hci_site_id": {"readonly": True}, "asr_service_uri": {"readonly": True}, "rcm_service_uri": {"readonly": True}, @@ -6132,280 +6882,18 @@ def __init__( super().__init__(**kwargs) self.instance_type: str = "VMwareToAzStackHCI" self.vmware_fabric_arm_id = vmware_fabric_arm_id - self.vmware_site_id = None + self.vmware_site_id: Optional[str] = None self.az_stack_hci_fabric_arm_id = az_stack_hci_fabric_arm_id - self.az_stack_hci_site_id = None + self.az_stack_hci_site_id: Optional[str] = None self.storage_account_id = storage_account_id self.storage_account_sas_secret_name = storage_account_sas_secret_name - self.asr_service_uri = None - self.rcm_service_uri = None - self.gateway_service_uri = None - self.source_gateway_service_id = None - self.target_gateway_service_id = None - self.source_storage_container_name = None - self.target_storage_container_name = None - self.resource_location = None - self.subscription_id = None - self.resource_group = None - - -class WorkflowModel(_serialization.Model): - """Workflow model. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: Workflow model properties. Required. - :vartype properties: ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModelProperties - :ivar id: Gets or sets the Id of the resource. - :vartype id: str - :ivar name: Gets or sets the name of the resource. - :vartype name: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :ivar system_data: - :vartype system_data: - ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModelSystemData - """ - - _validation = { - "properties": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "WorkflowModelProperties"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "WorkflowModelSystemData"}, - } - - def __init__(self, *, properties: "_models.WorkflowModelProperties", **kwargs: Any) -> None: - """ - :keyword properties: Workflow model properties. Required. - :paramtype properties: - ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModelProperties - """ - super().__init__(**kwargs) - self.properties = properties - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class WorkflowModelCollection(_serialization.Model): - """Workflow model collection. - - :ivar value: Gets or sets the list of workflows. - :vartype value: list[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] - :ivar next_link: Gets or sets the value of next link. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[WorkflowModel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.WorkflowModel"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Gets or sets the list of workflows. - :paramtype value: list[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] - :keyword next_link: Gets or sets the value of next link. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class WorkflowModelProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Workflow model properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar display_name: Gets or sets the friendly display name. - :vartype display_name: str - :ivar state: Gets or sets the workflow state. Known values are: "Pending", "Started", - "Cancelling", "Succeeded", "Failed", "Cancelled", "CompletedWithInformation", - "CompletedWithWarnings", and "CompletedWithErrors". - :vartype state: str or ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowState - :ivar start_time: Gets or sets the start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets or sets the end time. - :vartype end_time: ~datetime.datetime - :ivar object_id: Gets or sets the affected object Id. - :vartype object_id: str - :ivar object_name: Gets or sets the affected object name. - :vartype object_name: str - :ivar object_internal_id: Gets or sets the affected object internal Id. - :vartype object_internal_id: str - :ivar object_internal_name: Gets or sets the affected object internal name. - :vartype object_internal_name: str - :ivar object_type: Gets or sets the object type. Known values are: "AvsDiskPool", "Dra", - "Fabric", "Policy", "ProtectedItem", "RecoveryPlan", "ReplicationExtension", and "Vault". - :vartype object_type: str or - ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowObjectType - :ivar replication_provider_id: Gets or sets the replication provider. - :vartype replication_provider_id: str - :ivar source_fabric_provider_id: Gets or sets the source fabric provider. - :vartype source_fabric_provider_id: str - :ivar target_fabric_provider_id: Gets or sets the target fabric provider. - :vartype target_fabric_provider_id: str - :ivar allowed_actions: Gets or sets the list of allowed actions on the workflow. - :vartype allowed_actions: list[str] - :ivar activity_id: Gets or sets the workflow activity id. - :vartype activity_id: str - :ivar tasks: Gets or sets the list of tasks. - :vartype tasks: list[~azure.mgmt.recoveryservicesdatareplication.models.TaskModel] - :ivar errors: Gets or sets the list of errors. - :vartype errors: list[~azure.mgmt.recoveryservicesdatareplication.models.ErrorModel] - :ivar custom_properties: Workflow model custom properties. Required. - :vartype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModelCustomProperties - """ - - _validation = { - "display_name": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "object_id": {"readonly": True}, - "object_name": {"readonly": True}, - "object_internal_id": {"readonly": True}, - "object_internal_name": {"readonly": True}, - "object_type": {"readonly": True}, - "replication_provider_id": {"readonly": True}, - "source_fabric_provider_id": {"readonly": True}, - "target_fabric_provider_id": {"readonly": True}, - "allowed_actions": {"readonly": True}, - "activity_id": {"readonly": True}, - "tasks": {"readonly": True}, - "errors": {"readonly": True}, - "custom_properties": {"required": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "object_id": {"key": "objectId", "type": "str"}, - "object_name": {"key": "objectName", "type": "str"}, - "object_internal_id": {"key": "objectInternalId", "type": "str"}, - "object_internal_name": {"key": "objectInternalName", "type": "str"}, - "object_type": {"key": "objectType", "type": "str"}, - "replication_provider_id": {"key": "replicationProviderId", "type": "str"}, - "source_fabric_provider_id": {"key": "sourceFabricProviderId", "type": "str"}, - "target_fabric_provider_id": {"key": "targetFabricProviderId", "type": "str"}, - "allowed_actions": {"key": "allowedActions", "type": "[str]"}, - "activity_id": {"key": "activityId", "type": "str"}, - "tasks": {"key": "tasks", "type": "[TaskModel]"}, - "errors": {"key": "errors", "type": "[ErrorModel]"}, - "custom_properties": {"key": "customProperties", "type": "WorkflowModelCustomProperties"}, - } - - def __init__(self, *, custom_properties: "_models.WorkflowModelCustomProperties", **kwargs: Any) -> None: - """ - :keyword custom_properties: Workflow model custom properties. Required. - :paramtype custom_properties: - ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModelCustomProperties - """ - super().__init__(**kwargs) - self.display_name = None - self.state = None - self.start_time = None - self.end_time = None - self.object_id = None - self.object_name = None - self.object_internal_id = None - self.object_internal_name = None - self.object_type = None - self.replication_provider_id = None - self.source_fabric_provider_id = None - self.target_fabric_provider_id = None - self.allowed_actions = None - self.activity_id = None - self.tasks = None - self.errors = None - self.custom_properties = custom_properties - - -class WorkflowModelSystemData(SystemDataModel): - """WorkflowModelSystemData. - - :ivar created_by: Gets or sets identity that created the resource. - :vartype created_by: str - :ivar created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :vartype created_by_type: str - :ivar created_at: Gets or sets the timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: Gets or sets the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: Gets or sets the type of identity that last modified the resource: - user, application, - managedIdentity. - :vartype last_modified_by_type: str - :ivar last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[str] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: Gets or sets identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: Gets or sets the type of identity that created the resource: user, - application, - managedIdentity. - :paramtype created_by_type: str - :keyword created_at: Gets or sets the timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: Gets or sets the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: Gets or sets the type of identity that last modified the - resource: user, application, - managedIdentity. - :paramtype last_modified_by_type: str - :keyword last_modified_at: Gets or sets the timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) + self.asr_service_uri: Optional[str] = None + self.rcm_service_uri: Optional[str] = None + self.gateway_service_uri: Optional[str] = None + self.source_gateway_service_id: Optional[str] = None + self.target_gateway_service_id: Optional[str] = None + self.source_storage_container_name: Optional[str] = None + self.target_storage_container_name: Optional[str] = None + self.resource_location: Optional[str] = None + self.subscription_id: Optional[str] = None + self.resource_group: Optional[str] = None diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_recovery_services_data_replication_mgmt_client_enums.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_recovery_services_data_replication_mgmt_client_enums.py index df2f45098fc6..2f160f0c97c0 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_recovery_services_data_replication_mgmt_client_enums.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/models/_recovery_services_data_replication_mgmt_client_enums.py @@ -16,12 +16,79 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class HealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the fabric health.""" NORMAL = "Normal" + """Healthy Status.""" WARNING = "Warning" + """Warning Status.""" CRITICAL = "Critical" + """Critical Status.""" + + +class JobObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the object type.""" + + AVS_DISK_POOL = "AvsDiskPool" + """AVS disk pool.""" + FABRIC_AGENT = "FabricAgent" + """Fabric agent level workflow.""" + FABRIC = "Fabric" + """Fabric level job.""" + POLICY = "Policy" + """Policy level job.""" + PROTECTED_ITEM = "ProtectedItem" + """Protected item level job.""" + RECOVERY_PLAN = "RecoveryPlan" + """Recovery plan level job.""" + REPLICATION_EXTENSION = "ReplicationExtension" + """Replication extension level job.""" + VAULT = "Vault" + """Vault level job.""" + + +class JobState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the job state.""" + + PENDING = "Pending" + """Job has not been started.""" + STARTED = "Started" + """Job is in progress.""" + CANCELLING = "Cancelling" + """Job cancellation is in progress.""" + SUCCEEDED = "Succeeded" + """Job has completed successfully.""" + FAILED = "Failed" + """Job failed.""" + CANCELLED = "Cancelled" + """Job has been cancelled.""" + COMPLETED_WITH_INFORMATION = "CompletedWithInformation" + """Job has completed with information.""" + COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" + """Job has completed with warnings.""" + COMPLETED_WITH_ERRORS = "CompletedWithErrors" + """Job has completed with errors.""" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -34,169 +101,262 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_SYSTEM = "user,system" +class PrivateEndpointConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the status.""" + + APPROVED = "Approved" + """Approved Status.""" + DISCONNECTED = "Disconnected" + """Disconnected Status.""" + PENDING = "Pending" + """Pending Status.""" + REJECTED = "Rejected" + """Rejected Status.""" + + class ProtectedItemActiveLocation(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the location of the protected item.""" PRIMARY = "Primary" + """Protected item is active on Primary.""" RECOVERY = "Recovery" + """Protected item is active on Recovery.""" class ProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the protection state.""" UNPROTECTED_STATES_BEGIN = "UnprotectedStatesBegin" + """Begin marker for unprotected states.""" ENABLING_PROTECTION = "EnablingProtection" + """Enable protection is in progress.""" ENABLING_FAILED = "EnablingFailed" + """Enable protection failed.""" DISABLING_PROTECTION = "DisablingProtection" + """Disabling protection is in progress.""" MARKED_FOR_DELETION = "MarkedForDeletion" + """Disabling protection succeeded. This is a transient state before the protected item is deleted.""" DISABLING_FAILED = "DisablingFailed" + """Disable protection failed.""" UNPROTECTED_STATES_END = "UnprotectedStatesEnd" + """End marker for unprotected states.""" INITIAL_REPLICATION_STATES_BEGIN = "InitialReplicationStatesBegin" + """Begin marker for initial replication states.""" INITIAL_REPLICATION_IN_PROGRESS = "InitialReplicationInProgress" + """Initial replication is in progress.""" INITIAL_REPLICATION_COMPLETED_ON_PRIMARY = "InitialReplicationCompletedOnPrimary" + """Initial replication has completed on the primary side.""" INITIAL_REPLICATION_COMPLETED_ON_RECOVERY = "InitialReplicationCompletedOnRecovery" + """Initial replication has completed on the recovery side.""" INITIAL_REPLICATION_FAILED = "InitialReplicationFailed" + """Initial replication failed and would need to be started again.""" INITIAL_REPLICATION_STATES_END = "InitialReplicationStatesEnd" + """End marker for initial replication states.""" PROTECTED_STATES_BEGIN = "ProtectedStatesBegin" + """Begin marker for protected steady-state states.""" PROTECTED = "Protected" + """Protected item is protected and replication is on-going. Any issues with replication will be + surfaced separately via the health property and will not affect the state.""" PROTECTED_STATES_END = "ProtectedStatesEnd" + """End marker for protected steady-state states.""" PLANNED_FAILOVER_TRANSITION_STATES_BEGIN = "PlannedFailoverTransitionStatesBegin" + """Begin marker for planned failover transition states.""" PLANNED_FAILOVER_INITIATED = "PlannedFailoverInitiated" + """Planned failover has been initiated.""" PLANNED_FAILOVER_COMPLETING = "PlannedFailoverCompleting" + """Planned failover preparing protected entities is in progress.""" PLANNED_FAILOVER_COMPLETED = "PlannedFailoverCompleted" + """Planned failover has been completed successfully.""" PLANNED_FAILOVER_FAILED = "PlannedFailoverFailed" + """Planned failover initiation failed.""" PLANNED_FAILOVER_COMPLETION_FAILED = "PlannedFailoverCompletionFailed" + """Planned failover preparing protected entities failed.""" PLANNED_FAILOVER_TRANSITION_STATES_END = "PlannedFailoverTransitionStatesEnd" + """End marker for planned failover transition states.""" UNPLANNED_FAILOVER_TRANSITION_STATES_BEGIN = "UnplannedFailoverTransitionStatesBegin" + """Begin marker for unplanned failover transition states.""" UNPLANNED_FAILOVER_INITIATED = "UnplannedFailoverInitiated" + """Unplanned failover has been initiated.""" UNPLANNED_FAILOVER_COMPLETING = "UnplannedFailoverCompleting" + """Unplanned failover preparing protected entities is in progress.""" UNPLANNED_FAILOVER_COMPLETED = "UnplannedFailoverCompleted" + """Unplanned failover preparing protected entities is in progress.""" UNPLANNED_FAILOVER_FAILED = "UnplannedFailoverFailed" + """Unplanned failover initiation failed.""" UNPLANNED_FAILOVER_COMPLETION_FAILED = "UnplannedFailoverCompletionFailed" + """Unplanned failover preparing protected entities failed.""" UNPLANNED_FAILOVER_TRANSITION_STATES_END = "UnplannedFailoverTransitionStatesEnd" + """End marker for unplanned failover transition states.""" COMMIT_FAILOVER_STATES_BEGIN = "CommitFailoverStatesBegin" + """Begin marker for commit failover states.""" COMMIT_FAILOVER_IN_PROGRESS_ON_PRIMARY = "CommitFailoverInProgressOnPrimary" + """Commit failover is in progress on the primary side.""" COMMIT_FAILOVER_IN_PROGRESS_ON_RECOVERY = "CommitFailoverInProgressOnRecovery" + """Commit failover is in progress on the recovery side.""" COMMIT_FAILOVER_COMPLETED = "CommitFailoverCompleted" + """Commit failover has been completed successfully.""" COMMIT_FAILOVER_FAILED_ON_PRIMARY = "CommitFailoverFailedOnPrimary" + """Commit failover failed on the primary side.""" COMMIT_FAILOVER_FAILED_ON_RECOVERY = "CommitFailoverFailedOnRecovery" + """Commit failover failed on the recovery side.""" COMMIT_FAILOVER_STATES_END = "CommitFailoverStatesEnd" + """End marker for commit failover states.""" CANCEL_FAILOVER_STATES_BEGIN = "CancelFailoverStatesBegin" + """Begin marker for cancel failover states.""" CANCEL_FAILOVER_IN_PROGRESS_ON_PRIMARY = "CancelFailoverInProgressOnPrimary" + """Cancel failover is in progress on the primary side.""" CANCEL_FAILOVER_IN_PROGRESS_ON_RECOVERY = "CancelFailoverInProgressOnRecovery" + """Cancel failover is in progress on the recovery side.""" CANCEL_FAILOVER_FAILED_ON_PRIMARY = "CancelFailoverFailedOnPrimary" + """Cancel failover failed on the primary side.""" CANCEL_FAILOVER_FAILED_ON_RECOVERY = "CancelFailoverFailedOnRecovery" + """Cancel failover failed on the recovery side.""" CANCEL_FAILOVER_STATES_END = "CancelFailoverStatesEnd" + """End marker for cancel failover states.""" CHANGE_RECOVERY_POINT_STATES_BEGIN = "ChangeRecoveryPointStatesBegin" + """Begin marker for change recovery point states.""" CHANGE_RECOVERY_POINT_INITIATED = "ChangeRecoveryPointInitiated" + """Change recovery point has been initiated..""" CHANGE_RECOVERY_POINT_COMPLETED = "ChangeRecoveryPointCompleted" + """Change recovery point has been completed successfully.""" CHANGE_RECOVERY_POINT_FAILED = "ChangeRecoveryPointFailed" + """Change recovery point has failed.""" CHANGE_RECOVERY_POINT_STATES_END = "ChangeRecoveryPointStatesEnd" + """End marker for change recovery point states.""" REPROTECT_STATES_BEGIN = "ReprotectStatesBegin" + """Begin marker for reprotect states.""" REPROTECT_INITIATED = "ReprotectInitiated" + """Reprotect has been initiated.""" REPROTECT_FAILED = "ReprotectFailed" + """Reprotect has failed.""" REPROTECT_STATES_END = "ReprotectStatesEnd" + """End marker for reprotect states.""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the provisioning state of the Dra.""" + """Gets or sets the provisioning state of the email configuration.""" CANCELED = "Canceled" + """Resource creation has been canceled""" CREATING = "Creating" + """Resource is being created.""" DELETING = "Deleting" + """Resource is being deleted.""" DELETED = "Deleted" + """Resource has been deleted.""" FAILED = "Failed" + """Resource creation failed.""" SUCCEEDED = "Succeeded" + """Resource creation/update succeeded.""" UPDATING = "Updating" + """Resource is being updated.""" class RecoveryPointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the recovery point type.""" APPLICATION_CONSISTENT = "ApplicationConsistent" + """Application consistent recovery point.""" CRASH_CONSISTENT = "CrashConsistent" + """Crash consistent recovery point.""" class ReplicationVaultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the type of vault.""" DISASTER_RECOVERY = "DisasterRecovery" + """Disaster recovery vault.""" MIGRATE = "Migrate" + """Migrate vault.""" class ResynchronizationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the resynchronization state.""" NONE = "None" + """Resynchronization is not active.""" RESYNCHRONIZATION_INITIATED = "ResynchronizationInitiated" + """Resynchronization has been initiated.""" RESYNCHRONIZATION_COMPLETED = "ResynchronizationCompleted" + """Resynchronization has been completed successfully.""" RESYNCHRONIZATION_FAILED = "ResynchronizationFailed" + """Resynchronization has failed and would need to be started again.""" class TaskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the task state.""" PENDING = "Pending" + """Task has not been started.""" STARTED = "Started" + """Task is in progress.""" SUCCEEDED = "Succeeded" + """Task has completed successfully.""" FAILED = "Failed" + """Task failed.""" CANCELLED = "Cancelled" + """Task has been cancelled.""" SKIPPED = "Skipped" + """Task has been skipped.""" class TestFailoverState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the test failover state.""" NONE = "None" + """Test failover is not active.""" TEST_FAILOVER_INITIATED = "TestFailoverInitiated" + """Test failover has been initiated.""" TEST_FAILOVER_COMPLETING = "TestFailoverCompleting" + """Preparing test protected entities is in progress.""" TEST_FAILOVER_COMPLETED = "TestFailoverCompleted" + """Test failover has been completed successfully.""" TEST_FAILOVER_FAILED = "TestFailoverFailed" + """Test failover initiation failed..""" TEST_FAILOVER_COMPLETION_FAILED = "TestFailoverCompletionFailed" + """Preparing test protected entities failed.""" TEST_FAILOVER_CLEANUP_INITIATED = "TestFailoverCleanupInitiated" + """Test failover cleanup has been initiated.""" TEST_FAILOVER_CLEANUP_COMPLETING = "TestFailoverCleanupCompleting" + """Cleaning up test protected entities is in progress.""" MARKED_FOR_DELETION = "MarkedForDeletion" + """Test failover cleanup has completed/failed. This is a transient state before the state is moved + back to None.""" + + +class VaultIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets or sets the identityType which can be either SystemAssigned or None.""" + + NONE = "None" + """No identity.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """System assigned identity.""" + USER_ASSIGNED = "UserAssigned" + """User assigned identity.""" class VMNicSelection(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the selection type of the NIC.""" NOT_SELECTED = "NotSelected" + """Not Selected.""" SELECTED_BY_USER = "SelectedByUser" + """Selected by user.""" SELECTED_BY_DEFAULT = "SelectedByDefault" + """Default selection by ASR.""" SELECTED_BY_USER_OVERRIDE = "SelectedByUserOverride" + """NIC configuration overridden by user. Differs from SelectedByUser in the sense that the legacy + SelectedByUser is used both for explicit modification by user and implicit approval of user if + the settings are used for TFO/FO. SelectedByUserOverride implies user overriding at least one + of the configurations.""" class VMwareToAzureMigrateResyncState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the resync state.""" NONE = "None" + """None state.""" PREPARED_FOR_RESYNCHRONIZATION = "PreparedForResynchronization" + """Prepared for resynchronization state.""" STARTED_RESYNCHRONIZATION = "StartedResynchronization" - - -class WorkflowObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the object type.""" - - AVS_DISK_POOL = "AvsDiskPool" - DRA = "Dra" - FABRIC = "Fabric" - POLICY = "Policy" - PROTECTED_ITEM = "ProtectedItem" - RECOVERY_PLAN = "RecoveryPlan" - REPLICATION_EXTENSION = "ReplicationExtension" - VAULT = "Vault" - - -class WorkflowState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the workflow state.""" - - PENDING = "Pending" - STARTED = "Started" - CANCELLING = "Cancelling" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELLED = "Cancelled" - COMPLETED_WITH_INFORMATION = "CompletedWithInformation" - COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" - COMPLETED_WITH_ERRORS = "CompletedWithErrors" + """Started resynchronization state.""" diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/__init__.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/__init__.py index 08f3ec0219c3..4fb5feec9c05 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/__init__.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/__init__.py @@ -5,53 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._dra_operations import DraOperations -from ._dra_operation_status_operations import DraOperationStatusOperations -from ._email_configuration_operations import EmailConfigurationOperations -from ._event_operations import EventOperations -from ._fabric_operations import FabricOperations -from ._fabric_operations_status_operations import FabricOperationsStatusOperations -from ._policy_operations import PolicyOperations -from ._policy_operation_status_operations import PolicyOperationStatusOperations -from ._protected_item_operations import ProtectedItemOperations -from ._protected_item_operation_status_operations import ProtectedItemOperationStatusOperations -from ._recovery_points_operations import RecoveryPointsOperations -from ._replication_extension_operations import ReplicationExtensionOperations -from ._replication_extension_operation_status_operations import ReplicationExtensionOperationStatusOperations -from ._recovery_services_data_replication_mgmt_client_operations import ( - RecoveryServicesDataReplicationMgmtClientOperationsMixin, -) -from ._operations import Operations -from ._vault_operations import VaultOperations -from ._vault_operation_status_operations import VaultOperationStatusOperations -from ._workflow_operations import WorkflowOperations -from ._workflow_operation_status_operations import WorkflowOperationStatusOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore +from ._fabric_operations import FabricOperations # type: ignore +from ._vault_operations import VaultOperations # type: ignore +from ._deployment_preflight_operations import DeploymentPreflightOperations # type: ignore +from ._location_based_operation_results_operations import LocationBasedOperationResultsOperations # type: ignore +from ._operation_results_operations import OperationResultsOperations # type: ignore +from ._fabric_agent_operations import FabricAgentOperations # type: ignore +from ._email_configuration_operations import EmailConfigurationOperations # type: ignore +from ._event_operations import EventOperations # type: ignore +from ._job_operations import JobOperations # type: ignore +from ._private_endpoint_connection_proxies_operations import PrivateEndpointConnectionProxiesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._protected_item_operations import ProtectedItemOperations # type: ignore +from ._recovery_point_operations import RecoveryPointOperations # type: ignore +from ._replication_extension_operations import ReplicationExtensionOperations # type: ignore +from ._policy_operations import PolicyOperations # 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__ = [ - "DraOperations", - "DraOperationStatusOperations", + "Operations", + "CheckNameAvailabilityOperations", + "FabricOperations", + "VaultOperations", + "DeploymentPreflightOperations", + "LocationBasedOperationResultsOperations", + "OperationResultsOperations", + "FabricAgentOperations", "EmailConfigurationOperations", "EventOperations", - "FabricOperations", - "FabricOperationsStatusOperations", - "PolicyOperations", - "PolicyOperationStatusOperations", + "JobOperations", + "PrivateEndpointConnectionProxiesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", "ProtectedItemOperations", - "ProtectedItemOperationStatusOperations", - "RecoveryPointsOperations", + "RecoveryPointOperations", "ReplicationExtensionOperations", - "ReplicationExtensionOperationStatusOperations", - "RecoveryServicesDataReplicationMgmtClientOperationsMixin", - "Operations", - "VaultOperations", - "VaultOperationStatusOperations", - "WorkflowOperations", - "WorkflowOperationStatusOperations", + "PolicyOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_check_name_availability_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_check_name_availability_operations.py new file mode 100644 index 000000000000..889d9194e463 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_check_name_availability_operations.py @@ -0,0 +1,209 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_post_request(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", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/locations/{location}/checkNameAvailability", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`check_name_availability` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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") + + @overload + def post( + self, + location: str, + body: Optional[_models.CheckNameAvailabilityModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def post( + self, location: str, body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def post( + self, location: str, body: Optional[Union[_models.CheckNameAvailabilityModel, IO[bytes]]] = None, **kwargs: Any + ) -> _models.CheckNameAvailabilityResponseModel: + """Performs the resource name availability check. + + Checks the resource name availability. + + :param location: The name of the Azure region. Required. + :type location: str + :param body: Resource details. Is either a CheckNameAvailabilityModel type or a IO[bytes] type. + Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel or + IO[bytes] + :return: CheckNameAvailabilityResponseModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResponseModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "CheckNameAvailabilityModel") + else: + _json = None + + _request = build_post_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResponseModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_deployment_preflight_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_deployment_preflight_operations.py new file mode 100644 index 000000000000..f62732e02830 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_deployment_preflight_operations.py @@ -0,0 +1,235 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_post_request( + resource_group_name: str, deployment_id: 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", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/deployments/{deploymentId}/preflight", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentPreflightOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`deployment_preflight` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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") + + @overload + def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[_models.DeploymentPreflightModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def post( + self, + resource_group_name: str, + deployment_id: str, + body: Optional[Union[_models.DeploymentPreflightModel, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.DeploymentPreflightModel: + """Performs resource deployment validation. + + Performs resource deployment preflight validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_id: Deployment Id. Required. + :type deployment_id: str + :param body: Deployment preflight model. Is either a DeploymentPreflightModel type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel or + IO[bytes] + :return: DeploymentPreflightModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeploymentPreflightModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "DeploymentPreflightModel") + else: + _json = None + + _request = build_post_request( + resource_group_name=resource_group_name, + deployment_id=deployment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentPreflightModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operation_status_operations.py deleted file mode 100644 index 977ad0befa9a..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operation_status_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - fabric_name: str, - fabric_agent_name: str, - operation_id: 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", "2021-02-16-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}/operations/{operationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "fabricAgentName": _SERIALIZER.url("fabric_agent_name", fabric_agent_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _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) - - -class DraOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`dra_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - 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") - - @distributed_trace - def get( - self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the fabric agent (Dra) operation status. - - Tracks the results of an asynchronous operation on the fabric agent. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. - :type fabric_agent_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - fabric_name=fabric_name, - fabric_agent_name=fabric_agent_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_email_configuration_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_email_configuration_operations.py index 76eb74a3aa7c..95245a34ad6b 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_email_configuration_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_email_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,12 @@ # Code generated by Microsoft (R) AutoRest 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 from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +22,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,29 +38,24 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, vault_name: str, email_configuration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "emailConfigurationName": _SERIALIZER.url( - "email_configuration_name", email_configuration_name, "str", pattern=r"^[a-zA-Z0-9]*$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -73,21 +69,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( +def build_get_request( resource_group_name: str, vault_name: str, email_configuration_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -105,31 +100,35 @@ def build_create_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_create_request( + resource_group_name: str, vault_name: str, email_configuration_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "emailConfigurationName": _SERIALIZER.url( + "email_configuration_name", email_configuration_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -138,9 +137,11 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class EmailConfigurationOperations: @@ -157,18 +158,104 @@ class EmailConfigurationOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.EmailConfigurationModel"]: + """Gets the list of alert configuration settings for the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either EmailConfigurationModel or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EmailConfigurationModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EmailConfigurationModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( self, resource_group_name: str, vault_name: str, email_configuration_name: str, **kwargs: Any ) -> _models.EmailConfigurationModel: - """Gets the email configuration setting. - - Gets the details of the alert configuration setting. + """Gets the details of the alert configuration setting. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -177,12 +264,11 @@ def get( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,22 +282,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EmailConfigurationModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, email_configuration_name=email_configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,16 +305,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) + deserialized = self._deserialize("EmailConfigurationModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" - } + return deserialized # type: ignore @overload def create( @@ -238,14 +318,12 @@ def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[_models.EmailConfigurationModel] = None, + body: _models.EmailConfigurationModel, *, content_type: str = "application/json", **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -254,12 +332,11 @@ def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Default value is None. + :param body: EmailConfiguration model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: @@ -271,14 +348,12 @@ def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -287,12 +362,11 @@ def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Default value is None. - :type body: IO + :param body: EmailConfiguration model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: @@ -304,12 +378,10 @@ def create( resource_group_name: str, vault_name: str, email_configuration_name: str, - body: Optional[Union[_models.EmailConfigurationModel, IO]] = None, + body: Union[_models.EmailConfigurationModel, IO[bytes]], **kwargs: Any ) -> _models.EmailConfigurationModel: - """Creates email configuration settings. - - Creates an alert configuration setting for the given vault. + """Creates an alert configuration setting for the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -318,18 +390,15 @@ def create( :type vault_name: str :param email_configuration_name: The email configuration name. Required. :type email_configuration_name: str - :param body: EmailConfiguration model. Is either a EmailConfigurationModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: EmailConfiguration model. Is either a EmailConfigurationModel type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel or + IO[bytes] :return: EmailConfigurationModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -350,12 +419,9 @@ def create( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "EmailConfigurationModel") - else: - _json = None + _json = self._serialize.body(body, "EmailConfigurationModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, email_configuration_name=email_configuration_name, @@ -364,16 +430,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,113 +447,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EmailConfigurationModel", pipeline_response) + deserialized = self._deserialize("EmailConfigurationModel", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" - } - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> Iterable["_models.EmailConfigurationModel"]: - """Lists the email configuration settings. - - Gets the list of alert configuration settings for the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EmailConfigurationModel or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EmailConfigurationModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EmailConfigurationModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EmailConfigurationModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_event_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_event_operations.py index b4a46cef69b4..414bfbfb5dfb 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_event_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_event_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,33 +37,47 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, vault_name: str, event_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, + vault_name: str, + subscription_id: str, + *, + odata_options: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, + **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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events/{eventName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "eventName": _SERIALIZER.url("event_name", event_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if odata_options is not None: + _params["odataOptions"] = _SERIALIZER.query("odata_options", odata_options, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -70,43 +85,32 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - vault_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any +def build_get_request( + resource_group_name: str, vault_name: str, event_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events/{eventName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "eventName": _SERIALIZER.url("event_name", event_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -129,102 +133,36 @@ class EventOperations: def __init__(self, *args, **kwargs): 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") - - @distributed_trace - def get(self, resource_group_name: str, vault_name: str, event_name: str, **kwargs: Any) -> _models.EventModel: - """Gets the event. - - Gets the details of the event. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param event_name: The event name. Required. - :type event_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EventModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EventModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - event_name=event_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("EventModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events/{eventName}" - } + 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, resource_group_name: str, vault_name: str, - filter: Optional[str] = None, + odata_options: Optional[str] = None, continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, **kwargs: Any ) -> Iterable["_models.EventModel"]: - """Lists the events. - - Gets the list of events in the given vault. + """Gets the list of events in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param filter: Filter string. Default value is None. - :type filter: str + :param odata_options: OData options. Default value is None. + :type odata_options: str :param continuation_token_parameter: Continuation token. Default value is None. :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param page_size: Page size. Default value is None. + :type page_size: int :return: An iterator like instance of either EventModel or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.EventModel] @@ -234,9 +172,9 @@ def list( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.EventModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.EventModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,19 +185,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, - filter=filter, + odata_options=odata_options, continuation_token_parameter=continuation_token_parameter, + page_size=page_size, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -271,27 +208,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("EventModelCollection", pipeline_response) + deserialized = self._deserialize("EventModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,6 +240,61 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events" - } + @distributed_trace + def get(self, resource_group_name: str, vault_name: str, event_name: str, **kwargs: Any) -> _models.EventModel: + """Gets the details of the event. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param event_name: The event name. Required. + :type event_name: str + :return: EventModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.EventModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EventModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + event_name=event_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_agent_operations.py similarity index 68% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_agent_operations.py index 5262955f1869..49d73364eed6 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_dra_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_agent_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,27 +42,24 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, fabric_name: str, fabric_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_group_name: str, fabric_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "fabricAgentName": _SERIALIZER.url("fabric_agent_name", fabric_agent_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -73,21 +73,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( +def build_get_request( resource_group_name: str, fabric_name: str, fabric_agent_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -103,27 +102,26 @@ def build_create_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_request( resource_group_name: str, fabric_name: str, fabric_agent_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -139,29 +137,34 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, fabric_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, fabric_name: str, fabric_agent_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "fabricAgentName": _SERIALIZER.url("fabric_agent_name", fabric_agent_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -172,49 +175,131 @@ def build_list_request(resource_group_name: str, fabric_name: str, subscription_ # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class DraOperations: +class FabricAgentOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`dra` attribute. + :attr:`fabric_agent` attribute. """ models = _models def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, fabric_name: str, **kwargs: Any) -> Iterable["_models.FabricAgentModel"]: + """Gets the list of fabric agents in the given fabric. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param fabric_name: The fabric name. Required. + :type fabric_name: str + :return: An iterator like instance of either FabricAgentModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricAgentModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + fabric_name=fabric_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FabricAgentModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any - ) -> _models.DraModel: - """Gets the fabric agent (Dra). - - Gets the details of the fabric agent. + ) -> _models.FabricAgentModel: + """Gets the details of the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DraModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel + :return: FabricAgentModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,24 +311,22 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[_models.FabricAgentModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -253,26 +336,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DraModel", pipeline_response) + deserialized = self._deserialize("FabricAgentModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[Union[_models.DraModel, IO]] = None, + body: Union[_models.FabricAgentModel, IO[bytes]], **kwargs: Any - ) -> _models.DraModel: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,7 +364,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -293,12 +372,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "DraModel") - else: - _json = None + _json = self._serialize.body(body, "FabricAgentModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, @@ -307,78 +383,71 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DraModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("DraModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } - @overload def begin_create( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[_models.DraModel] = None, + body: _models.FabricAgentModel, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> LROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel + :param body: Fabric agent model. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DraModel or the result of cls(response) + :return: An instance of LROPoller that returns either FabricAgentModel or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -388,38 +457,29 @@ def begin_create( resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> LROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Default value is None. - :type body: IO + :param body: Fabric agent model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DraModel or the result of cls(response) + :return: An instance of LROPoller that returns either FabricAgentModel or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -429,36 +489,25 @@ def begin_create( resource_group_name: str, fabric_name: str, fabric_agent_name: str, - body: Optional[Union[_models.DraModel, IO]] = None, + body: Union[_models.FabricAgentModel, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DraModel]: - """Puts the fabric agent (Dra). - - Creates the fabric agent. + ) -> LROPoller[_models.FabricAgentModel]: + """Creates the fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :param body: Dra model. Is either a DraModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DraModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either DraModel or the result of cls(response) + :param body: Fabric agent model. Is either a FabricAgentModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel or IO[bytes] + :return: An instance of LROPoller that returns either FabricAgentModel or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.FabricAgentModel] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -466,7 +515,7 @@ def begin_create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DraModel] = kwargs.pop("cls", None) + cls: ClsType[_models.FabricAgentModel] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -483,39 +532,38 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DraModel", pipeline_response) + deserialized = self._deserialize("FabricAgentModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.FabricAgentModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return LROPoller[_models.FabricAgentModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,70 +575,61 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( self, resource_group_name: str, fabric_name: str, fabric_agent_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the fabric agent (Dra). - - Deletes the fabric agent. + """Deletes fabric agent. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param fabric_agent_name: The fabric agent (Dra) name. Required. + :param fabric_agent_name: The fabric agent name. Required. :type fabric_agent_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -604,7 +643,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, fabric_name=fabric_name, fabric_agent_name=fabric_agent_name, @@ -614,11 +653,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -629,107 +669,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" - } - - @distributed_trace - def list(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> Iterable["_models.DraModel"]: - """Lists the fabric agents (Dras). - - Gets the list of fabric agents in the given fabric. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DraModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.DraModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.DraModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - fabric_name=fabric_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DraModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations.py index 8656e8d9e466..e22b214450c1 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,24 +42,19 @@ _SERIALIZER.client_side_validation = False -def build_get_request(resource_group_name: str, fabric_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_by_subscription_request(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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationFabrics" + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -70,57 +68,54 @@ def build_get_request(resource_group_name: str, fabric_name: str, subscription_i return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( - resource_group_name: str, fabric_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( - resource_group_name: str, fabric_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_group_name: str, fabric_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -135,27 +130,26 @@ def build_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_request( resource_group_name: str, fabric_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -170,77 +164,80 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any +def build_update_request( + resource_group_name: str, fabric_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationFabrics" - ) # pylint: disable=line-too-long + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any +def build_delete_request( + resource_group_name: str, fabric_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class FabricOperations: @@ -257,28 +254,189 @@ class FabricOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, fabric_name: str, **kwargs: Any) -> _models.FabricModel: - """Gets the fabric. + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.FabricModel"]: + """Gets the list of fabrics in the given subscription. + + :return: An iterator like instance of either FabricModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricModelListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FabricModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response - Gets the details of the fabric. + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.FabricModel"]: + """Gets the list of fabrics in the given subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param continuation_token_parameter: Continuation token from the previous call. Default value + is None. + :type continuation_token_parameter: str + :return: An iterator like instance of either FabricModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FabricModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FabricModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> _models.FabricModel: + """Gets the details of the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FabricModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,21 +450,19 @@ def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> _mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FabricModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -316,25 +472,17 @@ def get(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore def _create_initial( - self, - resource_group_name: str, - fabric_name: str, - body: Optional[Union[_models.FabricModel, IO]] = None, - **kwargs: Any - ) -> _models.FabricModel: - error_map = { + self, resource_group_name: str, fabric_name: str, body: Union[_models.FabricModel, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +495,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FabricModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -355,12 +503,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "FabricModel") - else: - _json = None + _json = self._serialize.body(body, "FabricModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, @@ -368,72 +513,64 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("FabricModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("FabricModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } - @overload def begin_create( self, resource_group_name: str, fabric_name: str, - body: Optional[_models.FabricModel] = None, + body: _models.FabricModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. + :param body: Fabric properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -446,33 +583,23 @@ def begin_create( self, resource_group_name: str, fabric_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. - :type body: IO + :param body: Fabric properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -482,35 +609,17 @@ def begin_create( @distributed_trace def begin_create( - self, - resource_group_name: str, - fabric_name: str, - body: Optional[Union[_models.FabricModel, IO]] = None, - **kwargs: Any + self, resource_group_name: str, fabric_name: str, body: Union[_models.FabricModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Puts the fabric. - - Creates the fabric. + """Creates the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Is either a FabricModel type or a IO type. Default value is - None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Fabric properties. Is either a FabricModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModel or IO[bytes] :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -538,43 +647,42 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.FabricModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return LROPoller[_models.FabricModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, fabric_name: str, - body: Optional[Union[_models.FabricModelUpdate, IO]] = None, + body: Union[_models.FabricModelUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.FabricModel]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -587,7 +695,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FabricModel]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -595,12 +703,9 @@ def _update_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "FabricModelUpdate") - else: - _json = None + _json = self._serialize.body(body, "FabricModelUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, @@ -608,77 +713,62 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("FabricModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[_models.FabricModelUpdate] = None, + body: _models.FabricModelUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. + :param body: Fabric properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -691,33 +781,23 @@ def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Default value is None. - :type body: IO + :param body: Fabric properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -730,32 +810,19 @@ def begin_update( self, resource_group_name: str, fabric_name: str, - body: Optional[Union[_models.FabricModelUpdate, IO]] = None, + body: Union[_models.FabricModelUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FabricModel]: - """Updates the fabric. - - Performs update on the fabric. + """Performs update on the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :param body: Fabric properties. Is either a FabricModelUpdate type or a IO type. Default value - is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Fabric properties. Is either a FabricModelUpdate type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.FabricModelUpdate or IO[bytes] :return: An instance of LROPoller that returns either FabricModel or the result of cls(response) :rtype: @@ -783,12 +850,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FabricModel", pipeline_response) + deserialized = self._deserialize("FabricModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -800,22 +868,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.FabricModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return LROPoller[_models.FabricModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, fabric_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -827,65 +891,56 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, fabric_name=fabric_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, fabric_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the fabric. - - Removes the fabric. + """Removes the fabric. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param fabric_name: The fabric name. Required. :type fabric_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -899,7 +954,7 @@ def begin_delete(self, resource_group_name: str, fabric_name: str, **kwargs: Any lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, fabric_name=fabric_name, api_version=api_version, @@ -908,11 +963,12 @@ def begin_delete(self, resource_group_name: str, fabric_name: str, **kwargs: Any params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -923,202 +979,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" - } - - @distributed_trace - def list_by_subscription( - self, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FabricModel"]: - """Lists the fabrics. - - Gets the list of fabrics in the given subscription. - - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FabricModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FabricModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_by_subscription_request( - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("FabricModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationFabrics" - } - - @distributed_trace - def list( - self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FabricModel"]: - """Lists the fabrics. - - Gets the list of fabrics in the given subscription and resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FabricModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.FabricModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FabricModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("FabricModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_job_operations.py similarity index 73% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_job_operations.py index 5f52efa9e62d..eb5e20455940 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,33 +37,47 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, vault_name: str, job_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, + vault_name: str, + subscription_id: str, + *, + odata_options: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, + **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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if odata_options is not None: + _params["odataOptions"] = _SERIALIZER.query("odata_options", odata_options, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -70,43 +85,32 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - vault_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any +def build_get_request( + resource_group_name: str, vault_name: str, job_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -115,128 +119,62 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkflowOperations: +class JobOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`workflow` attribute. + :attr:`job` attribute. """ models = _models def __init__(self, *args, **kwargs): 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") - - @distributed_trace - def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs: Any) -> _models.WorkflowModel: - """Gets the job (workflow). - - Gets the details of the job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param job_name: The job (workflow) name. Required. - :type job_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkflowModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WorkflowModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WorkflowModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}" - } + 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, resource_group_name: str, vault_name: str, - filter: Optional[str] = None, + odata_options: Optional[str] = None, continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.WorkflowModel"]: - """Lists the jobs (workflows). - - Gets the list of jobs in the given vault. + ) -> Iterable["_models.JobModel"]: + """Gets the list of jobs in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param filter: Filter string. Default value is None. - :type filter: str + :param odata_options: OData options. Default value is None. + :type odata_options: str :param continuation_token_parameter: Continuation token. Default value is None. :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkflowModel or the result of cls(response) + :param page_size: Page size. Default value is None. + :type page_size: int + :return: An iterator like instance of either JobModel or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.WorkflowModel] + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.JobModel] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WorkflowModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.JobModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,19 +185,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, - filter=filter, + odata_options=odata_options, continuation_token_parameter=continuation_token_parameter, + page_size=page_size, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -271,27 +208,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("WorkflowModelCollection", pipeline_response) + deserialized = self._deserialize("JobModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,6 +240,61 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs" - } + @distributed_trace + def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs: Any) -> _models.JobModel: + """Gets the details of the job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param job_name: The job name. Required. + :type job_name: str + :return: JobModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.JobModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_location_based_operation_results_operations.py similarity index 68% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operation_status_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_location_based_operation_results_operations.py index c6185658985f..99a1275e8af3 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operation_status_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_location_based_operation_results_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -35,25 +36,25 @@ def build_get_request( - resource_group_name: str, vault_name: str, operation_id: str, subscription_id: str, **kwargs: Any + resource_group_name: str, location: str, operation_id: 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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/operations/{operationId}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/locations/{location}/operationResults/{operationId}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } @@ -68,46 +69,45 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class VaultOperationStatusOperations: +class LocationBasedOperationResultsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`vault_operation_status` attribute. + :attr:`location_based_operation_results` attribute. """ models = _models def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, vault_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the vault operation status. + def get(self, resource_group_name: str, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatus: + """Gets the location based operation result status. - Tracks the results of an asynchronous operation on the vault. + Gets the location based operation result. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,22 +121,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, - vault_name=vault_name, + location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,13 +144,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operation_results_operations.py similarity index 67% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations_status_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operation_results_operations.py index 549f599e9efc..39d74fd9dde2 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_fabric_operations_status_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operation_results_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -34,26 +35,23 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, fabric_name: str, operation_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_group_name: str, operation_id: 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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/operations/{operationId}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/operationResults/{operationId}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/{operationId}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "fabricName": _SERIALIZER.url("fabric_name", fabric_name, "str", pattern=r"^[a-zA-Z0-9]*$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } @@ -68,46 +66,43 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class FabricOperationsStatusOperations: +class OperationResultsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`fabric_operations_status` attribute. + :attr:`operation_results` attribute. """ models = _models def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, fabric_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the fabric operation status. + def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _models.OperationStatus: + """Gets the operation result status. - Tracks the results of an asynchronous operation on the fabric. + Gets the operations. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param fabric_name: The fabric name. Required. - :type fabric_name: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,22 +116,19 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, - fabric_name=fabric_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,13 +138,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operations.py index e7b985fd53b1..2226e9a767e4 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ def build_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,18 +69,17 @@ class Operations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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"]: - """Get a list of REST API operations supported by Microsoft.DataReplication. + """List the operations for the provider. - Gets the operations. - - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.Operation] @@ -92,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -138,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DataReplication/operations"} diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operation_status_operations.py deleted file mode 100644 index 2e2de6cb0936..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operation_status_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, vault_name: str, policy_name: str, operation_id: 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", "2021-02-16-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}/operations/{operationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _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) - - -class PolicyOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`policy_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - 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") - - @distributed_trace - def get( - self, resource_group_name: str, vault_name: str, policy_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the policy operation status. - - Tracks the results of an asynchronous operation on the policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param policy_name: The policy name. Required. - :type policy_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - policy_name=policy_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operations.py index 2ecd6317a684..b00f5b066e90 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_policy_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,27 +42,24 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, vault_name: str, policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -73,21 +73,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( +def build_get_request( resource_group_name: str, vault_name: str, policy_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -103,27 +102,26 @@ def build_create_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_request( resource_group_name: str, vault_name: str, policy_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -139,29 +137,34 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, vault_name: str, policy_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -172,7 +175,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class PolicyOperations: @@ -189,16 +192,99 @@ class PolicyOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, vault_name: str, policy_name: str, **kwargs: Any) -> _models.PolicyModel: - """Gets the policy. + def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterable["_models.PolicyModel"]: + """Gets the list of policies in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PolicyModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyModelListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - Gets the details of the policy. + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any) -> _models.PolicyModel: + """Gets the details of the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -207,12 +293,11 @@ def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwa :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,22 +311,20 @@ def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,26 +334,22 @@ def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwa error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyModel", pipeline_response) + deserialized = self._deserialize("PolicyModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[Union[_models.PolicyModel, IO]] = None, + body: Union[_models.PolicyModel, IO[bytes]], **kwargs: Any - ) -> _models.PolicyModel: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +362,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -291,12 +370,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "PolicyModel") - else: - _json = None + _json = self._serialize.body(body, "PolicyModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, @@ -305,54 +381,54 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PolicyModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("PolicyModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } - @overload def begin_create( self, resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[_models.PolicyModel] = None, + body: _models.PolicyModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -361,19 +437,11 @@ def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Default value is None. + :param body: Policy model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -387,14 +455,12 @@ def begin_create( resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -403,19 +469,11 @@ def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Default value is None. - :type body: IO + :param body: Policy model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -429,12 +487,10 @@ def begin_create( resource_group_name: str, vault_name: str, policy_name: str, - body: Optional[Union[_models.PolicyModel, IO]] = None, + body: Union[_models.PolicyModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PolicyModel]: - """Puts the policy. - - Creates the policy. + """Creates the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -443,19 +499,8 @@ def begin_create( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :param body: Policy model. Is either a PolicyModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Policy model. Is either a PolicyModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel or IO[bytes] :return: An instance of LROPoller that returns either PolicyModel or the result of cls(response) :rtype: @@ -484,39 +529,38 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PolicyModel", pipeline_response) + deserialized = self._deserialize("PolicyModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PolicyModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return LROPoller[_models.PolicyModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,54 +572,53 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the policy. - - Removes the policy. + """Removes the policy. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -584,14 +627,6 @@ def begin_delete( :type vault_name: str :param policy_name: The policy name. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -605,7 +640,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, policy_name=policy_name, @@ -615,11 +650,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -630,107 +666,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" - } - - @distributed_trace - def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterable["_models.PolicyModel"]: - """Lists the policies. - - Gets the list of policies in the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PolicyModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PolicyModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connection_proxies_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connection_proxies_operations.py new file mode 100644 index 000000000000..dd8ebc243145 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connection_proxies_operations.py @@ -0,0 +1,832 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnectionProxies", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + } + + _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_get_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionProxyName": _SERIALIZER.url( + "private_endpoint_connection_proxy_name", + private_endpoint_connection_proxy_name, + "str", + pattern=r"^[a-zA-Z0-9-.]*$", + ), + } + + _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_create_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_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", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionProxyName": _SERIALIZER.url( + "private_endpoint_connection_proxy_name", + private_endpoint_connection_proxy_name, + "str", + pattern=r"^[a-zA-Z0-9-.]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionProxyName": _SERIALIZER.url( + "private_endpoint_connection_proxy_name", + private_endpoint_connection_proxy_name, + "str", + pattern=r"^[a-zA-Z0-9-.]*$", + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_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", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyName}/validate", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionProxyName": _SERIALIZER.url( + "private_endpoint_connection_proxy_name", + private_endpoint_connection_proxy_name, + "str", + pattern=r"^[a-zA-Z0-9-.]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionProxiesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_endpoint_connection_proxies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionProxy"]: + """Gets the all private endpoint connections proxies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateEndpointConnectionProxy or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionProxyListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionProxyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Gets the private endpoint connection proxy details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: _models.PrivateEndpointConnectionProxy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: Union[_models.PrivateEndpointConnectionProxy, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Create a new private endpoint connection proxy which includes both auto and manual approval + types. Creating the proxy resource will also create a private endpoint connection resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: Private endpoint connection creation input. Is either a + PrivateEndpointConnectionProxy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + or IO[bytes] + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnectionProxy") + + _request = build_create_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_proxy_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Returns the operation to track the deletion of private endpoint connection proxy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: _models.PrivateEndpointConnectionProxy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_proxy_name: str, + body: Union[_models.PrivateEndpointConnectionProxy, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionProxy: + """Returns remote private endpoint connection information after validation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_proxy_name: The private endpoint connection proxy name. + Required. + :type private_endpoint_connection_proxy_name: str + :param body: The private endpoint connection proxy input. Is either a + PrivateEndpointConnectionProxy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + or IO[bytes] + :return: PrivateEndpointConnectionProxy or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnectionProxy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionProxy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnectionProxy") + + _request = build_validate_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_proxy_name=private_endpoint_connection_proxy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionProxy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connections_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..ee28d5b23d58 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,627 @@ +# 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) AutoRest 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 +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + } + + _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_get_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _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_update_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_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", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + vault_name: str, + private_endpoint_connection_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """Gets the all private endpoint connections configured on the vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the private endpoint connection details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + body: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updated the private endpoint connection status (Approval/Rejected). This gets invoked by + resource admin. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :param body: Private endpoint connection update input. Is either a PrivateEndpointConnection + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection or + IO[bytes] + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PrivateEndpointConnection") + + _request = build_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, vault_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_endpoint_connection_name: The private endpoint connection name. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_link_resources_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..750544d7d37a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_private_link_resources_operations.py @@ -0,0 +1,270 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, vault_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateLinkResources", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + } + + _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_get_request( + resource_group_name: str, vault_name: str, private_link_resource_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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/privateLinkResources/{privateLinkResourceName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "privateLinkResourceName": _SERIALIZER.url( + "private_link_resource_name", private_link_resource_name, "str", pattern=r"^[a-zA-Z0-9-.]*$" + ), + } + + _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) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterable["_models.PrivateLinkResource"]: + """Gets the list of private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, vault_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the details of site recovery private link resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param private_link_resource_name: The private link name. Required. + :type private_link_resource_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operation_status_operations.py deleted file mode 100644 index c87381ee4525..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operation_status_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - vault_name: str, - protected_item_name: str, - operation_id: 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", "2021-02-16-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/operations/{operationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "protectedItemName": _SERIALIZER.url( - "protected_item_name", protected_item_name, "str", pattern=r"^[a-zA-Z0-9]*$" - ), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _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) - - -class ProtectedItemOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`protected_item_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - 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") - - @distributed_trace - def get( - self, resource_group_name: str, vault_name: str, protected_item_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the protected item operation status. - - Tracks the results of an asynchronous operation on the protected item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param protected_item_name: The protected item name. Required. - :type protected_item_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - protected_item_name=protected_item_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operations.py index ad8e23a236aa..26bfd8555041 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_protected_item_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,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,20 +42,68 @@ _SERIALIZER.client_side_validation = False +def build_list_request( + resource_group_name: str, + vault_name: str, + subscription_id: str, + *, + odata_options: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, + **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", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if odata_options is not None: + _params["odataOptions"] = _SERIALIZER.query("odata_options", odata_options, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_get_request( resource_group_name: str, vault_name: str, protected_item_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -81,7 +132,7 @@ def build_create_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -89,7 +140,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -114,26 +165,21 @@ def build_create_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( - resource_group_name: str, - vault_name: str, - protected_item_name: str, - subscription_id: str, - *, - force_delete: Optional[bool] = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, vault_name: str, protected_item_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -148,45 +194,58 @@ def build_delete_request( _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_delete is not None: - _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, + vault_name: str, + protected_item_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "protectedItemName": _SERIALIZER.url( + "protected_item_name", protected_item_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_planned_failover_request( @@ -195,7 +254,7 @@ def build_planned_failover_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +262,7 @@ def build_planned_failover_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -242,18 +301,118 @@ class ProtectedItemOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, + resource_group_name: str, + vault_name: str, + odata_options: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProtectedItemModel"]: + """Gets the list of protected items in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param odata_options: OData options. Default value is None. + :type odata_options: str + :param continuation_token_parameter: Continuation token. Default value is None. + :type continuation_token_parameter: str + :param page_size: Page size. Default value is None. + :type page_size: int + :return: An iterator like instance of either ProtectedItemModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProtectedItemModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + odata_options=odata_options, + continuation_token_parameter=continuation_token_parameter, + page_size=page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProtectedItemModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( self, resource_group_name: str, vault_name: str, protected_item_name: str, **kwargs: Any ) -> _models.ProtectedItemModel: - """Gets the protected item. - - Gets the details of the protected item. + """Gets the details of the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -262,12 +421,11 @@ def get( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProtectedItemModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,22 +439,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -306,26 +462,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.ProtectedItemModel, IO]] = None, + body: Union[_models.ProtectedItemModel, IO[bytes]], **kwargs: Any - ) -> _models.ProtectedItemModel: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,7 +490,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -346,12 +498,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "ProtectedItemModel") - else: - _json = None + _json = self._serialize.body(body, "ProtectedItemModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, @@ -360,54 +509,54 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } - @overload def begin_create( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[_models.ProtectedItemModel] = None, + body: _models.ProtectedItemModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -416,19 +565,11 @@ def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Default value is None. + :param body: Protected item model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -442,14 +583,12 @@ def begin_create( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -458,19 +597,11 @@ def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Default value is None. - :type body: IO + :param body: Protected item model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -484,12 +615,10 @@ def begin_create( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.ProtectedItemModel, IO]] = None, + body: Union[_models.ProtectedItemModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ProtectedItemModel]: - """Puts the protected item. - - Creates the protected item. + """Creates the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -498,20 +627,9 @@ def begin_create( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Protected item model. Is either a ProtectedItemModel type or a IO type. Default - value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Protected item model. Is either a ProtectedItemModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel or IO[bytes] :return: An instance of LROPoller that returns either ProtectedItemModel or the result of cls(response) :rtype: @@ -540,44 +658,43 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ProtectedItemModel", pipeline_response) + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ProtectedItemModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return LROPoller[_models.ProtectedItemModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _update_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - force_delete: Optional[bool] = None, + body: Union[_models.ProtectedItemModelUpdate, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,64 +702,108 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ProtectedItemModelUpdate") - request = build_delete_request( + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, - force_delete=force_delete, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + return deserialized # type: ignore - @distributed_trace - def begin_delete( + @overload + def begin_update( self, resource_group_name: str, vault_name: str, protected_item_name: str, - force_delete: Optional[bool] = None, + body: _models.ProtectedItemModelUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Deletes the protected item. + ) -> LROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param body: Protected item model. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ - Removes the protected item. + @overload + def begin_update( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -651,46 +812,76 @@ def begin_delete( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param force_delete: A flag indicating whether to do force delete or not. Default value is - None. - :type force_delete: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param body: Protected item model. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + body: Union[_models.ProtectedItemModelUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ProtectedItemModel]: + """Performs update on the protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param body: Protected item model. Is either a ProtectedItemModelUpdate type or a IO[bytes] + type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModelUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either ProtectedItemModel or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProtectedItemModel] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, - force_delete=force_delete, + body=body, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ProtectedItemModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: PollingMethod = cast( @@ -701,120 +892,157 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ProtectedItemModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.ProtectedItemModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" - } + def _delete_initial( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace - def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterable["_models.ProtectedItemModel"]: - """Lists the protected items. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - Gets the list of protected items in the given vault. + _decompress = kwargs.pop("decompress", True) + _stream = True + 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 [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Removes the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProtectedItemModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ProtectedItemModel] + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param force_delete: A flag indicating whether to do force delete or not. Default value is + None. + :type force_delete: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ProtectedItemModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + force_delete=force_delete, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("ProtectedItemModelCollection", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems" - } + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _planned_failover_initial( self, resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.PlannedFailoverModel, IO]] = None, + body: Union[_models.PlannedFailoverModel, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PlannedFailoverModel]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -827,7 +1055,7 @@ def _planned_failover_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PlannedFailoverModel]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -835,12 +1063,9 @@ def _planned_failover_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "PlannedFailoverModel") - else: - _json = None + _json = self._serialize.body(body, "PlannedFailoverModel") - request = build_planned_failover_request( + _request = build_planned_failover_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, @@ -849,44 +1074,39 @@ def _planned_failover_initial( content_type=content_type, json=_json, content=_content, - template_url=self._planned_failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("PlannedFailoverModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _planned_failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover" - } + return deserialized # type: ignore @overload def begin_planned_failover( @@ -894,14 +1114,12 @@ def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[_models.PlannedFailoverModel] = None, + body: _models.PlannedFailoverModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -910,19 +1128,11 @@ def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Default value is None. + :param body: Planned failover model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -936,14 +1146,12 @@ def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -952,19 +1160,11 @@ def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Default value is None. - :type body: IO + :param body: Planned failover model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -978,12 +1178,10 @@ def begin_planned_failover( resource_group_name: str, vault_name: str, protected_item_name: str, - body: Optional[Union[_models.PlannedFailoverModel, IO]] = None, + body: Union[_models.PlannedFailoverModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PlannedFailoverModel]: - """Performs planned failover. - - Performs the planned failover on the protected item. + """Performs the planned failover on the protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -992,20 +1190,10 @@ def begin_planned_failover( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :param body: Planned failover model. Is either a PlannedFailoverModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Planned failover model. Is either a PlannedFailoverModel type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.PlannedFailoverModel or + IO[bytes] :return: An instance of LROPoller that returns either PlannedFailoverModel or the result of cls(response) :rtype: @@ -1034,12 +1222,13 @@ def begin_planned_failover( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PlannedFailoverModel", pipeline_response) + deserialized = self._deserialize("PlannedFailoverModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1051,14 +1240,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PlannedFailoverModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_planned_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover" - } + return LROPoller[_models.PlannedFailoverModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_points_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_point_operations.py similarity index 79% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_points_operations.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_point_operations.py index 5bd051045b4c..cb1ef557589b 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_points_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_point_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,25 +37,20 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, - vault_name: str, - protected_item_name: str, - recovery_point_name: str, - subscription_id: str, - **kwargs: Any +def build_list_request( + resource_group_name: str, vault_name: str, protected_item_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -64,9 +60,6 @@ def build_get_request( "protectedItemName": _SERIALIZER.url( "protected_item_name", protected_item_name, "str", pattern=r"^[a-zA-Z0-9]*$" ), - "recoveryPointName": _SERIALIZER.url( - "recovery_point_name", recovery_point_name, "str", pattern=r"^[a-zA-Z0-9]*$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -80,20 +73,25 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, vault_name: str, protected_item_name: str, subscription_id: str, **kwargs: Any +def build_get_request( + resource_group_name: str, + vault_name: str, + protected_item_name: str, + recovery_point_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -103,6 +101,9 @@ def build_list_request( "protectedItemName": _SERIALIZER.url( "protected_item_name", protected_item_name, "str", pattern=r"^[a-zA-Z0-9]*$" ), + "recoveryPointName": _SERIALIZER.url( + "recovery_point_name", recovery_point_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -116,110 +117,32 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RecoveryPointsOperations: +class RecoveryPointOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`recovery_points` attribute. + :attr:`recovery_point` attribute. """ models = _models def __init__(self, *args, **kwargs): 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") - - @distributed_trace - def get( - self, - resource_group_name: str, - vault_name: str, - protected_item_name: str, - recovery_point_name: str, - **kwargs: Any - ) -> _models.RecoveryPointModel: - """Gets the recovery point. - - Gets the details of the recovery point of a protected item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param protected_item_name: The protected item name. Required. - :type protected_item_name: str - :param recovery_point_name: The recovery point name. Required. - :type recovery_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecoveryPointModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RecoveryPointModel] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - protected_item_name=protected_item_name, - recovery_point_name=recovery_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryPointModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointName}" - } + 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, resource_group_name: str, vault_name: str, protected_item_name: str, **kwargs: Any ) -> Iterable["_models.RecoveryPointModel"]: - """Lists the recovery points. - - Gets the list of recovery points of the given protected item. + """Gets the list of recovery points of the given protected item. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -228,7 +151,6 @@ def list( :type vault_name: str :param protected_item_name: The protected item name. Required. :type protected_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecoveryPointModel or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel] @@ -238,9 +160,9 @@ def list( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RecoveryPointModelCollection] = kwargs.pop("cls", None) + cls: ClsType[_models.RecoveryPointModelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,18 +173,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, vault_name=vault_name, protected_item_name=protected_item_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -274,27 +194,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("RecoveryPointModelCollection", pipeline_response) + deserialized = self._deserialize("RecoveryPointModelListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,6 +226,71 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints" - } + @distributed_trace + def get( + self, + resource_group_name: str, + vault_name: str, + protected_item_name: str, + recovery_point_name: str, + **kwargs: Any + ) -> _models.RecoveryPointModel: + """Gets the details of the recovery point of a protected item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :param protected_item_name: The protected item name. Required. + :type protected_item_name: str + :param recovery_point_name: The recovery point name. Required. + :type recovery_point_name: str + :return: RecoveryPointModel or the result of cls(response) + :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.RecoveryPointModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecoveryPointModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + protected_item_name=protected_item_name, + recovery_point_name=recovery_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecoveryPointModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_services_data_replication_mgmt_client_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_services_data_replication_mgmt_client_operations.py deleted file mode 100644 index ccb1b619145a..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_recovery_services_data_replication_mgmt_client_operations.py +++ /dev/null @@ -1,387 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_name_availability_request(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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/locations/{location}/checkNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_deployment_preflight_request( - resource_group_name: str, deployment_id: 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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/deployments/{deploymentId}/preflight", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RecoveryServicesDataReplicationMgmtClientOperationsMixin(RecoveryServicesDataReplicationMgmtClientMixinABC): - @overload - def check_name_availability( - self, - location: str, - body: Optional[_models.CheckNameAvailabilityModel] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, location: str, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, location: str, body: Optional[Union[_models.CheckNameAvailabilityModel, IO]] = None, **kwargs: Any - ) -> _models.CheckNameAvailabilityResponseModel: - """Performs the resource name availability check. - - Checks the resource name availability. - - :param location: The name of the Azure region. Required. - :type location: str - :param body: Resource details. Is either a CheckNameAvailabilityModel type or a IO type. - Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponseModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.CheckNameAvailabilityResponseModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckNameAvailabilityResponseModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "CheckNameAvailabilityModel") - else: - _json = None - - request = build_check_name_availability_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.check_name_availability.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResponseModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/locations/{location}/checkNameAvailability" - } - - @overload - def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[_models.DeploymentPreflightModel] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def deployment_preflight( - self, - resource_group_name: str, - deployment_id: str, - body: Optional[Union[_models.DeploymentPreflightModel, IO]] = None, - **kwargs: Any - ) -> _models.DeploymentPreflightModel: - """Performs resource deployment validation. - - Performs resource deployment validation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param deployment_id: Deployment Id. Required. - :type deployment_id: str - :param body: Deployment preflight model. Is either a DeploymentPreflightModel type or a IO - type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentPreflightModel or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.DeploymentPreflightModel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DeploymentPreflightModel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DeploymentPreflightModel") - else: - _json = None - - request = build_deployment_preflight_request( - resource_group_name=resource_group_name, - deployment_id=deployment_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.deployment_preflight.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeploymentPreflightModel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - deployment_preflight.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/deployments/{deploymentId}/preflight" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operation_status_operations.py deleted file mode 100644 index 1aad3a654dec..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operation_status_operations.py +++ /dev/null @@ -1,174 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - vault_name: str, - replication_extension_name: str, - operation_id: 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", "2021-02-16-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}/operations/{operationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "replicationExtensionName": _SERIALIZER.url( - "replication_extension_name", replication_extension_name, "str", pattern=r"^[a-zA-Z0-9]*$" - ), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _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) - - -class ReplicationExtensionOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`replication_extension_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - 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") - - @distributed_trace - def get( - self, - resource_group_name: str, - vault_name: str, - replication_extension_name: str, - operation_id: str, - **kwargs: Any - ) -> _models.OperationStatus: - """Gets the replication extension operation status. - - Tracks the results of an asynchronous operation on the replication extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param replication_extension_name: The replication extension name. Required. - :type replication_extension_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - replication_extension_name=replication_extension_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operations.py index 9cfb530c121f..abeb55bd0abb 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_replication_extension_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,29 +42,24 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, vault_name: str, replication_extension_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "replicationExtensionName": _SERIALIZER.url( - "replication_extension_name", replication_extension_name, "str", pattern=r"^[a-zA-Z0-9]*$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -75,21 +73,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( +def build_get_request( resource_group_name: str, vault_name: str, replication_extension_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -107,27 +104,26 @@ def build_create_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_request( resource_group_name: str, vault_name: str, replication_extension_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -145,29 +141,36 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_request( + resource_group_name: str, vault_name: str, replication_extension_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), + "replicationExtensionName": _SERIALIZER.url( + "replication_extension_name", replication_extension_name, "str", pattern=r"^[a-zA-Z0-9]*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -178,7 +181,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class ReplicationExtensionOperations: @@ -195,18 +198,104 @@ class ReplicationExtensionOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> Iterable["_models.ReplicationExtensionModel"]: + """Gets the list of replication extensions in the given vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The vault name. Required. + :type vault_name: str + :return: An iterator like instance of either ReplicationExtensionModel or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ReplicationExtensionModelListResult] = 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_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationExtensionModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any ) -> _models.ReplicationExtensionModel: - """Gets the replication extension. - - Gets the details of the replication extension. + """Gets the details of the replication extension. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -215,12 +304,11 @@ def get( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationExtensionModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,22 +322,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationExtensionModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,26 +345,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[Union[_models.ReplicationExtensionModel, IO]] = None, + body: Union[_models.ReplicationExtensionModel, IO[bytes]], **kwargs: Any - ) -> _models.ReplicationExtensionModel: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -291,7 +373,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ReplicationExtensionModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -299,12 +381,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "ReplicationExtensionModel") - else: - _json = None + _json = self._serialize.body(body, "ReplicationExtensionModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, @@ -313,54 +392,54 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } - @overload def begin_create( self, resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[_models.ReplicationExtensionModel] = None, + body: _models.ReplicationExtensionModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -369,19 +448,11 @@ def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Default value is None. + :param body: Replication extension model. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -395,14 +466,12 @@ def begin_create( resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -411,19 +480,11 @@ def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Default value is None. - :type body: IO + :param body: Replication extension model. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -437,12 +498,10 @@ def begin_create( resource_group_name: str, vault_name: str, replication_extension_name: str, - body: Optional[Union[_models.ReplicationExtensionModel, IO]] = None, + body: Union[_models.ReplicationExtensionModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ReplicationExtensionModel]: - """Puts the replication extension. - - Creates the replication extension in the given vault. + """Creates the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -451,20 +510,10 @@ def begin_create( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :param body: Replication extension model. Is either a ReplicationExtensionModel type or a IO - type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Replication extension model. Is either a ReplicationExtensionModel type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel or + IO[bytes] :return: An instance of LROPoller that returns either ReplicationExtensionModel or the result of cls(response) :rtype: @@ -493,39 +542,38 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response) + deserialized = self._deserialize("ReplicationExtensionModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ReplicationExtensionModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return LROPoller[_models.ReplicationExtensionModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,54 +585,53 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( self, resource_group_name: str, vault_name: str, replication_extension_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the replication extension. - - Deletes the replication extension in the given vault. + """Deletes the replication extension in the given vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -593,14 +640,6 @@ def begin_delete( :type vault_name: str :param replication_extension_name: The replication extension name. Required. :type replication_extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -614,7 +653,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, replication_extension_name=replication_extension_name, @@ -624,11 +663,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -639,110 +679,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" - } - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> Iterable["_models.ReplicationExtensionModel"]: - """Lists the replication extensions. - - Gets the list of replication extensions in the given vault. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationExtensionModel or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.ReplicationExtensionModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ReplicationExtensionModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationExtensionModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operations.py index ae142ce05e4c..4557ed942e55 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operations.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_vault_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,34 @@ # Code generated by Microsoft (R) AutoRest 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 -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request +from .._configuration import RecoveryServicesDataReplicationMgmtClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,24 +42,19 @@ _SERIALIZER.client_side_validation = False -def build_get_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_by_subscription_request(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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationVaults" + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -70,53 +68,54 @@ def build_get_request(resource_group_name: str, vault_name: str, subscription_id return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_request( + resource_group_name: str, subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_request(resource_group_name: str, vault_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", "2021-02-16-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -131,25 +130,24 @@ def build_update_request(resource_group_name: str, vault_name: str, subscription _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_create_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -164,77 +162,76 @@ def build_delete_request(resource_group_name: str, vault_name: str, subscription _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: +def build_update_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationVaults" - ) # pylint: disable=line-too-long + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: +def build_delete_request(resource_group_name: str, vault_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", "2021-02-16-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults", - ) # pylint: disable=line-too-long + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}", + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class VaultOperations: @@ -251,28 +248,189 @@ class VaultOperations: def __init__(self, *args, **kwargs): 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: RecoveryServicesDataReplicationMgmtClientConfiguration = ( + 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, vault_name: str, **kwargs: Any) -> _models.VaultModel: - """Gets the vault. + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.VaultModel"]: + """Gets the list of vaults in the given subscription. + + :return: An iterator like instance of either VaultModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VaultModelListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VaultModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.VaultModel"]: + """Gets the list of vaults in the given subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param continuation_token_parameter: Continuation token from the previous call. Default value + is None. + :type continuation_token_parameter: str + :return: An iterator like instance of either VaultModel or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VaultModelListResult] = 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: - Gets the details of the vault. + _request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + 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), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VaultModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.VaultModel: + """Gets the details of the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VaultModel or the result of cls(response) :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,21 +444,19 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VaultModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -310,25 +466,17 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore def _create_initial( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModel, IO]] = None, - **kwargs: Any - ) -> _models.VaultModel: - error_map = { + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModel, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +489,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VaultModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -349,12 +497,9 @@ def _create_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "VaultModel") - else: - _json = None + _json = self._serialize.body(body, "VaultModel") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -362,72 +507,64 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VaultModel", pipeline_response) - + response_headers = {} if response.status_code == 201: - deserialized = self._deserialize("VaultModel", pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } - @overload def begin_create( self, resource_group_name: str, vault_name: str, - body: Optional[_models.VaultModel] = None, + body: _models.VaultModel, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. + :param body: Vault properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -439,33 +576,23 @@ def begin_create( self, resource_group_name: str, vault_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. - :type body: IO + :param body: Vault properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -474,34 +601,17 @@ def begin_create( @distributed_trace def begin_create( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModel, IO]] = None, - **kwargs: Any + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Puts the vault. - - Creates the vault. + """Creates the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Is either a VaultModel type or a IO type. Default value is None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Vault properties. Is either a VaultModel type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModel or IO[bytes] :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -528,43 +638,38 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VaultModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return LROPoller[_models.VaultModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModelUpdate, IO]] = None, - **kwargs: Any - ) -> Optional[_models.VaultModel]: - error_map = { + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModelUpdate, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,7 +682,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VaultModel]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -585,12 +690,9 @@ def _update_initial( if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = self._serialize.body(body, "VaultModelUpdate") - else: - _json = None + _json = self._serialize.body(body, "VaultModelUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -598,77 +700,62 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VaultModel", pipeline_response) - if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vault_name: str, - body: Optional[_models.VaultModelUpdate] = None, + body: _models.VaultModelUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. + :param body: Vault properties. Required. :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -680,33 +767,23 @@ def begin_update( self, resource_group_name: str, vault_name: str, - body: Optional[IO] = None, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Default value is None. - :type body: IO + :param body: Vault properties. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -715,35 +792,17 @@ def begin_update( @distributed_trace def begin_update( - self, - resource_group_name: str, - vault_name: str, - body: Optional[Union[_models.VaultModelUpdate, IO]] = None, - **kwargs: Any + self, resource_group_name: str, vault_name: str, body: Union[_models.VaultModelUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VaultModel]: - """Updates the vault. - - Performs update on the vault. + """Performs update on the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :param body: Vault properties. Is either a VaultModelUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Vault properties. Is either a VaultModelUpdate type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.recoveryservicesdatareplication.models.VaultModelUpdate or IO[bytes] :return: An instance of LROPoller that returns either VaultModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] @@ -770,12 +829,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VaultModel", pipeline_response) + deserialized = self._deserialize("VaultModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -787,22 +847,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VaultModel].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return LROPoller[_models.VaultModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -814,65 +870,56 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the vault. - - Removes the vault. + """Removes the vault. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param vault_name: The vault name. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -886,7 +933,7 @@ def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -895,11 +942,12 @@ def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -910,202 +958,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" - } - - @distributed_trace - def list_by_subscription( - self, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VaultModel"]: - """Lists the vaults. - - Gets the list of vaults in the given subscription. - - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VaultModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VaultModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_by_subscription_request( - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VaultModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationVaults" - } - - @distributed_trace - def list( - self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VaultModel"]: - """Lists the vaults. - - Gets the list of vaults in the given subscription and resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param continuation_token_parameter: Continuation token from the previous call. Default value - is None. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VaultModel or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.recoveryservicesdatareplication.models.VaultModel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.VaultModelCollection] = kwargs.pop("cls", None) - - error_map = { - 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - 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), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VaultModelCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operation_status_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operation_status_operations.py deleted file mode 100644 index 0a45461c96cf..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/azure/mgmt/recoveryservicesdatareplication/operations/_workflow_operation_status_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import RecoveryServicesDataReplicationMgmtClientMixinABC, _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, vault_name: str, job_name: str, operation_id: 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", "2021-02-16-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}/operations/{operationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "jobName": _SERIALIZER.url("job_name", job_name, "str", pattern=r"^[a-zA-Z0-9]*$"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _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) - - -class WorkflowOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.recoveryservicesdatareplication.RecoveryServicesDataReplicationMgmtClient`'s - :attr:`workflow_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - 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") - - @distributed_trace - def get( - self, resource_group_name: str, vault_name: str, job_name: str, operation_id: str, **kwargs: Any - ) -> _models.OperationStatus: - """Gets the job (workflow) operation status. - - Tracks the results of an asynchronous operation on the job. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vault_name: The vault name. Required. - :type vault_name: str - :param job_name: The job (workflow) name. Required. - :type job_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.recoveryservicesdatareplication.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - job_name=job_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}/operations/{operationId}" - } diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability_post.py similarity index 85% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability_post.py index 57cbf847afa4..a06f60cf99d4 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/check_name_availability_post.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python check_name_availability.py + python check_name_availability_post.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, @@ -29,12 +31,12 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.check_name_availability( + response = client.check_name_availability.post( location="trfqtbtmusswpibw", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/CheckNameAvailability.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/CheckNameAvailability_Post.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight_post.py similarity index 80% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_operation_status_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight_post.py index 52a6ff825941..c107bd63e861 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_operation_status_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight_post.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python vault_operation_status_get.py + python deployment_preflight_post.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, @@ -29,14 +31,13 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.vault_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", - vault_name="4", - operation_id="vsdvwe", + response = client.deployment_preflight.post( + resource_group_name="rgswagger_2024-09-01", + deployment_id="lnfcwsmlowbwkndkztzvaj", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/VaultOperationStatus_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/DeploymentPreflight_Post.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_operation_status_get.py deleted file mode 100644 index e8aff76911d8..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_operation_status_get.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-recoveryservicesdatareplication -# USAGE - python dra_operation_status_get.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 = RecoveryServicesDataReplicationMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", - ) - - response = client.dra_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", - fabric_name="wPR", - fabric_agent_name="M", - operation_id="dadsqwcq", - ) - print(response) - - -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/DraOperationStatus_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_create.py index 2feed4b7a2ef..c59f0264f03d 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,13 +32,20 @@ def main(): ) response = client.email_configuration.create( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", vault_name="4", email_configuration_name="0", + body={ + "properties": { + "customEmailAddresses": ["ketvbducyailcny"], + "locale": "vpnjxjvdqtebnucyxiyrjiko", + "sendToOwners": True, + } + }, ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/EmailConfiguration_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_get.py index 3c3eb9838a44..14c112b6423d 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,13 +32,13 @@ def main(): ) response = client.email_configuration.get( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", vault_name="4", email_configuration_name="0", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/EmailConfiguration_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_list.py index 294a581f44d2..dbedbd301649 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/email_configuration_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,13 +32,13 @@ def main(): ) response = client.email_configuration.list( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", vault_name="4", ) for item in response: print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/EmailConfiguration_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_get.py index acda6d5e70f3..80bbe91afdf0 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,13 +32,13 @@ def main(): ) response = client.event.get( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", vault_name="4", event_name="231CIG", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Event_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_list.py index a81b076a6f85..a7b648bffff6 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/event_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,13 +32,13 @@ def main(): ) response = client.event.list( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", vault_name="4", ) for item in response: print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Event_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_create.py similarity index 54% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_create.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_create.py index 9511f975b62c..8d2aefe76dda 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python dra_create.py + python fabric_agent_create.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, @@ -29,14 +31,35 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.dra.begin_create( - resource_group_name="rgrecoveryservicesdatareplication", + response = client.fabric_agent.begin_create( + resource_group_name="rgswagger_2024-09-01", fabric_name="wPR", fabric_agent_name="M", + body={ + "properties": { + "authenticationIdentity": { + "aadAuthority": "bubwwbowfhdmujrt", + "applicationId": "cwktzrwajuvfyyymfstpey", + "audience": "dkjobanyqgzenivyxhvavottpc", + "objectId": "khsiaqfbpuhp", + "tenantId": "joclkkdovixwapephhxaqtefubhhmq", + }, + "customProperties": {"instanceType": "FabricAgentModelCustomProperties"}, + "machineId": "envzcoijbqhtrpncbjbhk", + "machineName": "y", + "resourceAccessIdentity": { + "aadAuthority": "bubwwbowfhdmujrt", + "applicationId": "cwktzrwajuvfyyymfstpey", + "audience": "dkjobanyqgzenivyxhvavottpc", + "objectId": "khsiaqfbpuhp", + "tenantId": "joclkkdovixwapephhxaqtefubhhmq", + }, + } + }, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/FabricAgent_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_delete.py similarity index 84% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_delete.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_delete.py index dfe21fd58c44..8a27d6b1f8a6 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python dra_delete.py + python fabric_agent_delete.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, @@ -29,13 +31,13 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - client.dra.begin_delete( - resource_group_name="rgrecoveryservicesdatareplication", + client.fabric_agent.begin_delete( + resource_group_name="rgswagger_2024-09-01", fabric_name="wPR", fabric_agent_name="M", ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/FabricAgent_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_get.py similarity index 87% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_get.py index b1b345a926a0..e5630adc9afc 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python dra_get.py + python fabric_agent_get.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, @@ -29,7 +31,7 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.dra.get( + response = client.fabric_agent.get( resource_group_name="rgrecoveryservicesdatareplication", fabric_name="wPR", fabric_agent_name="M", @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/FabricAgent_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_list.py similarity index 84% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_list.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_list.py index b47a2f3cf7fd..f2dabb4c4149 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/dra_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_agent_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python dra_list.py + python fabric_agent_list.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, @@ -29,14 +31,14 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.dra.list( - resource_group_name="rgrecoveryservicesdatareplication", + response = client.fabric_agent.list( + resource_group_name="rgswagger_2024-09-01", fabric_name="wPR", ) for item in response: print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/FabricAgent_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_create.py index b5ca6274034b..1fee45beb80d 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,12 +32,16 @@ def main(): ) response = client.fabric.begin_create( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", fabric_name="wPR", + body={ + "location": "tqygutlpob", + "properties": {"customProperties": {"instanceType": "FabricModelCustomProperties"}}, + }, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_delete.py index a2f71f220375..f4d038ba4cef 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -35,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_get.py index 594ace3d4d75..515566ee25f7 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list.py index e4328b94ba6d..ba6302837c2f 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,12 +32,12 @@ def main(): ) response = client.fabric.list( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", ) for item in response: print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list_by_subscription.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list_by_subscription.py index 5f95116e3b9c..0d0b0785fb96 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list_by_subscription.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_ListBySubscription.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_update.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_update.py index 1972dbe36a93..9de04e7f3fad 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_update.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -30,12 +32,13 @@ def main(): ) response = client.fabric.begin_update( - resource_group_name="rgrecoveryservicesdatareplication", + resource_group_name="rgswagger_2024-09-01", fabric_name="wPR", + body={"properties": {"customProperties": {"instanceType": "FabricModelCustomProperties"}}, "tags": {}}, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Update.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Fabric_Update.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_get.py similarity index 88% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_get.py index 52c54c214b84..fab7581f7c84 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python workflow_get.py + python job_get.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, @@ -29,7 +31,7 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.workflow.get( + response = client.job.get( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", job_name="ZGH4y", @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Job_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_list.py similarity index 88% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_list.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_list.py index 709b78e5ba0c..4b467854e6ee 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/job_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python workflow_list.py + python job_list.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, @@ -29,7 +31,7 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.workflow.list( + response = client.job.list( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", ) @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Job_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_operations_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/location_based_operation_results_get.py similarity index 78% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_operations_status_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/location_based_operation_results_get.py index ebb69cac3f34..c29d0c6a8656 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/fabric_operations_status_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/location_based_operation_results_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python fabric_operations_status_get.py + python location_based_operation_results_get.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, @@ -29,14 +31,14 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.fabric_operations_status.get( - resource_group_name="rgrecoveryservicesdatareplication", - fabric_name="wPR", - operation_id="dvfwerv", + response = client.location_based_operation_results.get( + resource_group_name="rgswagger_2024-09-01", + location="Central US EUAP", + operation_id="lghle", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/FabricOperationsStatus_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/LocationBasedOperationResults_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operation_results_get.py similarity index 81% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operation_results_get.py index 158e1f0a3665..cc7aecb1bc84 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/deployment_preflight.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operation_results_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python deployment_preflight.py + python operation_results_get.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, @@ -29,13 +31,13 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.deployment_preflight( - resource_group_name="rgrecoveryservicesdatareplication", - deployment_id="kjoiahxljomjcmvabaobumg", + response = client.operation_results.get( + resource_group_name="rgswagger_2024-09-01", + operation_id="lghle", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/DeploymentPreflight.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/OperationResults_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operations_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operations_list.py index 61dd8e0e5bf6..c3d0a5b98b5c 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operations_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/operations_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Operations_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_create.py index 23c3dc138d4a..9e65f7afed60 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -33,10 +35,11 @@ def main(): resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", policy_name="fafqwc", + body={"properties": {"customProperties": {"instanceType": "PolicyModelCustomProperties"}}}, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Policy_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_delete.py index a702d9bbb09c..4f4b8d609aa0 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Policy_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_get.py index acf0b670ad0b..518ac42384b5 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Policy_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_list.py index 868a0a7a537a..aae1f5a594a0 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Policy_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_delete.py new file mode 100644 index 000000000000..f5db9f7c8096 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_delete.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_delete.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + client.private_endpoint_connections.begin_delete( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_name="sdwqtfhigjirrzhpbmqtzgs", + ).result() + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnection_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_get.py similarity index 79% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_operation_status_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_get.py index 2a700a39aef0..5b8f7a3f1274 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_operation_status_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python protected_item_operation_status_get.py + python private_endpoint_connection_get.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, @@ -29,15 +31,14 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.protected_item_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", + response = client.private_endpoint_connections.get( + resource_group_name="rgswagger_2024-09-01", vault_name="4", - protected_item_name="d", - operation_id="wdqacsc", + private_endpoint_connection_name="vbkm", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItemOperationStatus_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnection_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_list.py new file mode 100644 index 000000000000..c30311f3d76e --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_list.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_list.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connections.list( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnection_List.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_create.py new file mode 100644 index 000000000000..670ee12dd5f2 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_create.py @@ -0,0 +1,96 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_proxy_create.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connection_proxies.create( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_proxy_name="d", + body={ + "etag": "hruibxrezstxroxrxweh", + "properties": { + "remotePrivateEndpoint": { + "connectionDetails": [ + { + "groupId": "pjrlygpadir", + "id": "lenqkogzkes", + "linkIdentifier": "ravfufhkdowufd", + "memberName": "ybuysjrlfupewxe", + "privateIpAddress": "cyiacdzzyqmxjpijjbwgasegehtqe", + } + ], + "id": "yipalno", + "manualPrivateLinkServiceConnections": [ + { + "groupIds": ["hvejynjktikteipnioyeja"], + "name": "jqwntlzfsksl", + "requestMessage": "bukgzpkvcvfbmcdmpcbiigbvugicqa", + } + ], + "privateLinkServiceConnections": [ + { + "groupIds": ["hvejynjktikteipnioyeja"], + "name": "jqwntlzfsksl", + "requestMessage": "bukgzpkvcvfbmcdmpcbiigbvugicqa", + } + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["vedcg"], + "groupId": "per", + "internalFqdn": "maqavwhxwzzhbzjbryyquvitmup", + "memberName": "ybptuypgdqoxkuwqx", + "privateLinkServiceArmRegion": "rerkqqxinteevmlbrdkktaqhcch", + "redirectMapId": "pezncxcq", + } + ], + "id": "nzqxevuyqeedrqnkbnlcyrrrbzxvl", + "remotePrivateEndpointConnection": {"id": "ocunsgawjsqohkrcyxiv"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "afwbq", + "description": "y", + "status": "Approved", + }, + } + ], + } + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnectionProxy_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_delete.py new file mode 100644 index 000000000000..f9c735aa1489 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_delete.py @@ -0,0 +1,43 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_proxy_delete.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + client.private_endpoint_connection_proxies.begin_delete( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_proxy_name="d", + ).result() + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnectionProxy_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_get.py new file mode 100644 index 000000000000..2b1882d123b2 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_get.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_proxy_get.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connection_proxies.get( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_proxy_name="d", + ) + print(response) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnectionProxy_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_list.py new file mode 100644 index 000000000000..056c6a4a5bb6 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_list.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_proxy_list.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connection_proxies.list( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnectionProxy_List.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_validate.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_validate.py new file mode 100644 index 000000000000..c61cb6b26bda --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_proxy_validate.py @@ -0,0 +1,96 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_proxy_validate.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connection_proxies.validate( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_proxy_name="d", + body={ + "etag": "hruibxrezstxroxrxweh", + "properties": { + "remotePrivateEndpoint": { + "connectionDetails": [ + { + "groupId": "pjrlygpadir", + "id": "lenqkogzkes", + "linkIdentifier": "ravfufhkdowufd", + "memberName": "ybuysjrlfupewxe", + "privateIpAddress": "cyiacdzzyqmxjpijjbwgasegehtqe", + } + ], + "id": "yipalno", + "manualPrivateLinkServiceConnections": [ + { + "groupIds": ["hvejynjktikteipnioyeja"], + "name": "jqwntlzfsksl", + "requestMessage": "bukgzpkvcvfbmcdmpcbiigbvugicqa", + } + ], + "privateLinkServiceConnections": [ + { + "groupIds": ["hvejynjktikteipnioyeja"], + "name": "jqwntlzfsksl", + "requestMessage": "bukgzpkvcvfbmcdmpcbiigbvugicqa", + } + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["vedcg"], + "groupId": "per", + "internalFqdn": "maqavwhxwzzhbzjbryyquvitmup", + "memberName": "ybptuypgdqoxkuwqx", + "privateLinkServiceArmRegion": "rerkqqxinteevmlbrdkktaqhcch", + "redirectMapId": "pezncxcq", + } + ], + "id": "nzqxevuyqeedrqnkbnlcyrrrbzxvl", + "remotePrivateEndpointConnection": {"id": "ocunsgawjsqohkrcyxiv"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "afwbq", + "description": "y", + "status": "Approved", + }, + } + ], + } + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnectionProxy_Validate.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_update.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_update.py new file mode 100644 index 000000000000..f8c0d64ed1e2 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_endpoint_connection_update.py @@ -0,0 +1,54 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_endpoint_connection_update.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_endpoint_connections.update( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + private_endpoint_connection_name="jitf", + body={ + "properties": { + "privateEndpoint": {"id": "cwcdqoynostmqwdwy"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "afwbq", + "description": "y", + "status": "Approved", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateEndpointConnection_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_get.py similarity index 81% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_operation_status_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_get.py index 438d64f5dac1..8871d939a050 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/policy_operation_status_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python policy_operation_status_get.py + python private_link_resource_get.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, @@ -29,15 +31,14 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.policy_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", + response = client.private_link_resources.get( + resource_group_name="rgswagger_2024-09-01", vault_name="4", - policy_name="xczxcwec", - operation_id="wdqfsdxv", + private_link_resource_name="d", ) print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/PolicyOperationStatus_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateLinkResource_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_list.py new file mode 100644 index 000000000000..94882300738a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/private_link_resource_list.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-recoveryservicesdatareplication +# USAGE + python private_link_resource_list.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 = RecoveryServicesDataReplicationMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", + ) + + response = client.private_link_resources.list( + resource_group_name="rgswagger_2024-09-01", + vault_name="4", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/PrivateLinkResource_List.json +if __name__ == "__main__": + main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_create.py index d8f37186a52f..138bc8a22ca5 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -33,10 +35,17 @@ def main(): resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", protected_item_name="d", + body={ + "properties": { + "customProperties": {"instanceType": "ProtectedItemModelCustomProperties"}, + "policyName": "tjoeiynplt", + "replicationExtensionName": "jwxdo", + } + }, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_delete.py index a403f3213586..96b342fb0732 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_get.py index 7c8694a6e78c..81608d708977 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_list.py index e1f0810b5127..a77f6597efb2 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_planned_failover.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_planned_failover.py index fc860a30739c..5f4df5564088 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_planned_failover.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_planned_failover.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -33,10 +35,11 @@ def main(): resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", protected_item_name="d", + body={"properties": {"customProperties": {"instanceType": "PlannedFailoverModelCustomProperties"}}}, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_PlannedFailover.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_PlannedFailover.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_update.py similarity index 76% rename from sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_operation_status_get.py rename to sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_update.py index d1af0bd506ba..d9ff8d9d63ce 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_operation_status_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/protected_item_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-recoveryservicesdatareplication # USAGE - python replication_extension_operation_status_get.py + python protected_item_update.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, @@ -29,15 +31,15 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.replication_extension_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", + response = client.protected_item.begin_update( + resource_group_name="rgswagger_2024-09-01", vault_name="4", - replication_extension_name="g16yjJ", - operation_id="wqdqc", - ) + protected_item_name="d", + body={"properties": {"customProperties": {"instanceType": "ProtectedItemModelCustomPropertiesUpdate"}}}, + ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtensionOperationStatus_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ProtectedItem_Update.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_get.py index 5b42e46b6c30..44feba9e41a0 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -29,7 +31,7 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.recovery_points.get( + response = client.recovery_point.get( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", protected_item_name="d", @@ -38,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/RecoveryPoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_list.py index e22874bc3921..cedc17572f85 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/recovery_points_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -29,7 +31,7 @@ def main(): subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", ) - response = client.recovery_points.list( + response = client.recovery_point.list( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", protected_item_name="d", @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/RecoveryPoints_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_create.py index a9216adb2664..28147cc0183a 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -33,10 +35,11 @@ def main(): resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", replication_extension_name="g16yjJ", + body={"properties": {"customProperties": {"instanceType": "ReplicationExtensionModelCustomProperties"}}}, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ReplicationExtension_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_delete.py index f647c3143342..8ae091986d65 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ReplicationExtension_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_get.py index 2957df01dfc1..99385f0d7ef7 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ReplicationExtension_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_list.py index 8023e8e16411..c06c50190e43 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/replication_extension_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/ReplicationExtension_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_create.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_create.py index 32ca942e0c1a..3478032fef74 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_create.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -32,10 +34,15 @@ def main(): response = client.vault.begin_create( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", + body={ + "location": "eck", + "properties": {"vaultType": "DisasterRecovery"}, + "tags": {"key5359": "ljfilxolxzuxrauopwtyxghrp"}, + }, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Create.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_Create.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_delete.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_delete.py index 3bacb61d0cd2..92600698895a 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_delete.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -35,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Delete.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_Delete.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_get.py index 14e55ae22d67..c2c6504847d8 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_get.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_Get.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list.py index 31754dee6d49..3ecab03a4355 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_List.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_List.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list_by_subscription.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list_by_subscription.py index 6e2908ed31a8..56c78ba91cc6 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list_by_subscription.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_ListBySubscription.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_update.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_update.py index 750f3a26bee2..aab52d57eca8 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_update.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/vault_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient """ @@ -32,10 +34,11 @@ def main(): response = client.vault.begin_update( resource_group_name="rgrecoveryservicesdatareplication", vault_name="4", + body={"properties": {"vaultType": "DisasterRecovery"}, "tags": {"key8872": "pvtc"}}, ).result() print(response) -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Update.json +# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/examples/Vault_Update.json if __name__ == "__main__": main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_operation_status_get.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_operation_status_get.py deleted file mode 100644 index ea534fb2486a..000000000000 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_samples/workflow_operation_status_get.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-recoveryservicesdatareplication -# USAGE - python workflow_operation_status_get.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 = RecoveryServicesDataReplicationMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="930CEC23-4430-4513-B855-DBA237E2F3BF", - ) - - response = client.workflow_operation_status.get( - resource_group_name="rgrecoveryservicesdatareplication", - vault_name="4", - job_name="ZGH4y", - operation_id="wdqcxc", - ) - print(response) - - -# x-ms-original-file: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/WorkflowOperationStatus_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/conftest.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/conftest.py new file mode 100644 index 000000000000..34fbd97700f3 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/conftest.py @@ -0,0 +1,51 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + recoveryservicesdatareplicationmgmt_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + recoveryservicesdatareplicationmgmt_tenant_id = os.environ.get( + "AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + recoveryservicesdatareplicationmgmt_client_id = os.environ.get( + "AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + recoveryservicesdatareplicationmgmt_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=recoveryservicesdatareplicationmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=recoveryservicesdatareplicationmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=recoveryservicesdatareplicationmgmt_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=recoveryservicesdatareplicationmgmt_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations.py new file mode 100644 index 000000000000..79396297c9c5 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations.py @@ -0,0 +1,30 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtCheckNameAvailabilityOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability_post(self, resource_group): + response = self.client.check_name_availability.post( + location="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations_async.py new file mode 100644 index 000000000000..b97023f0bd59 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_check_name_availability_operations_async.py @@ -0,0 +1,31 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtCheckNameAvailabilityOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability_post(self, resource_group): + response = await self.client.check_name_availability.post( + location="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations.py new file mode 100644 index 000000000000..4b4cc1993979 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations.py @@ -0,0 +1,31 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtDeploymentPreflightOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deployment_preflight_post(self, resource_group): + response = self.client.deployment_preflight.post( + resource_group_name=resource_group.name, + deployment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations_async.py new file mode 100644 index 000000000000..2ad0dd9dfcf9 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_deployment_preflight_operations_async.py @@ -0,0 +1,32 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtDeploymentPreflightOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deployment_preflight_post(self, resource_group): + response = await self.client.deployment_preflight.post( + resource_group_name=resource_group.name, + deployment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations.py new file mode 100644 index 000000000000..d320e6229d22 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations.py @@ -0,0 +1,76 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtEmailConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_email_configuration_list(self, resource_group): + response = self.client.email_configuration.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_email_configuration_get(self, resource_group): + response = self.client.email_configuration.get( + resource_group_name=resource_group.name, + vault_name="str", + email_configuration_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_email_configuration_create(self, resource_group): + response = self.client.email_configuration.create( + resource_group_name=resource_group.name, + vault_name="str", + email_configuration_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "sendToOwners": bool, + "customEmailAddresses": ["str"], + "locale": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations_async.py new file mode 100644 index 000000000000..a417790515bb --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_email_configuration_operations_async.py @@ -0,0 +1,77 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtEmailConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_email_configuration_list(self, resource_group): + response = self.client.email_configuration.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_email_configuration_get(self, resource_group): + response = await self.client.email_configuration.get( + resource_group_name=resource_group.name, + vault_name="str", + email_configuration_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_email_configuration_create(self, resource_group): + response = await self.client.email_configuration.create( + resource_group_name=resource_group.name, + vault_name="str", + email_configuration_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "sendToOwners": bool, + "customEmailAddresses": ["str"], + "locale": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations.py new file mode 100644 index 000000000000..7e6411a926b8 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtEventOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_event_list(self, resource_group): + response = self.client.event.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_event_get(self, resource_group): + response = self.client.event.get( + resource_group_name=resource_group.name, + vault_name="str", + event_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations_async.py new file mode 100644 index 000000000000..90f50cd3497a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_event_operations_async.py @@ -0,0 +1,45 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtEventOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_event_list(self, resource_group): + response = self.client.event.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_event_get(self, resource_group): + response = await self.client.event.get( + resource_group_name=resource_group.name, + vault_name="str", + event_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations.py new file mode 100644 index 000000000000..4d37ccbdf7b9 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations.py @@ -0,0 +1,139 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtFabricAgentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_agent_list(self, resource_group): + response = self.client.fabric_agent.list( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_agent_get(self, resource_group): + response = self.client.fabric_agent.get( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_agent_begin_create(self, resource_group): + response = self.client.fabric_agent.begin_create( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "authenticationIdentity": { + "aadAuthority": "str", + "applicationId": "str", + "audience": "str", + "objectId": "str", + "tenantId": "str", + }, + "customProperties": "fabric_agent_model_custom_properties", + "machineId": "str", + "machineName": "str", + "resourceAccessIdentity": { + "aadAuthority": "str", + "applicationId": "str", + "audience": "str", + "objectId": "str", + "tenantId": "str", + }, + "correlationId": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "isResponsive": bool, + "lastHeartbeat": "2020-02-20 00:00:00", + "provisioningState": "str", + "versionNumber": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_agent_begin_delete(self, resource_group): + response = self.client.fabric_agent.begin_delete( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations_async.py new file mode 100644 index 000000000000..72aa427dac9a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_agent_operations_async.py @@ -0,0 +1,144 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtFabricAgentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_agent_list(self, resource_group): + response = self.client.fabric_agent.list( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ) + 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_agent_get(self, resource_group): + response = await self.client.fabric_agent.get( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_agent_begin_create(self, resource_group): + response = await ( + await self.client.fabric_agent.begin_create( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "authenticationIdentity": { + "aadAuthority": "str", + "applicationId": "str", + "audience": "str", + "objectId": "str", + "tenantId": "str", + }, + "customProperties": "fabric_agent_model_custom_properties", + "machineId": "str", + "machineName": "str", + "resourceAccessIdentity": { + "aadAuthority": "str", + "applicationId": "str", + "audience": "str", + "objectId": "str", + "tenantId": "str", + }, + "correlationId": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "isResponsive": bool, + "lastHeartbeat": "2020-02-20 00:00:00", + "provisioningState": "str", + "versionNumber": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_agent_begin_delete(self, resource_group): + response = await ( + await self.client.fabric_agent.begin_delete( + resource_group_name=resource_group.name, + fabric_name="str", + fabric_agent_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations.py new file mode 100644 index 000000000000..4017f7bb0505 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations.py @@ -0,0 +1,195 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtFabricOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_list_by_subscription(self, resource_group): + response = self.client.fabric.list_by_subscription( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_list(self, resource_group): + response = self.client.fabric.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_get(self, resource_group): + response = self.client.fabric.get( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_begin_create(self, resource_group): + response = self.client.fabric.begin_create( + resource_group_name=resource_group.name, + fabric_name="str", + body={ + "location": "str", + "id": "str", + "name": "str", + "properties": { + "customProperties": "fabric_model_custom_properties", + "health": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "provisioningState": "str", + "serviceEndpoint": "str", + "serviceResourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_begin_update(self, resource_group): + response = self.client.fabric.begin_update( + resource_group_name=resource_group.name, + fabric_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "fabric_model_custom_properties", + "health": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "provisioningState": "str", + "serviceEndpoint": "str", + "serviceResourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_fabric_begin_delete(self, resource_group): + response = self.client.fabric.begin_delete( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations_async.py new file mode 100644 index 000000000000..3eadcddbcf79 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_fabric_operations_async.py @@ -0,0 +1,202 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtFabricOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_list_by_subscription(self, resource_group): + response = self.client.fabric.list_by_subscription( + api_version="2024-09-01", + ) + 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_list(self, resource_group): + response = self.client.fabric.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + 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_get(self, resource_group): + response = await self.client.fabric.get( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_begin_create(self, resource_group): + response = await ( + await self.client.fabric.begin_create( + resource_group_name=resource_group.name, + fabric_name="str", + body={ + "location": "str", + "id": "str", + "name": "str", + "properties": { + "customProperties": "fabric_model_custom_properties", + "health": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "provisioningState": "str", + "serviceEndpoint": "str", + "serviceResourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_begin_update(self, resource_group): + response = await ( + await self.client.fabric.begin_update( + resource_group_name=resource_group.name, + fabric_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "fabric_model_custom_properties", + "health": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "provisioningState": "str", + "serviceEndpoint": "str", + "serviceResourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_fabric_begin_delete(self, resource_group): + response = await ( + await self.client.fabric.begin_delete( + resource_group_name=resource_group.name, + fabric_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations.py new file mode 100644 index 000000000000..8bc5790fc7ec --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_job_list(self, resource_group): + response = self.client.job.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_job_get(self, resource_group): + response = self.client.job.get( + resource_group_name=resource_group.name, + vault_name="str", + job_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations_async.py new file mode 100644 index 000000000000..694d0fdfb316 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_job_operations_async.py @@ -0,0 +1,45 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_job_list(self, resource_group): + response = self.client.job.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_job_get(self, resource_group): + response = await self.client.job.get( + resource_group_name=resource_group.name, + vault_name="str", + job_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations.py new file mode 100644 index 000000000000..d246d4cdeaf6 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations.py @@ -0,0 +1,32 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtLocationBasedOperationResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_location_based_operation_results_get(self, resource_group): + response = self.client.location_based_operation_results.get( + resource_group_name=resource_group.name, + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations_async.py new file mode 100644 index 000000000000..93f577b235ce --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_location_based_operation_results_operations_async.py @@ -0,0 +1,33 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtLocationBasedOperationResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_location_based_operation_results_get(self, resource_group): + response = await self.client.location_based_operation_results.get( + resource_group_name=resource_group.name, + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations.py new file mode 100644 index 000000000000..c7df05675fce --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations.py @@ -0,0 +1,31 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtOperationResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operation_results_get(self, resource_group): + response = self.client.operation_results.get( + resource_group_name=resource_group.name, + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations_async.py new file mode 100644 index 000000000000..462321c5f6fc --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operation_results_operations_async.py @@ -0,0 +1,32 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtOperationResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operation_results_get(self, resource_group): + response = await self.client.operation_results.get( + resource_group_name=resource_group.name, + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations.py new file mode 100644 index 000000000000..1fc46e65e746 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations.py @@ -0,0 +1,29 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations_async.py new file mode 100644 index 000000000000..b452d137e720 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations.py new file mode 100644 index 000000000000..880e5e62d71a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations.py @@ -0,0 +1,84 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_list(self, resource_group): + response = self.client.policy.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_get(self, resource_group): + response = self.client.policy.get( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_begin_create(self, resource_group): + response = self.client.policy.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + body={ + "id": "str", + "name": "str", + "properties": {"customProperties": "policy_model_custom_properties", "provisioningState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_begin_delete(self, resource_group): + response = self.client.policy.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations_async.py new file mode 100644 index 000000000000..69f71c305ad3 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_policy_operations_async.py @@ -0,0 +1,89 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_list(self, resource_group): + response = self.client.policy.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_policy_get(self, resource_group): + response = await self.client.policy.get( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_begin_create(self, resource_group): + response = await ( + await self.client.policy.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + body={ + "id": "str", + "name": "str", + "properties": {"customProperties": "policy_model_custom_properties", "provisioningState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_begin_delete(self, resource_group): + response = await ( + await self.client.policy.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + policy_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations.py new file mode 100644 index 000000000000..65143732d75f --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations.py @@ -0,0 +1,195 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateEndpointConnectionProxiesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_proxies_list(self, resource_group): + response = self.client.private_endpoint_connection_proxies.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_proxies_get(self, resource_group): + response = self.client.private_endpoint_connection_proxies.get( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_proxies_create(self, resource_group): + response = self.client.private_endpoint_connection_proxies.create( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + body={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "remotePrivateEndpoint": { + "id": "str", + "connectionDetails": [ + { + "groupId": "str", + "id": "str", + "linkIdentifier": "str", + "memberName": "str", + "privateIpAddress": "str", + } + ], + "manualPrivateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["str"], + "groupId": "str", + "internalFqdn": "str", + "memberName": "str", + "privateLinkServiceArmRegion": "str", + "redirectMapId": "str", + } + ], + "id": "str", + "remotePrivateEndpointConnection": {"id": "str"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_proxies_begin_delete(self, resource_group): + response = self.client.private_endpoint_connection_proxies.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_proxies_validate(self, resource_group): + response = self.client.private_endpoint_connection_proxies.validate( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + body={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "remotePrivateEndpoint": { + "id": "str", + "connectionDetails": [ + { + "groupId": "str", + "id": "str", + "linkIdentifier": "str", + "memberName": "str", + "privateIpAddress": "str", + } + ], + "manualPrivateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["str"], + "groupId": "str", + "internalFqdn": "str", + "memberName": "str", + "privateLinkServiceArmRegion": "str", + "redirectMapId": "str", + } + ], + "id": "str", + "remotePrivateEndpointConnection": {"id": "str"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations_async.py new file mode 100644 index 000000000000..b5509176baa3 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connection_proxies_operations_async.py @@ -0,0 +1,198 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateEndpointConnectionProxiesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connection_proxies_list(self, resource_group): + response = self.client.private_endpoint_connection_proxies.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_private_endpoint_connection_proxies_get(self, resource_group): + response = await self.client.private_endpoint_connection_proxies.get( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connection_proxies_create(self, resource_group): + response = await self.client.private_endpoint_connection_proxies.create( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + body={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "remotePrivateEndpoint": { + "id": "str", + "connectionDetails": [ + { + "groupId": "str", + "id": "str", + "linkIdentifier": "str", + "memberName": "str", + "privateIpAddress": "str", + } + ], + "manualPrivateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["str"], + "groupId": "str", + "internalFqdn": "str", + "memberName": "str", + "privateLinkServiceArmRegion": "str", + "redirectMapId": "str", + } + ], + "id": "str", + "remotePrivateEndpointConnection": {"id": "str"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connection_proxies_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connection_proxies.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connection_proxies_validate(self, resource_group): + response = await self.client.private_endpoint_connection_proxies.validate( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_proxy_name="str", + body={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "remotePrivateEndpoint": { + "id": "str", + "connectionDetails": [ + { + "groupId": "str", + "id": "str", + "linkIdentifier": "str", + "memberName": "str", + "privateIpAddress": "str", + } + ], + "manualPrivateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceConnections": [ + {"groupIds": ["str"], "name": "str", "requestMessage": "str"} + ], + "privateLinkServiceProxies": [ + { + "groupConnectivityInformation": [ + { + "customerVisibleFqdns": ["str"], + "groupId": "str", + "internalFqdn": "str", + "memberName": "str", + "privateLinkServiceArmRegion": "str", + "redirectMapId": "str", + } + ], + "id": "str", + "remotePrivateEndpointConnection": {"id": "str"}, + "remotePrivateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..a9bbcb95a539 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations.py @@ -0,0 +1,92 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_update(self, resource_group): + response = self.client.private_endpoint_connections.update( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..86c2e2e49011 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_endpoint_connections_operations_async.py @@ -0,0 +1,95 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_update(self, resource_group): + response = await self.client.private_endpoint_connections.update( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations.py new file mode 100644 index 000000000000..9c53b20611bd --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + vault_name="str", + private_link_resource_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations_async.py new file mode 100644 index 000000000000..cd55e0b34174 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + vault_name="str", + private_link_resource_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations.py new file mode 100644 index 000000000000..9bc1350985de --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations.py @@ -0,0 +1,218 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtProtectedItemOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_list(self, resource_group): + response = self.client.protected_item.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_get(self, resource_group): + response = self.client.protected_item.get( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_begin_create(self, resource_group): + response = self.client.protected_item.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "protected_item_model_custom_properties", + "policyName": "str", + "replicationExtensionName": "str", + "allowedJobs": ["str"], + "correlationId": "str", + "currentJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "fabricAgentId": "str", + "fabricId": "str", + "fabricObjectId": "str", + "fabricObjectName": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "lastFailedEnableProtectionJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "lastFailedPlannedFailoverJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "lastSuccessfulPlannedFailoverTime": "2020-02-20 00:00:00", + "lastSuccessfulTestFailoverTime": "2020-02-20 00:00:00", + "lastSuccessfulUnplannedFailoverTime": "2020-02-20 00:00:00", + "lastTestFailoverJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "protectionState": "str", + "protectionStateDescription": "str", + "provisioningState": "str", + "replicationHealth": "str", + "resyncRequired": bool, + "resynchronizationState": "str", + "sourceFabricProviderId": "str", + "targetFabricAgentId": "str", + "targetFabricId": "str", + "targetFabricProviderId": "str", + "testFailoverState": "str", + "testFailoverStateDescription": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_begin_update(self, resource_group): + response = self.client.protected_item.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={ + "id": "str", + "name": "str", + "properties": {"customProperties": "protected_item_model_custom_properties_update"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_begin_delete(self, resource_group): + response = self.client.protected_item.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_protected_item_begin_planned_failover(self, resource_group): + response = self.client.protected_item.begin_planned_failover( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={"properties": {"customProperties": "planned_failover_model_custom_properties"}}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations_async.py new file mode 100644 index 000000000000..7e1ce281f8ca --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_protected_item_operations_async.py @@ -0,0 +1,227 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtProtectedItemOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_protected_item_list(self, resource_group): + response = self.client.protected_item.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_protected_item_get(self, resource_group): + response = await self.client.protected_item.get( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_protected_item_begin_create(self, resource_group): + response = await ( + await self.client.protected_item.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "protected_item_model_custom_properties", + "policyName": "str", + "replicationExtensionName": "str", + "allowedJobs": ["str"], + "correlationId": "str", + "currentJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "fabricAgentId": "str", + "fabricId": "str", + "fabricObjectId": "str", + "fabricObjectName": "str", + "healthErrors": [ + { + "affectedResourceCorrelationIds": ["str"], + "affectedResourceType": "str", + "category": "str", + "causes": "str", + "childErrors": [ + { + "category": "str", + "causes": "str", + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "code": "str", + "creationTime": "2020-02-20 00:00:00", + "healthCategory": "str", + "isCustomerResolvable": bool, + "message": "str", + "recommendation": "str", + "severity": "str", + "source": "str", + "summary": "str", + } + ], + "lastFailedEnableProtectionJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "lastFailedPlannedFailoverJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "lastSuccessfulPlannedFailoverTime": "2020-02-20 00:00:00", + "lastSuccessfulTestFailoverTime": "2020-02-20 00:00:00", + "lastSuccessfulUnplannedFailoverTime": "2020-02-20 00:00:00", + "lastTestFailoverJob": { + "displayName": "str", + "endTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "scenarioName": "str", + "startTime": "2020-02-20 00:00:00", + "state": "str", + }, + "protectionState": "str", + "protectionStateDescription": "str", + "provisioningState": "str", + "replicationHealth": "str", + "resyncRequired": bool, + "resynchronizationState": "str", + "sourceFabricProviderId": "str", + "targetFabricAgentId": "str", + "targetFabricId": "str", + "targetFabricProviderId": "str", + "testFailoverState": "str", + "testFailoverStateDescription": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_protected_item_begin_update(self, resource_group): + response = await ( + await self.client.protected_item.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={ + "id": "str", + "name": "str", + "properties": {"customProperties": "protected_item_model_custom_properties_update"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_protected_item_begin_delete(self, resource_group): + response = await ( + await self.client.protected_item.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_protected_item_begin_planned_failover(self, resource_group): + response = await ( + await self.client.protected_item.begin_planned_failover( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + body={"properties": {"customProperties": "planned_failover_model_custom_properties"}}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations.py new file mode 100644 index 000000000000..860c583d53cb --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations.py @@ -0,0 +1,46 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtRecoveryPointOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_recovery_point_list(self, resource_group): + response = self.client.recovery_point.list( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_recovery_point_get(self, resource_group): + response = self.client.recovery_point.get( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + recovery_point_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations_async.py new file mode 100644 index 000000000000..c2a7c658cee7 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_recovery_point_operations_async.py @@ -0,0 +1,47 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtRecoveryPointOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_recovery_point_list(self, resource_group): + response = self.client.recovery_point.list( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + api_version="2024-09-01", + ) + 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_recovery_point_get(self, resource_group): + response = await self.client.recovery_point.get( + resource_group_name=resource_group.name, + vault_name="str", + protected_item_name="str", + recovery_point_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations.py new file mode 100644 index 000000000000..5f22fc6ef827 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations.py @@ -0,0 +1,87 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtReplicationExtensionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_replication_extension_list(self, resource_group): + response = self.client.replication_extension.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_replication_extension_get(self, resource_group): + response = self.client.replication_extension.get( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_replication_extension_begin_create(self, resource_group): + response = self.client.replication_extension.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "replication_extension_model_custom_properties", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_replication_extension_begin_delete(self, resource_group): + response = self.client.replication_extension.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations_async.py new file mode 100644 index 000000000000..053772638b2a --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_replication_extension_operations_async.py @@ -0,0 +1,92 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtReplicationExtensionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_replication_extension_list(self, resource_group): + response = self.client.replication_extension.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + 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_replication_extension_get(self, resource_group): + response = await self.client.replication_extension.get( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_replication_extension_begin_create(self, resource_group): + response = await ( + await self.client.replication_extension.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + body={ + "id": "str", + "name": "str", + "properties": { + "customProperties": "replication_extension_model_custom_properties", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_replication_extension_begin_delete(self, resource_group): + response = await ( + await self.client.replication_extension.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + replication_extension_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations.py new file mode 100644 index 000000000000..11cdba40a2f8 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations.py @@ -0,0 +1,126 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtVaultOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_list_by_subscription(self, resource_group): + response = self.client.vault.list_by_subscription( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_list(self, resource_group): + response = self.client.vault.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_get(self, resource_group): + response = self.client.vault.get( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_begin_create(self, resource_group): + response = self.client.vault.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + body={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": {"provisioningState": "str", "serviceResourceId": "str", "vaultType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_begin_update(self, resource_group): + response = self.client.vault.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + body={ + "id": "str", + "identity": {"type": "str", "principalId": "str", "tenantId": "str"}, + "name": "str", + "properties": {"provisioningState": "str", "serviceResourceId": "str", "vaultType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vault_begin_delete(self, resource_group): + response = self.client.vault.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations_async.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations_async.py new file mode 100644 index 000000000000..bf6585458f91 --- /dev/null +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/generated_tests/test_recovery_services_data_replication_mgmt_vault_operations_async.py @@ -0,0 +1,133 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.recoveryservicesdatareplication.aio import RecoveryServicesDataReplicationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRecoveryServicesDataReplicationMgmtVaultOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RecoveryServicesDataReplicationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vault_list_by_subscription(self, resource_group): + response = self.client.vault.list_by_subscription( + api_version="2024-09-01", + ) + 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_vault_list(self, resource_group): + response = self.client.vault.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + 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_vault_get(self, resource_group): + response = await self.client.vault.get( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vault_begin_create(self, resource_group): + response = await ( + await self.client.vault.begin_create( + resource_group_name=resource_group.name, + vault_name="str", + body={ + "location": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": {"provisioningState": "str", "serviceResourceId": "str", "vaultType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vault_begin_update(self, resource_group): + response = await ( + await self.client.vault.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + body={ + "id": "str", + "identity": {"type": "str", "principalId": "str", "tenantId": "str"}, + "name": "str", + "properties": {"provisioningState": "str", "serviceResourceId": "str", "vaultType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vault_begin_delete(self, resource_group): + response = await ( + await self.client.vault.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/sdk_packaging.toml b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/sdk_packaging.toml index d294588de916..e161e8184bf3 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/sdk_packaging.toml +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/sdk_packaging.toml @@ -3,7 +3,7 @@ package_name = "azure-mgmt-recoveryservicesdatareplication" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Recoveryservicesdatareplication Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/setup.py b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/setup.py index 11a93b4b23d8..2747ff8c9424 100644 --- a/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/setup.py +++ b/sdk/recoveryservicesdatareplication/azure-mgmt-recoveryservicesdatareplication/setup.py @@ -49,15 +49,14 @@ 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 :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "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, @@ -74,10 +73,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.7", + python_requires=">=3.9", )