diff --git a/sdk/keyvault/azure-mgmt-keyvault/CHANGELOG.md b/sdk/keyvault/azure-mgmt-keyvault/CHANGELOG.md index 4a419dd0e25a..0c333cc2c5ff 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/CHANGELOG.md +++ b/sdk/keyvault/azure-mgmt-keyvault/CHANGELOG.md @@ -1,5 +1,42 @@ # Release History +## 13.0.0 (2025-12-11) + +### Features Added + + - Client `KeyVaultManagementClient` added method `send_request` + - Model `DeletedManagedHsm` added property `system_data` + - Model `DeletedVault` added property `system_data` + - Model `Key` added property `properties` + - Model `Key` added property `system_data` + - Model `MHSMPrivateEndpointConnectionItem` added property `properties` + - Model `ManagedHsmKey` added property `properties` + - Model `ManagedHsmKey` added property `system_data` + - Model `Operation` added property `operation_properties` + - Model `Permissions` added property `keys_property` + - Model `PrivateEndpointConnection` added property `system_data` + - Model `PrivateEndpointConnectionItem` added property `properties` + - Model `PrivateLinkResource` added property `system_data` + - Model `Resource` added property `system_data` + - Model `Secret` added property `system_data` + - Model `VaultCheckNameAvailabilityParameters` added property `type` + - Added model `CloudError` + - Added model `OperationProperties` + - Added model `TrackedResource` + +### Breaking Changes + + - This version introduces new hybrid models which have dual dictionary and model nature. Please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - Model `Key` moved instance variable `attributes`, `kty`, `key_ops`, `key_size`, `curve_name`, `key_uri`, `key_uri_with_version`, `rotation_policy` and `release_policy` under property `properties` + - Model `MHSMPrivateEndpointConnectionItem` moved instance variable `private_endpoint`, `private_link_service_connection_state` and `provisioning_state` under property `properties` + - Model `ManagedHsmKey` moved instance variable `attributes`, `kty`, `key_ops`, `key_size`, `curve_name`, `key_uri`, `key_uri_with_version`, `rotation_policy` and `release_policy` under property `properties` + - Model `Operation` moved instance variable `service_specification` under property `operation_properties` + - Model `PrivateEndpointConnectionItem` moved instance variable `private_endpoint`, `private_link_service_connection_state` and `provisioning_state` under property `properties` + - Model `Permissions` renamed its instance variable `keys` to `keys_property` + - Model `Resource` deleted or renamed its instance variable `location` + - Model `Resource` deleted or renamed its instance variable `tags` + - Renamed model `ProxyResourceWithoutSystemData` to `ProxyResource` + ## 12.1.1 (2025-10-09) ### Bugs Fixed diff --git a/sdk/keyvault/azure-mgmt-keyvault/_metadata.json b/sdk/keyvault/azure-mgmt-keyvault/_metadata.json index 7fcaeb14700b..e9dcd87a872f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/_metadata.json +++ b/sdk/keyvault/azure-mgmt-keyvault/_metadata.json @@ -1,11 +1,7 @@ { - "commit": "520e1f6bc250b4ce51a22eaa7583cc0b24564b71", + "apiVersion": "2025-05-01", + "commit": "74db5e79837425a7723e81bca0b7576ab725c186", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.40.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/keyvault/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.40.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/keyvault/resource-manager/readme.md" + "typespec_src": "specification/keyvault/KeyVault.Management", + "emitterVersion": "0.55.0" } \ No newline at end of file diff --git a/sdk/keyvault/azure-mgmt-keyvault/apiview-properties.json b/sdk/keyvault/azure-mgmt-keyvault/apiview-properties.json index 41f90483cb89..2a9f6a6b7d08 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/apiview-properties.json +++ b/sdk/keyvault/azure-mgmt-keyvault/apiview-properties.json @@ -1,225 +1,220 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.KeyVault", "CrossLanguageDefinitionId": { - "azure.mgmt.keyvault.models.AccessPolicyEntry": null, - "azure.mgmt.keyvault.models.Action": null, - "azure.mgmt.keyvault.models.Attributes": null, - "azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters": null, - "azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult": null, - "azure.mgmt.keyvault.models.CheckNameAvailabilityResult": null, - "azure.mgmt.keyvault.models.CloudErrorBody": null, - "azure.mgmt.keyvault.models.DeletedManagedHsm": null, - "azure.mgmt.keyvault.models.DeletedManagedHsmListResult": null, - "azure.mgmt.keyvault.models.DeletedManagedHsmProperties": null, - "azure.mgmt.keyvault.models.DeletedVault": null, - "azure.mgmt.keyvault.models.DeletedVaultListResult": null, - "azure.mgmt.keyvault.models.DeletedVaultProperties": null, - "azure.mgmt.keyvault.models.DimensionProperties": null, - "azure.mgmt.keyvault.models.Error": null, - "azure.mgmt.keyvault.models.IPRule": null, - "azure.mgmt.keyvault.models.Resource": null, - "azure.mgmt.keyvault.models.Key": null, - "azure.mgmt.keyvault.models.KeyAttributes": null, - "azure.mgmt.keyvault.models.KeyCreateParameters": null, - "azure.mgmt.keyvault.models.KeyListResult": null, - "azure.mgmt.keyvault.models.KeyProperties": null, - "azure.mgmt.keyvault.models.KeyReleasePolicy": null, - "azure.mgmt.keyvault.models.KeyRotationPolicyAttributes": null, - "azure.mgmt.keyvault.models.LifetimeAction": null, - "azure.mgmt.keyvault.models.LogSpecification": null, - "azure.mgmt.keyvault.models.ManagedHsmResource": null, - "azure.mgmt.keyvault.models.ManagedHsm": null, - "azure.mgmt.keyvault.models.ManagedHsmAction": null, - "azure.mgmt.keyvault.models.ManagedHsmError": null, - "azure.mgmt.keyvault.models.ProxyResourceWithoutSystemData": null, - "azure.mgmt.keyvault.models.ManagedHsmKey": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyAttributes": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyListResult": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyProperties": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy": null, - "azure.mgmt.keyvault.models.ManagedHsmKeyRotationPolicyAttributes": null, - "azure.mgmt.keyvault.models.ManagedHsmLifetimeAction": null, - "azure.mgmt.keyvault.models.ManagedHsmListResult": null, - "azure.mgmt.keyvault.models.ManagedHsmProperties": null, - "azure.mgmt.keyvault.models.ManagedHsmRotationPolicy": null, - "azure.mgmt.keyvault.models.ManagedHSMSecurityDomainProperties": null, - "azure.mgmt.keyvault.models.ManagedHsmSku": null, - "azure.mgmt.keyvault.models.ManagedHsmTrigger": null, - "azure.mgmt.keyvault.models.ManagedServiceIdentity": null, - "azure.mgmt.keyvault.models.MetricSpecification": null, - "azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion": null, - "azure.mgmt.keyvault.models.MHSMIPRule": null, - "azure.mgmt.keyvault.models.MHSMNetworkRuleSet": null, - "azure.mgmt.keyvault.models.MHSMPrivateEndpoint": null, - "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection": null, - "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionItem": null, - "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionsListResult": null, - "azure.mgmt.keyvault.models.MHSMPrivateLinkResource": null, - "azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult": null, - "azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState": null, - "azure.mgmt.keyvault.models.MHSMRegionsListResult": null, - "azure.mgmt.keyvault.models.MHSMServiceTagRule": null, - "azure.mgmt.keyvault.models.MHSMVirtualNetworkRule": null, - "azure.mgmt.keyvault.models.NetworkRuleSet": null, - "azure.mgmt.keyvault.models.Operation": null, - "azure.mgmt.keyvault.models.OperationDisplay": null, - "azure.mgmt.keyvault.models.OperationListResult": null, - "azure.mgmt.keyvault.models.Permissions": null, - "azure.mgmt.keyvault.models.PrivateEndpoint": null, - "azure.mgmt.keyvault.models.PrivateEndpointConnection": null, - "azure.mgmt.keyvault.models.PrivateEndpointConnectionItem": null, - "azure.mgmt.keyvault.models.PrivateEndpointConnectionListResult": null, - "azure.mgmt.keyvault.models.PrivateLinkResource": null, - "azure.mgmt.keyvault.models.PrivateLinkResourceListResult": null, - "azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState": null, - "azure.mgmt.keyvault.models.ResourceListResult": null, - "azure.mgmt.keyvault.models.RotationPolicy": null, - "azure.mgmt.keyvault.models.Secret": null, - "azure.mgmt.keyvault.models.SecretAttributes": null, - "azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters": null, - "azure.mgmt.keyvault.models.SecretListResult": null, - "azure.mgmt.keyvault.models.SecretPatchParameters": null, - "azure.mgmt.keyvault.models.SecretPatchProperties": null, - "azure.mgmt.keyvault.models.SecretProperties": null, - "azure.mgmt.keyvault.models.ServiceSpecification": null, - "azure.mgmt.keyvault.models.Sku": null, - "azure.mgmt.keyvault.models.SystemData": null, - "azure.mgmt.keyvault.models.Trigger": null, - "azure.mgmt.keyvault.models.UserAssignedIdentity": null, - "azure.mgmt.keyvault.models.Vault": null, - "azure.mgmt.keyvault.models.VaultAccessPolicyParameters": null, - "azure.mgmt.keyvault.models.VaultAccessPolicyProperties": null, - "azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters": null, - "azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters": null, - "azure.mgmt.keyvault.models.VaultListResult": null, - "azure.mgmt.keyvault.models.VaultPatchParameters": null, - "azure.mgmt.keyvault.models.VaultPatchProperties": null, - "azure.mgmt.keyvault.models.VaultProperties": null, - "azure.mgmt.keyvault.models.VirtualNetworkRule": null, - "azure.mgmt.keyvault.models.JsonWebKeyOperation": null, - "azure.mgmt.keyvault.models.KeyRotationPolicyActionType": null, - "azure.mgmt.keyvault.models.DeletionRecoveryLevel": null, - "azure.mgmt.keyvault.models.JsonWebKeyType": null, - "azure.mgmt.keyvault.models.JsonWebKeyCurveName": null, - "azure.mgmt.keyvault.models.KeyPermissions": null, - "azure.mgmt.keyvault.models.SecretPermissions": null, - "azure.mgmt.keyvault.models.CertificatePermissions": null, - "azure.mgmt.keyvault.models.StoragePermissions": null, - "azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus": null, - "azure.mgmt.keyvault.models.ActionsRequired": null, - "azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState": null, - "azure.mgmt.keyvault.models.IdentityType": null, - "azure.mgmt.keyvault.models.SkuFamily": null, - "azure.mgmt.keyvault.models.SkuName": null, - "azure.mgmt.keyvault.models.CreateMode": null, - "azure.mgmt.keyvault.models.NetworkRuleBypassOptions": null, - "azure.mgmt.keyvault.models.NetworkRuleAction": null, - "azure.mgmt.keyvault.models.VaultProvisioningState": null, - "azure.mgmt.keyvault.models.GeoReplicationRegionProvisioningState": null, - "azure.mgmt.keyvault.models.ManagedHsmSkuFamily": null, - "azure.mgmt.keyvault.models.ManagedHsmSkuName": null, - "azure.mgmt.keyvault.models.ManagedServiceIdentityType": null, - "azure.mgmt.keyvault.models.ProvisioningState": null, - "azure.mgmt.keyvault.models.PublicNetworkAccess": null, - "azure.mgmt.keyvault.models.ActivationStatus": null, - "azure.mgmt.keyvault.models.Reason": null, - "azure.mgmt.keyvault.models.AccessPolicyUpdateKind": null, - "azure.mgmt.keyvault.operations.KeysOperations.create_if_not_exist": null, - "azure.mgmt.keyvault.aio.operations.KeysOperations.create_if_not_exist": null, - "azure.mgmt.keyvault.operations.KeysOperations.get": null, - "azure.mgmt.keyvault.aio.operations.KeysOperations.get": null, - "azure.mgmt.keyvault.operations.KeysOperations.list": null, - "azure.mgmt.keyvault.aio.operations.KeysOperations.list": null, - "azure.mgmt.keyvault.operations.KeysOperations.get_version": null, - "azure.mgmt.keyvault.aio.operations.KeysOperations.get_version": null, - "azure.mgmt.keyvault.operations.KeysOperations.list_versions": null, - "azure.mgmt.keyvault.aio.operations.KeysOperations.list_versions": null, - "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.create_if_not_exist": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.create_if_not_exist": null, - "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.get": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.get": null, - "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.list": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.list": null, - "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.get_version": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.get_version": null, - "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.list_versions": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.list_versions": null, - "azure.mgmt.keyvault.operations.VaultsOperations.begin_create_or_update": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.begin_create_or_update": null, - "azure.mgmt.keyvault.operations.VaultsOperations.update": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.update": null, - "azure.mgmt.keyvault.operations.VaultsOperations.delete": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.delete": null, - "azure.mgmt.keyvault.operations.VaultsOperations.get": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.get": null, - "azure.mgmt.keyvault.operations.VaultsOperations.update_access_policy": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.update_access_policy": null, - "azure.mgmt.keyvault.operations.VaultsOperations.list_by_resource_group": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_by_resource_group": null, - "azure.mgmt.keyvault.operations.VaultsOperations.list_by_subscription": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_by_subscription": null, - "azure.mgmt.keyvault.operations.VaultsOperations.list_deleted": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_deleted": null, - "azure.mgmt.keyvault.operations.VaultsOperations.get_deleted": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.get_deleted": null, - "azure.mgmt.keyvault.operations.VaultsOperations.begin_purge_deleted": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.begin_purge_deleted": null, - "azure.mgmt.keyvault.operations.VaultsOperations.list": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.list": null, - "azure.mgmt.keyvault.operations.VaultsOperations.check_name_availability": null, - "azure.mgmt.keyvault.aio.operations.VaultsOperations.check_name_availability": null, - "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.put": null, - "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.put": null, - "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.operations.PrivateLinkResourcesOperations.list_by_vault": null, - "azure.mgmt.keyvault.aio.operations.PrivateLinkResourcesOperations.list_by_vault": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_create_or_update": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_create_or_update": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_update": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_update": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_delete": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_delete": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.get": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.get": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_by_resource_group": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_by_resource_group": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_by_subscription": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_by_subscription": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_deleted": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_deleted": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.get_deleted": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.get_deleted": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_purge_deleted": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_purge_deleted": null, - "azure.mgmt.keyvault.operations.ManagedHsmsOperations.check_mhsm_name_availability": null, - "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.check_mhsm_name_availability": null, - "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.put": null, - "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.put": null, - "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.keyvault.operations.MHSMPrivateLinkResourcesOperations.list_by_mhsm_resource": null, - "azure.mgmt.keyvault.aio.operations.MHSMPrivateLinkResourcesOperations.list_by_mhsm_resource": null, - "azure.mgmt.keyvault.operations.MHSMRegionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.aio.operations.MHSMRegionsOperations.list_by_resource": null, - "azure.mgmt.keyvault.operations.Operations.list": null, - "azure.mgmt.keyvault.aio.operations.Operations.list": null, - "azure.mgmt.keyvault.operations.SecretsOperations.create_or_update": null, - "azure.mgmt.keyvault.aio.operations.SecretsOperations.create_or_update": null, - "azure.mgmt.keyvault.operations.SecretsOperations.update": null, - "azure.mgmt.keyvault.aio.operations.SecretsOperations.update": null, - "azure.mgmt.keyvault.operations.SecretsOperations.get": null, - "azure.mgmt.keyvault.aio.operations.SecretsOperations.get": null, - "azure.mgmt.keyvault.operations.SecretsOperations.list": null, - "azure.mgmt.keyvault.aio.operations.SecretsOperations.list": null + "azure.mgmt.keyvault.models.AccessPolicyEntry": "Microsoft.KeyVault.AccessPolicyEntry", + "azure.mgmt.keyvault.models.Action": "Microsoft.KeyVault.Action", + "azure.mgmt.keyvault.models.Attributes": "Microsoft.KeyVault.Attributes", + "azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters": "Microsoft.KeyVault.CheckMhsmNameAvailabilityParameters", + "azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult": "Microsoft.KeyVault.CheckMhsmNameAvailabilityResult", + "azure.mgmt.keyvault.models.CheckNameAvailabilityResult": "Microsoft.KeyVault.CheckNameAvailabilityResult", + "azure.mgmt.keyvault.models.CloudError": "Microsoft.KeyVault.CloudError", + "azure.mgmt.keyvault.models.CloudErrorBody": "Microsoft.KeyVault.CloudErrorBody", + "azure.mgmt.keyvault.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.keyvault.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.keyvault.models.DeletedManagedHsm": "Microsoft.KeyVault.DeletedManagedHsm", + "azure.mgmt.keyvault.models.DeletedManagedHsmProperties": "Microsoft.KeyVault.DeletedManagedHsmProperties", + "azure.mgmt.keyvault.models.DeletedVault": "Microsoft.KeyVault.DeletedVault", + "azure.mgmt.keyvault.models.DeletedVaultProperties": "Microsoft.KeyVault.DeletedVaultProperties", + "azure.mgmt.keyvault.models.DimensionProperties": "Microsoft.KeyVault.DimensionProperties", + "azure.mgmt.keyvault.models.Error": "Microsoft.KeyVault.Error", + "azure.mgmt.keyvault.models.IPRule": "Microsoft.KeyVault.IPRule", + "azure.mgmt.keyvault.models.Key": "Microsoft.KeyVault.Key", + "azure.mgmt.keyvault.models.KeyAttributes": "Microsoft.KeyVault.KeyAttributes", + "azure.mgmt.keyvault.models.KeyCreateParameters": "Microsoft.KeyVault.KeyCreateParameters", + "azure.mgmt.keyvault.models.KeyProperties": "Microsoft.KeyVault.KeyProperties", + "azure.mgmt.keyvault.models.KeyReleasePolicy": "Microsoft.KeyVault.KeyReleasePolicy", + "azure.mgmt.keyvault.models.KeyRotationPolicyAttributes": "Microsoft.KeyVault.KeyRotationPolicyAttributes", + "azure.mgmt.keyvault.models.LifetimeAction": "Microsoft.KeyVault.LifetimeAction", + "azure.mgmt.keyvault.models.LogSpecification": "Microsoft.KeyVault.LogSpecification", + "azure.mgmt.keyvault.models.ManagedHsm": "Microsoft.KeyVault.ManagedHsm", + "azure.mgmt.keyvault.models.ManagedHsmAction": "Microsoft.KeyVault.ManagedHsmAction", + "azure.mgmt.keyvault.models.ManagedHsmError": "Microsoft.KeyVault.ManagedHsmError", + "azure.mgmt.keyvault.models.ManagedHsmKey": "Microsoft.KeyVault.ManagedHsmKey", + "azure.mgmt.keyvault.models.ManagedHsmKeyAttributes": "Microsoft.KeyVault.ManagedHsmKeyAttributes", + "azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters": "Microsoft.KeyVault.ManagedHsmKeyCreateParameters", + "azure.mgmt.keyvault.models.ManagedHsmKeyProperties": "Microsoft.KeyVault.ManagedHsmKeyProperties", + "azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy": "Microsoft.KeyVault.ManagedHsmKeyReleasePolicy", + "azure.mgmt.keyvault.models.ManagedHsmKeyRotationPolicyAttributes": "Microsoft.KeyVault.ManagedHsmKeyRotationPolicyAttributes", + "azure.mgmt.keyvault.models.ManagedHsmLifetimeAction": "Microsoft.KeyVault.ManagedHsmLifetimeAction", + "azure.mgmt.keyvault.models.ManagedHsmProperties": "Microsoft.KeyVault.ManagedHsmProperties", + "azure.mgmt.keyvault.models.ManagedHsmResource": "Microsoft.KeyVault.ManagedHsmResource", + "azure.mgmt.keyvault.models.ManagedHsmRotationPolicy": "Microsoft.KeyVault.ManagedHsmRotationPolicy", + "azure.mgmt.keyvault.models.ManagedHSMSecurityDomainProperties": "Microsoft.KeyVault.ManagedHSMSecurityDomainProperties", + "azure.mgmt.keyvault.models.ManagedHsmSku": "Microsoft.KeyVault.ManagedHsmSku", + "azure.mgmt.keyvault.models.ManagedHsmTrigger": "Microsoft.KeyVault.ManagedHsmTrigger", + "azure.mgmt.keyvault.models.ManagedServiceIdentity": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", + "azure.mgmt.keyvault.models.MetricSpecification": "Microsoft.KeyVault.MetricSpecification", + "azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion": "Microsoft.KeyVault.MhsmGeoReplicatedRegion", + "azure.mgmt.keyvault.models.MHSMIPRule": "Microsoft.KeyVault.MhsmipRule", + "azure.mgmt.keyvault.models.MHSMNetworkRuleSet": "Microsoft.KeyVault.MhsmNetworkRuleSet", + "azure.mgmt.keyvault.models.MHSMPrivateEndpoint": "Microsoft.KeyVault.MhsmPrivateEndpoint", + "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection": "Microsoft.KeyVault.MhsmPrivateEndpointConnection", + "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionItem": "Microsoft.KeyVault.MhsmPrivateEndpointConnectionItem", + "azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionProperties": "Microsoft.KeyVault.MhsmPrivateEndpointConnectionProperties", + "azure.mgmt.keyvault.models.MHSMPrivateLinkResource": "Microsoft.KeyVault.MhsmPrivateLinkResource", + "azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult": "Microsoft.KeyVault.MhsmPrivateLinkResourceListResult", + "azure.mgmt.keyvault.models.MHSMPrivateLinkResourceProperties": "Microsoft.KeyVault.MhsmPrivateLinkResourceProperties", + "azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState": "Microsoft.KeyVault.MhsmPrivateLinkServiceConnectionState", + "azure.mgmt.keyvault.models.MHSMServiceTagRule": "Microsoft.KeyVault.MhsmServiceTagRule", + "azure.mgmt.keyvault.models.MHSMVirtualNetworkRule": "Microsoft.KeyVault.MhsmVirtualNetworkRule", + "azure.mgmt.keyvault.models.NetworkRuleSet": "Microsoft.KeyVault.NetworkRuleSet", + "azure.mgmt.keyvault.models.Operation": "Microsoft.KeyVault.Operation", + "azure.mgmt.keyvault.models.OperationDisplay": "Microsoft.KeyVault.OperationDisplay", + "azure.mgmt.keyvault.models.OperationProperties": "Microsoft.KeyVault.OperationProperties", + "azure.mgmt.keyvault.models.Permissions": "Microsoft.KeyVault.Permissions", + "azure.mgmt.keyvault.models.PrivateEndpoint": "Microsoft.KeyVault.PrivateEndpoint", + "azure.mgmt.keyvault.models.PrivateEndpointConnection": "Microsoft.KeyVault.PrivateEndpointConnection", + "azure.mgmt.keyvault.models.PrivateEndpointConnectionItem": "Microsoft.KeyVault.PrivateEndpointConnectionItem", + "azure.mgmt.keyvault.models.PrivateEndpointConnectionProperties": "Microsoft.KeyVault.PrivateEndpointConnectionProperties", + "azure.mgmt.keyvault.models.PrivateLinkResource": "Microsoft.KeyVault.PrivateLinkResource", + "azure.mgmt.keyvault.models.PrivateLinkResourceListResult": "Microsoft.KeyVault.PrivateLinkResourceListResult", + "azure.mgmt.keyvault.models.PrivateLinkResourceProperties": "Microsoft.KeyVault.PrivateLinkResourceProperties", + "azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState": "Microsoft.KeyVault.PrivateLinkServiceConnectionState", + "azure.mgmt.keyvault.models.RotationPolicy": "Microsoft.KeyVault.RotationPolicy", + "azure.mgmt.keyvault.models.Secret": "Microsoft.KeyVault.Secret", + "azure.mgmt.keyvault.models.SecretAttributes": "Microsoft.KeyVault.SecretAttributes", + "azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters": "Microsoft.KeyVault.SecretCreateOrUpdateParameters", + "azure.mgmt.keyvault.models.SecretPatchParameters": "Microsoft.KeyVault.SecretPatchParameters", + "azure.mgmt.keyvault.models.SecretPatchProperties": "Microsoft.KeyVault.SecretPatchProperties", + "azure.mgmt.keyvault.models.SecretProperties": "Microsoft.KeyVault.SecretProperties", + "azure.mgmt.keyvault.models.ServiceSpecification": "Microsoft.KeyVault.ServiceSpecification", + "azure.mgmt.keyvault.models.Sku": "Microsoft.KeyVault.Sku", + "azure.mgmt.keyvault.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.keyvault.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.keyvault.models.Trigger": "Microsoft.KeyVault.Trigger", + "azure.mgmt.keyvault.models.UserAssignedIdentity": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", + "azure.mgmt.keyvault.models.Vault": "Microsoft.KeyVault.Vault", + "azure.mgmt.keyvault.models.VaultAccessPolicyParameters": "Microsoft.KeyVault.VaultAccessPolicyParameters", + "azure.mgmt.keyvault.models.VaultAccessPolicyProperties": "Microsoft.KeyVault.VaultAccessPolicyProperties", + "azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters": "Microsoft.KeyVault.VaultCheckNameAvailabilityParameters", + "azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters": "Microsoft.KeyVault.VaultCreateOrUpdateParameters", + "azure.mgmt.keyvault.models.VaultPatchParameters": "Microsoft.KeyVault.VaultPatchParameters", + "azure.mgmt.keyvault.models.VaultPatchProperties": "Microsoft.KeyVault.VaultPatchProperties", + "azure.mgmt.keyvault.models.VaultProperties": "Microsoft.KeyVault.VaultProperties", + "azure.mgmt.keyvault.models.VirtualNetworkRule": "Microsoft.KeyVault.VirtualNetworkRule", + "azure.mgmt.keyvault.models.IdentityType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.keyvault.models.SkuFamily": "Microsoft.KeyVault.SkuFamily", + "azure.mgmt.keyvault.models.SkuName": "Microsoft.KeyVault.SkuName", + "azure.mgmt.keyvault.models.KeyPermissions": "Microsoft.KeyVault.KeyPermissions", + "azure.mgmt.keyvault.models.SecretPermissions": "Microsoft.KeyVault.SecretPermissions", + "azure.mgmt.keyvault.models.CertificatePermissions": "Microsoft.KeyVault.CertificatePermissions", + "azure.mgmt.keyvault.models.StoragePermissions": "Microsoft.KeyVault.StoragePermissions", + "azure.mgmt.keyvault.models.CreateMode": "Microsoft.KeyVault.CreateMode", + "azure.mgmt.keyvault.models.NetworkRuleBypassOptions": "Microsoft.KeyVault.NetworkRuleBypassOptions", + "azure.mgmt.keyvault.models.NetworkRuleAction": "Microsoft.KeyVault.NetworkRuleAction", + "azure.mgmt.keyvault.models.VaultProvisioningState": "Microsoft.KeyVault.VaultProvisioningState", + "azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus": "Microsoft.KeyVault.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.keyvault.models.ActionsRequired": "Microsoft.KeyVault.ActionsRequired", + "azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState": "Microsoft.KeyVault.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.keyvault.models.AccessPolicyUpdateKind": "Microsoft.KeyVault.AccessPolicyUpdateKind", + "azure.mgmt.keyvault.models.Reason": "Microsoft.KeyVault.Reason", + "azure.mgmt.keyvault.models.ProvisioningState": "Microsoft.KeyVault.ProvisioningState", + "azure.mgmt.keyvault.models.GeoReplicationRegionProvisioningState": "Microsoft.KeyVault.GeoReplicationRegionProvisioningState", + "azure.mgmt.keyvault.models.PublicNetworkAccess": "Microsoft.KeyVault.PublicNetworkAccess", + "azure.mgmt.keyvault.models.ActivationStatus": "Microsoft.KeyVault.ActivationStatus", + "azure.mgmt.keyvault.models.ManagedHsmSkuFamily": "Microsoft.KeyVault.ManagedHsmSkuFamily", + "azure.mgmt.keyvault.models.ManagedHsmSkuName": "Microsoft.KeyVault.ManagedHsmSkuName", + "azure.mgmt.keyvault.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "azure.mgmt.keyvault.models.DeletionRecoveryLevel": "Microsoft.KeyVault.DeletionRecoveryLevel", + "azure.mgmt.keyvault.models.JsonWebKeyType": "Microsoft.KeyVault.JsonWebKeyType", + "azure.mgmt.keyvault.models.JsonWebKeyOperation": "Microsoft.KeyVault.JsonWebKeyOperation", + "azure.mgmt.keyvault.models.JsonWebKeyCurveName": "Microsoft.KeyVault.JsonWebKeyCurveName", + "azure.mgmt.keyvault.models.KeyRotationPolicyActionType": "Microsoft.KeyVault.KeyRotationPolicyActionType", + "azure.mgmt.keyvault.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.keyvault.aio.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.keyvault.operations.VaultsOperations.get": "Microsoft.KeyVault.Vaults.get", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.get": "Microsoft.KeyVault.Vaults.get", + "azure.mgmt.keyvault.operations.VaultsOperations.begin_create_or_update": "Microsoft.KeyVault.Vaults.createOrUpdate", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.begin_create_or_update": "Microsoft.KeyVault.Vaults.createOrUpdate", + "azure.mgmt.keyvault.operations.VaultsOperations.update": "Microsoft.KeyVault.Vaults.update", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.update": "Microsoft.KeyVault.Vaults.update", + "azure.mgmt.keyvault.operations.VaultsOperations.delete": "Microsoft.KeyVault.Vaults.delete", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.delete": "Microsoft.KeyVault.Vaults.delete", + "azure.mgmt.keyvault.operations.VaultsOperations.list_by_resource_group": "Microsoft.KeyVault.Vaults.listByResourceGroup", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_by_resource_group": "Microsoft.KeyVault.Vaults.listByResourceGroup", + "azure.mgmt.keyvault.operations.VaultsOperations.list_by_subscription": "Microsoft.KeyVault.Vaults.listBySubscription", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_by_subscription": "Microsoft.KeyVault.Vaults.listBySubscription", + "azure.mgmt.keyvault.operations.VaultsOperations.update_access_policy": "Microsoft.KeyVault.Vaults.updateAccessPolicy", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.update_access_policy": "Microsoft.KeyVault.Vaults.updateAccessPolicy", + "azure.mgmt.keyvault.operations.VaultsOperations.get_deleted": "Microsoft.KeyVault.DeletedVaults.getDeleted", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.get_deleted": "Microsoft.KeyVault.DeletedVaults.getDeleted", + "azure.mgmt.keyvault.operations.VaultsOperations.begin_purge_deleted": "Microsoft.KeyVault.DeletedVaults.purgeDeleted", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.begin_purge_deleted": "Microsoft.KeyVault.DeletedVaults.purgeDeleted", + "azure.mgmt.keyvault.operations.VaultsOperations.list_deleted": "Microsoft.KeyVault.VaultsOperationGroup.listDeleted", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.list_deleted": "Microsoft.KeyVault.VaultsOperationGroup.listDeleted", + "azure.mgmt.keyvault.operations.VaultsOperations.list": "Microsoft.KeyVault.VaultsOperationGroup.list", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.list": "Microsoft.KeyVault.VaultsOperationGroup.list", + "azure.mgmt.keyvault.operations.VaultsOperations.check_name_availability": "Microsoft.KeyVault.VaultsOperationGroup.checkNameAvailability", + "azure.mgmt.keyvault.aio.operations.VaultsOperations.check_name_availability": "Microsoft.KeyVault.VaultsOperationGroup.checkNameAvailability", + "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.KeyVault.PrivateEndpointConnections.get", + "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.KeyVault.PrivateEndpointConnections.get", + "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.put": "Microsoft.KeyVault.PrivateEndpointConnections.put", + "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.put": "Microsoft.KeyVault.PrivateEndpointConnections.put", + "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.KeyVault.PrivateEndpointConnections.delete", + "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.KeyVault.PrivateEndpointConnections.delete", + "azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations.list_by_resource": "Microsoft.KeyVault.PrivateEndpointConnections.listByResource", + "azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations.list_by_resource": "Microsoft.KeyVault.PrivateEndpointConnections.listByResource", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.get": "Microsoft.KeyVault.ManagedHsms.get", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.get": "Microsoft.KeyVault.ManagedHsms.get", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_create_or_update": "Microsoft.KeyVault.ManagedHsms.createOrUpdate", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_create_or_update": "Microsoft.KeyVault.ManagedHsms.createOrUpdate", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_update": "Microsoft.KeyVault.ManagedHsms.update", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_update": "Microsoft.KeyVault.ManagedHsms.update", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_delete": "Microsoft.KeyVault.ManagedHsms.delete", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_delete": "Microsoft.KeyVault.ManagedHsms.delete", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_by_resource_group": "Microsoft.KeyVault.ManagedHsms.listByResourceGroup", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_by_resource_group": "Microsoft.KeyVault.ManagedHsms.listByResourceGroup", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_by_subscription": "Microsoft.KeyVault.ManagedHsms.listBySubscription", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_by_subscription": "Microsoft.KeyVault.ManagedHsms.listBySubscription", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.get_deleted": "Microsoft.KeyVault.DeletedManagedHsms.getDeleted", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.get_deleted": "Microsoft.KeyVault.DeletedManagedHsms.getDeleted", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.begin_purge_deleted": "Microsoft.KeyVault.DeletedManagedHsms.purgeDeleted", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.begin_purge_deleted": "Microsoft.KeyVault.DeletedManagedHsms.purgeDeleted", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.list_deleted": "Microsoft.KeyVault.ManagedHsmsOperationGroup.listDeleted", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.list_deleted": "Microsoft.KeyVault.ManagedHsmsOperationGroup.listDeleted", + "azure.mgmt.keyvault.operations.ManagedHsmsOperations.check_mhsm_name_availability": "Microsoft.KeyVault.ManagedHsmsOperationGroup.checkMhsmNameAvailability", + "azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations.check_mhsm_name_availability": "Microsoft.KeyVault.ManagedHsmsOperationGroup.checkMhsmNameAvailability", + "azure.mgmt.keyvault.operations.SecretsOperations.get": "Microsoft.KeyVault.Secrets.get", + "azure.mgmt.keyvault.aio.operations.SecretsOperations.get": "Microsoft.KeyVault.Secrets.get", + "azure.mgmt.keyvault.operations.SecretsOperations.create_or_update": "Microsoft.KeyVault.Secrets.createOrUpdate", + "azure.mgmt.keyvault.aio.operations.SecretsOperations.create_or_update": "Microsoft.KeyVault.Secrets.createOrUpdate", + "azure.mgmt.keyvault.operations.SecretsOperations.update": "Microsoft.KeyVault.Secrets.update", + "azure.mgmt.keyvault.aio.operations.SecretsOperations.update": "Microsoft.KeyVault.Secrets.update", + "azure.mgmt.keyvault.operations.SecretsOperations.list": "Microsoft.KeyVault.Secrets.list", + "azure.mgmt.keyvault.aio.operations.SecretsOperations.list": "Microsoft.KeyVault.Secrets.list", + "azure.mgmt.keyvault.operations.KeysOperations.get": "Microsoft.KeyVault.Keys.get", + "azure.mgmt.keyvault.aio.operations.KeysOperations.get": "Microsoft.KeyVault.Keys.get", + "azure.mgmt.keyvault.operations.KeysOperations.create_if_not_exist": "Microsoft.KeyVault.Keys.createIfNotExist", + "azure.mgmt.keyvault.aio.operations.KeysOperations.create_if_not_exist": "Microsoft.KeyVault.Keys.createIfNotExist", + "azure.mgmt.keyvault.operations.KeysOperations.list": "Microsoft.KeyVault.Keys.list", + "azure.mgmt.keyvault.aio.operations.KeysOperations.list": "Microsoft.KeyVault.Keys.list", + "azure.mgmt.keyvault.operations.KeysOperations.get_version": "Microsoft.KeyVault.KeyOperationGroup.getVersion", + "azure.mgmt.keyvault.aio.operations.KeysOperations.get_version": "Microsoft.KeyVault.KeyOperationGroup.getVersion", + "azure.mgmt.keyvault.operations.KeysOperations.list_versions": "Microsoft.KeyVault.KeyOperationGroup.listVersions", + "azure.mgmt.keyvault.aio.operations.KeysOperations.list_versions": "Microsoft.KeyVault.KeyOperationGroup.listVersions", + "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.get": "Microsoft.KeyVault.ManagedHsmKeys.get", + "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.get": "Microsoft.KeyVault.ManagedHsmKeys.get", + "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.create_if_not_exist": "Microsoft.KeyVault.ManagedHsmKeys.createIfNotExist", + "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.create_if_not_exist": "Microsoft.KeyVault.ManagedHsmKeys.createIfNotExist", + "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.list": "Microsoft.KeyVault.ManagedHsmKeys.list", + "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.list": "Microsoft.KeyVault.ManagedHsmKeys.list", + "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.get_version": "Microsoft.KeyVault.ManagedHsmKeyOperationGroup.getVersion", + "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.get_version": "Microsoft.KeyVault.ManagedHsmKeyOperationGroup.getVersion", + "azure.mgmt.keyvault.operations.ManagedHsmKeysOperations.list_versions": "Microsoft.KeyVault.ManagedHsmKeyOperationGroup.listVersions", + "azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations.list_versions": "Microsoft.KeyVault.ManagedHsmKeyOperationGroup.listVersions", + "azure.mgmt.keyvault.operations.PrivateLinkResourcesOperations.list_by_vault": "Microsoft.KeyVault.Vaults.listByVault", + "azure.mgmt.keyvault.aio.operations.PrivateLinkResourcesOperations.list_by_vault": "Microsoft.KeyVault.Vaults.listByVault", + "azure.mgmt.keyvault.operations.MHSMPrivateLinkResourcesOperations.list_by_mhsm_resource": "Microsoft.KeyVault.ManagedHsms.listByMHSMResource", + "azure.mgmt.keyvault.aio.operations.MHSMPrivateLinkResourcesOperations.list_by_mhsm_resource": "Microsoft.KeyVault.ManagedHsms.listByMHSMResource", + "azure.mgmt.keyvault.operations.MHSMRegionsOperations.list_by_resource": "Microsoft.KeyVault.ManagedHsms.listByResource", + "azure.mgmt.keyvault.aio.operations.MHSMRegionsOperations.list_by_resource": "Microsoft.KeyVault.ManagedHsms.listByResource", + "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.get": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.get", + "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.get": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.get", + "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.put": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.put", + "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.put": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.put", + "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.begin_delete": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.delete", + "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.begin_delete": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.delete", + "azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations.list_by_resource": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.listByResource", + "azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations.list_by_resource": "Microsoft.KeyVault.MhsmPrivateEndpointConnections.listByResource" } } \ No newline at end of file diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/__init__.py index a60631755701..3d8686069838 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._key_vault_management_client import KeyVaultManagementClient # type: ignore +from ._client import KeyVaultManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_client.py similarity index 88% rename from sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py rename to sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_client.py index c6376e0ab687..19af2be1d118 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import KeyVaultManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -43,43 +42,42 @@ class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. - :ivar keys: KeysOperations operations - :vartype keys: azure.mgmt.keyvault.operations.KeysOperations - :ivar managed_hsm_keys: ManagedHsmKeysOperations operations - :vartype managed_hsm_keys: azure.mgmt.keyvault.operations.ManagedHsmKeysOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.keyvault.operations.Operations :ivar vaults: VaultsOperations operations :vartype vaults: azure.mgmt.keyvault.operations.VaultsOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.keyvault.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.keyvault.operations.PrivateLinkResourcesOperations :ivar managed_hsms: ManagedHsmsOperations operations :vartype managed_hsms: azure.mgmt.keyvault.operations.ManagedHsmsOperations - :ivar mhsm_private_endpoint_connections: MHSMPrivateEndpointConnectionsOperations operations - :vartype mhsm_private_endpoint_connections: - azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations + :ivar secrets: SecretsOperations operations + :vartype secrets: azure.mgmt.keyvault.operations.SecretsOperations + :ivar keys: KeysOperations operations + :vartype keys: azure.mgmt.keyvault.operations.KeysOperations + :ivar managed_hsm_keys: ManagedHsmKeysOperations operations + :vartype managed_hsm_keys: azure.mgmt.keyvault.operations.ManagedHsmKeysOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.keyvault.operations.PrivateLinkResourcesOperations :ivar mhsm_private_link_resources: MHSMPrivateLinkResourcesOperations operations :vartype mhsm_private_link_resources: azure.mgmt.keyvault.operations.MHSMPrivateLinkResourcesOperations :ivar mhsm_regions: MHSMRegionsOperations operations :vartype mhsm_regions: azure.mgmt.keyvault.operations.MHSMRegionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.keyvault.operations.Operations - :ivar secrets: SecretsOperations operations - :vartype secrets: azure.mgmt.keyvault.operations.SecretsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar mhsm_private_endpoint_connections: MHSMPrivateEndpointConnectionsOperations operations + :vartype mhsm_private_endpoint_connections: + azure.mgmt.keyvault.operations.MHSMPrivateEndpointConnectionsOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :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 None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is "2025-05-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. @@ -94,6 +92,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -102,6 +101,7 @@ def __init__( self._config = KeyVaultManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -125,39 +125,38 @@ def __init__( 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) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), 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 = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_hsm_keys = ManagedHsmKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.vaults = VaultsOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.managed_hsms = ManagedHsmsOperations(self._client, self._config, self._serialize, self._deserialize) - self.mhsm_private_endpoint_connections = MHSMPrivateEndpointConnectionsOperations( + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_hsm_keys = ManagedHsmKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.mhsm_private_link_resources = MHSMPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.mhsm_regions = MHSMRegionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.mhsm_private_endpoint_connections = MHSMPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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 >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -170,7 +169,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_configuration.py index bb00ffc118ec..535b5aea1471 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,16 +24,17 @@ class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instanc Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is "2025-05-01". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -41,6 +42,7 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -53,6 +55,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/__init__.py @@ -1,6 +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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/model_base.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/model_base.py new file mode 100644 index 000000000000..d883c1d0b855 --- /dev/null +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/model_base.py @@ -0,0 +1,1260 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_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_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._attr_to_rest_field.items() + } + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._original_tsp_name = original_tsp_name + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + original_tsp_name=original_tsp_name, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/serialization.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/serialization.py index 5f250836cf4b..45a3e44e45cb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/serialization.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -787,7 +787,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_version.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_version.py index 5ae4c1319488..7373638328f9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/_version.py @@ -1,8 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "12.1.1" +VERSION = "13.0.0" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/__init__.py index 30acffb8c4a7..31921ab4837a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._key_vault_management_client import KeyVaultManagementClient # type: ignore +from ._client import KeyVaultManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_client.py similarity index 89% rename from sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py rename to sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_client.py index 999d6174d010..79ab98e6736c 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_key_vault_management_client.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,6 @@ from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models from .._utils.serialization import Deserializer, Serializer from ._configuration import KeyVaultManagementClientConfiguration from .operations import ( @@ -43,44 +42,43 @@ class KeyVaultManagementClient: # pylint: disable=too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure Key Vault. - :ivar keys: KeysOperations operations - :vartype keys: azure.mgmt.keyvault.aio.operations.KeysOperations - :ivar managed_hsm_keys: ManagedHsmKeysOperations operations - :vartype managed_hsm_keys: azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.keyvault.aio.operations.Operations :ivar vaults: VaultsOperations operations :vartype vaults: azure.mgmt.keyvault.aio.operations.VaultsOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.keyvault.aio.operations.PrivateEndpointConnectionsOperations + :ivar managed_hsms: ManagedHsmsOperations operations + :vartype managed_hsms: azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations + :ivar secrets: SecretsOperations operations + :vartype secrets: azure.mgmt.keyvault.aio.operations.SecretsOperations + :ivar keys: KeysOperations operations + :vartype keys: azure.mgmt.keyvault.aio.operations.KeysOperations + :ivar managed_hsm_keys: ManagedHsmKeysOperations operations + :vartype managed_hsm_keys: azure.mgmt.keyvault.aio.operations.ManagedHsmKeysOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.keyvault.aio.operations.PrivateLinkResourcesOperations - :ivar managed_hsms: ManagedHsmsOperations operations - :vartype managed_hsms: azure.mgmt.keyvault.aio.operations.ManagedHsmsOperations - :ivar mhsm_private_endpoint_connections: MHSMPrivateEndpointConnectionsOperations operations - :vartype mhsm_private_endpoint_connections: - azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations :ivar mhsm_private_link_resources: MHSMPrivateLinkResourcesOperations operations :vartype mhsm_private_link_resources: azure.mgmt.keyvault.aio.operations.MHSMPrivateLinkResourcesOperations :ivar mhsm_regions: MHSMRegionsOperations operations :vartype mhsm_regions: azure.mgmt.keyvault.aio.operations.MHSMRegionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.keyvault.aio.operations.Operations - :ivar secrets: SecretsOperations operations - :vartype secrets: azure.mgmt.keyvault.aio.operations.SecretsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar mhsm_private_endpoint_connections: MHSMPrivateEndpointConnectionsOperations operations + :vartype mhsm_private_endpoint_connections: + azure.mgmt.keyvault.aio.operations.MHSMPrivateEndpointConnectionsOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :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 None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is "2025-05-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. @@ -95,6 +93,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -103,6 +102,7 @@ def __init__( self._config = KeyVaultManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -127,34 +127,33 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs + base_url=cast(str, _endpoint), 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 = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_hsm_keys = ManagedHsmKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.vaults = VaultsOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.managed_hsms = ManagedHsmsOperations(self._client, self._config, self._serialize, self._deserialize) - self.mhsm_private_endpoint_connections = MHSMPrivateEndpointConnectionsOperations( + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_hsm_keys = ManagedHsmKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.mhsm_private_link_resources = MHSMPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.mhsm_regions = MHSMRegionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.mhsm_private_endpoint_connections = MHSMPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -162,7 +161,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -175,7 +174,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_configuration.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_configuration.py index 2b6c8faac0f3..a333b16a00e7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_configuration.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,16 +24,17 @@ class KeyVaultManagementClientConfiguration: # pylint: disable=too-many-instanc Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is "2025-05-01". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -41,6 +42,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -53,6 +55,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/__init__.py index 2c20c64a2fa5..599afc490f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,34 +12,34 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._keys_operations import KeysOperations # type: ignore -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore -from ._vaults_operations import VaultsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore -from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore from ._operations import Operations # type: ignore -from ._secrets_operations import SecretsOperations # type: ignore +from ._operations import VaultsOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import ManagedHsmsOperations # type: ignore +from ._operations import SecretsOperations # type: ignore +from ._operations import KeysOperations # type: ignore +from ._operations import ManagedHsmKeysOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import MHSMRegionsOperations # type: ignore +from ._operations import MHSMPrivateEndpointConnectionsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "KeysOperations", - "ManagedHsmKeysOperations", + "Operations", "VaultsOperations", "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "ManagedHsmsOperations", - "MHSMPrivateEndpointConnectionsOperations", + "SecretsOperations", + "KeysOperations", + "ManagedHsmKeysOperations", + "PrivateLinkResourcesOperations", "MHSMPrivateLinkResourcesOperations", "MHSMRegionsOperations", - "Operations", - "SecretsOperations", + "MHSMPrivateEndpointConnectionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_keys_operations.py deleted file mode 100644 index 8dafdb114f8a..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_keys_operations.py +++ /dev/null @@ -1,505 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, 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, - 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._keys_operations import ( - build_create_if_not_exist_request, - build_get_request, - build_get_version_request, - build_list_request, - build_list_versions_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class KeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`keys` 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: KeyVaultManagementClientConfiguration = 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 create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: _models.KeyCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: 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: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: Union[_models.KeyCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Is either a - KeyCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters or IO[bytes] - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "KeyCreateParameters") - - _request = build_create_if_not_exist_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any) -> _models.Key: - """Gets the current version of the specified key from the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key to be retrieved. Required. - :type vault_name: str - :param key_name: The name of the key to be retrieved. Required. - :type key_name: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Key"]: - """Lists the keys in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the keys to be retrieved. Required. - :type vault_name: str - :return: An iterator like instance of either Key or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Key] - :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.KeyListResult] = 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("KeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_version( - self, resource_group_name: str, vault_name: str, key_name: str, key_version: str, **kwargs: Any - ) -> _models.Key: - """Gets the specified version of the specified key in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key version to be retrieved. - Required. - :type vault_name: str - :param key_name: The name of the key version to be retrieved. Required. - :type key_name: str - :param key_version: The version of the key to be retrieved. Required. - :type key_version: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - _request = build_get_version_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_name, - key_version=key_version, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_versions( - self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Key"]: - """Lists the versions of the specified key in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key versions to be retrieved. - Required. - :type vault_name: str - :param key_name: The name of the key versions to be retrieved. Required. - :type key_name: str - :return: An iterator like instance of either Key or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Key] - :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.KeyListResult] = 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_versions_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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("KeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsm_keys_operations.py deleted file mode 100644 index 41e255346a79..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsm_keys_operations.py +++ /dev/null @@ -1,509 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, 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, - 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._managed_hsm_keys_operations import ( - build_create_if_not_exist_request, - build_get_request, - build_get_version_request, - build_list_request, - build_list_versions_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedHsmKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`managed_hsm_keys` 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: KeyVaultManagementClientConfiguration = 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 create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: _models.ManagedHsmKeyCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: 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: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: Union[_models.ManagedHsmKeyCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Is either a - ManagedHsmKeyCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters or IO[bytes] - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsmKeyCreateParameters") - - _request = build_create_if_not_exist_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, name: str, key_name: str, **kwargs: Any) -> _models.ManagedHsmKey: - """Gets the current version of the specified key from the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncItemPaged["_models.ManagedHsmKey"]: - """Lists the keys in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :return: An iterator like instance of either ManagedHsmKey or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] - :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.ManagedHsmKeyListResult] = 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, - name=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("ManagedHsmKeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_version( - self, resource_group_name: str, name: str, key_name: str, key_version: str, **kwargs: Any - ) -> _models.ManagedHsmKey: - """Gets the specified version of the specified key in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param key_version: The version of the key to be retrieved. Required. - :type key_version: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - _request = build_get_version_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_name, - key_version=key_version, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_versions( - self, resource_group_name: str, name: str, key_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedHsmKey"]: - """Lists the versions of the specified key in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :return: An iterator like instance of either ManagedHsmKey or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] - :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.ManagedHsmKeyListResult] = 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_versions_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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("ManagedHsmKeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsms_operations.py deleted file mode 100644 index 4e695971d37c..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_managed_hsms_operations.py +++ /dev/null @@ -1,1115 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - 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._managed_hsms_operations import ( - build_check_mhsm_name_availability_request, - build_create_or_update_request, - build_delete_request, - build_get_deleted_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_deleted_request, - build_purge_deleted_request, - build_update_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedHsmsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`managed_hsms` 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: KeyVaultManagementClientConfiguration = 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") - - async def _create_or_update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsm") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - name=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) - - _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 [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.ManagedHsmError, 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: _models.ManagedHsm, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm - :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 ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Required. - :type parameters: 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 ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Is either a ManagedHsm - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedHsm] = 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._create_or_update_initial( - resource_group_name=resource_group_name, - name=name, - parameters=parameters, - 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): - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ManagedHsm].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedHsm]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsm") - - _request = build_update_request( - resource_group_name=resource_group_name, - name=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) - - _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 [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.ManagedHsmError, 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - name: str, - parameters: _models.ManagedHsm, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm - :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 ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Required. - :type parameters: 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 ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Is either a ManagedHsm type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedHsm or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedHsm] = 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._update_initial( - resource_group_name=resource_group_name, - name=name, - parameters=parameters, - 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): - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ManagedHsm].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedHsm]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, 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, - name=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 [200, 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.ManagedHsmError, 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")) - - 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, name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes the specified managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: The name of the managed HSM Pool to delete. Required. - :type 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, - name=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, **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 - - @distributed_trace_async - async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_models.ManagedHsm]: - """Gets the specified managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: The name of the managed HSM Pool. Required. - :type name: str - :return: ManagedHsm or None or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsm or None - :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[Optional[_models.ManagedHsm]] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedHsm"]: - """The List operation gets information about the managed HSM Pools associated with the - subscription and within the specified resource group. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] - :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.ManagedHsmListResult] = 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_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=top, - 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("ManagedHsmListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.ManagedHsm"]: - """The List operation gets information about the managed HSM Pools associated with the - subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] - :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.ManagedHsmListResult] = 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, - top=top, - 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("ManagedHsmListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_deleted(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedManagedHsm"]: - """The List operation gets information about the deleted managed HSMs associated with the - subscription. - - :return: An iterator like instance of either DeletedManagedHsm or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.DeletedManagedHsm] - :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.DeletedManagedHsmListResult] = 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_deleted_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("DeletedManagedHsmListResult", 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.ManagedHsmError, 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_deleted(self, name: str, location: str, **kwargs: Any) -> _models.DeletedManagedHsm: - """Gets the specified deleted managed HSM. - - :param name: The name of the deleted managed HSM. Required. - :type name: str - :param location: The location of the deleted managed HSM. Required. - :type location: str - :return: DeletedManagedHsm or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.DeletedManagedHsm - :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.DeletedManagedHsm] = kwargs.pop("cls", None) - - _request = build_get_deleted_request( - name=name, - location=location, - 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeletedManagedHsm", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _purge_deleted_initial(self, name: str, location: 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_purge_deleted_request( - name=name, - location=location, - 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]: - 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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_purge_deleted(self, name: str, location: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Permanently deletes the specified managed HSM. - - :param name: The name of the soft-deleted managed HSM. Required. - :type name: str - :param location: The location of the soft-deleted managed HSM. Required. - :type location: 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._purge_deleted_initial( - name=name, - location=location, - 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, **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 check_mhsm_name_availability( - self, - mhsm_name: _models.CheckMhsmNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Required. - :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_mhsm_name_availability( - self, mhsm_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Required. - :type mhsm_name: 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: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_mhsm_name_availability( - self, mhsm_name: Union[_models.CheckMhsmNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Is either a CheckMhsmNameAvailabilityParameters - type or a IO[bytes] type. Required. - :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters or IO[bytes] - :return: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :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.CheckMhsmNameAvailabilityResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(mhsm_name, (IOBase, bytes)): - _content = mhsm_name - else: - _json = self._serialize.body(mhsm_name, "CheckMhsmNameAvailabilityParameters") - - _request = build_check_mhsm_name_availability_request( - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckMhsmNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_endpoint_connections_operations.py deleted file mode 100644 index 0e240fd0a47f..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_endpoint_connections_operations.py +++ /dev/null @@ -1,484 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - 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._mhsm_private_endpoint_connections_operations import ( - build_delete_request, - build_get_request, - build_list_by_resource_request, - build_put_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MHSMPrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`mhsm_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: KeyVaultManagementClientConfiguration = 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_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MHSMPrivateEndpointConnection"]: - """The List operation gets information about the private endpoint connections associated with the - managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: An iterator like instance of either MHSMPrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :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.MHSMPrivateEndpointConnectionsListResult] = 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_resource_request( - resource_group_name=resource_group_name, - name=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("MHSMPrivateEndpointConnectionsListResult", 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.ManagedHsmError, 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, name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :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.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: _models.MHSMPrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: 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: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: Union[_models.MHSMPrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Is either a - MHSMPrivateEndpointConnection type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection or IO[bytes] - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :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.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "MHSMPrivateEndpointConnection") - - _request = build_put_request( - resource_group_name=resource_group_name, - name=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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, resource_group_name: str, 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, - name=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 [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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, name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.MHSMPrivateEndpointConnection]: - """Deletes the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either MHSMPrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :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.MHSMPrivateEndpointConnection] = 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, - name=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): - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.MHSMPrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.MHSMPrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_link_resources_operations.py deleted file mode 100644 index 1c7c1d955059..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_private_link_resources_operations.py +++ /dev/null @@ -1,110 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -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._mhsm_private_link_resources_operations import build_list_by_mhsm_resource_request -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MHSMPrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`mhsm_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: KeyVaultManagementClientConfiguration = 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 list_by_mhsm_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> _models.MHSMPrivateLinkResourceListResult: - """Gets the private link resources supported for the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: MHSMPrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult - :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.MHSMPrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_mhsm_resource_request( - resource_group_name=resource_group_name, - name=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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MHSMPrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_regions_operations.py deleted file mode 100644 index 39fa399ab3e5..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_mhsm_regions_operations.py +++ /dev/null @@ -1,141 +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 collections.abc import MutableMapping -from typing import Any, Callable, 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.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._mhsm_regions_operations import build_list_by_resource_request -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MHSMRegionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`mhsm_regions` 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: KeyVaultManagementClientConfiguration = 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_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.MHSMGeoReplicatedRegion"]: - """The List operation gets information about the regions associated with the managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: An iterator like instance of either MHSMGeoReplicatedRegion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :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.MHSMRegionsListResult] = 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_resource_request( - resource_group_name=resource_group_name, - name=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("MHSMRegionsListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_operations.py index c5598e88c40d..74dd06735b67 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_operations.py @@ -1,12 +1,15 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -17,21 +20,77 @@ 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.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_request +from ...operations._operations import ( + build_keys_create_if_not_exist_request, + build_keys_get_request, + build_keys_get_version_request, + build_keys_list_request, + build_keys_list_versions_request, + build_managed_hsm_keys_create_if_not_exist_request, + build_managed_hsm_keys_get_request, + build_managed_hsm_keys_get_version_request, + build_managed_hsm_keys_list_request, + build_managed_hsm_keys_list_versions_request, + build_managed_hsms_check_mhsm_name_availability_request, + build_managed_hsms_create_or_update_request, + build_managed_hsms_delete_request, + build_managed_hsms_get_deleted_request, + build_managed_hsms_get_request, + build_managed_hsms_list_by_resource_group_request, + build_managed_hsms_list_by_subscription_request, + build_managed_hsms_list_deleted_request, + build_managed_hsms_purge_deleted_request, + build_managed_hsms_update_request, + build_mhsm_private_endpoint_connections_delete_request, + build_mhsm_private_endpoint_connections_get_request, + build_mhsm_private_endpoint_connections_list_by_resource_request, + build_mhsm_private_endpoint_connections_put_request, + build_mhsm_private_link_resources_list_by_mhsm_resource_request, + build_mhsm_regions_list_by_resource_request, + build_operations_list_request, + build_private_endpoint_connections_delete_request, + build_private_endpoint_connections_get_request, + build_private_endpoint_connections_list_by_resource_request, + build_private_endpoint_connections_put_request, + build_private_link_resources_list_by_vault_request, + build_secrets_create_or_update_request, + build_secrets_get_request, + build_secrets_list_request, + build_secrets_update_request, + build_vaults_check_name_availability_request, + build_vaults_create_or_update_request, + build_vaults_delete_request, + build_vaults_get_deleted_request, + build_vaults_get_request, + build_vaults_list_by_resource_group_request, + build_vaults_list_by_subscription_request, + build_vaults_list_deleted_request, + build_vaults_list_request, + build_vaults_purge_deleted_request, + build_vaults_update_access_policy_request, + build_vaults_update_request, +) from .._configuration import KeyVaultManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -45,8 +104,6 @@ class Operations: :attr:`operations` 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") @@ -56,17 +113,16 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: - """Lists all of the available Key Vault Rest API operations. + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -79,12 +135,661 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`vaults` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, **kwargs: Any) -> _models.Vault: + """Gets the specified Azure key 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 name of the vault. Required. + :type vault_name: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Vault] = kwargs.pop("cls", None) + + _request = build_vaults_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Vault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: _models.VaultCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters + :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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: JSON + :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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: 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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Is one of the following types: + VaultCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Vault] = 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._create_or_update_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Vault, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Vault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Vault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + parameters: _models.VaultPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: 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: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultPatchParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Is one of the following types: + VaultPatchParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters or JSON or IO[bytes] + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Vault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Vault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: + """Deletes the specified Azure key 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 name of the vault. Required. + :type vault_name: str + :return: None + :rtype: None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_vaults_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Vault"]: + """The List operation gets information about the vaults associated with the subscription and + within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Vault + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Vault]] = 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_vaults_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -99,16 +804,21 @@ def prepare_request(next_link=None): _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" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Vault], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -121,7 +831,5055 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, *, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.Vault"]: + """The List operation gets information about the vaults associated with the subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Vault + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Vault]] = 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_vaults_list_by_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Vault], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: _models.VaultAccessPolicyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: 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: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: Union[_models.VaultAccessPolicyParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Is one of the following types: + VaultAccessPolicyParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters or JSON or IO[bytes] + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VaultAccessPolicyParameters] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_update_access_policy_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_kind=operation_kind, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VaultAccessPolicyParameters, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models.DeletedVault: + """Gets the deleted Azure key vault. + + :param vault_name: The name of the vault. Required. + :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedVault. The DeletedVault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.DeletedVault + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedVault] = kwargs.pop("cls", None) + + _request = build_vaults_get_deleted_request( + vault_name=vault_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DeletedVault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_deleted_initial(self, vault_name: str, location: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_vaults_purge_deleted_request( + vault_name=vault_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_purge_deleted(self, vault_name: str, location: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + + :param vault_name: The name of the vault. Required. + :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._purge_deleted_initial( + vault_name=vault_name, + location=location, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedVault"]: + """Gets information about the deleted vaults in a subscription. + + :return: An iterator like instance of DeletedVault + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.DeletedVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedVault]] = 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_vaults_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DeletedVault], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.TrackedResource"]: + """The List operation gets information about the vaults associated with the subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of TrackedResource + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.TrackedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( + "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") + ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) + cls: ClsType[List[_models.TrackedResource]] = 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_vaults_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.TrackedResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def check_name_availability( + self, + vault_name: _models.VaultCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, vault_name: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, vault_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: 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: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, vault_name: Union[_models.VaultCheckNameAvailabilityParameters, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Is one of the following types: + VaultCheckNameAvailabilityParameters, JSON, IO[bytes] Required. + :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters or JSON or + IO[bytes] + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(vault_name, (IOBase, bytes)): + _content = vault_name + else: + _content = json.dumps(vault_name, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + """Gets the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or None. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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, 204]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: ~azure.mgmt.keyvault.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. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: 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. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Is one of the following + types: PrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_put_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + 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[_models.PrivateEndpointConnection]: + """Deletes the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = 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, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """The List operation gets information about the private endpoint connections associated with 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 name of the vault. Required. + :type vault_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = 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_private_endpoint_connections_list_by_resource_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedHsmsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`managed_hsms` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, name: str, **kwargs: Any) -> Optional[_models.ManagedHsm]: + """Gets the specified managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: ManagedHsm or None. The ManagedHsm is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsm or None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ManagedHsm]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_get_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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, 204]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsm, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_create_or_update_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: _models.ManagedHsm, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm + :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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: JSON + :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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: 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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Is one of the following + types: ManagedHsm, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsm] = 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._create_or_update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedHsm, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedHsm].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_update_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + name: str, + parameters: _models.ManagedHsm, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm + :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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: JSON + :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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: 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 ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Is one of the following types: + ManagedHsm, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedHsm. The ManagedHsm is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsm] = 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._update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedHsm, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedHsm].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_delete_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + 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, name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the specified managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + name=name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedHsm"]: + """The List operation gets information about the managed HSM Pools associated with the + subscription and within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of ManagedHsm + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsm]] = 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_managed_hsms_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, *, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.ManagedHsm"]: + """The List operation gets information about the managed HSM Pools associated with the + subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of ManagedHsm + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsm]] = 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_managed_hsms_list_by_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + 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_deleted(self, name: str, location: str, **kwargs: Any) -> _models.DeletedManagedHsm: + """Gets the specified deleted managed HSM. + + :param name: The name of the deleted managed HSM. Required. + :type name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedManagedHsm. The DeletedManagedHsm is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.DeletedManagedHsm + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedManagedHsm] = kwargs.pop("cls", None) + + _request = build_managed_hsms_get_deleted_request( + name=name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DeletedManagedHsm, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_deleted_initial(self, name: str, location: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_purge_deleted_request( + name=name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_purge_deleted(self, name: str, location: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Permanently deletes the specified managed HSM. + + :param name: The name of the deleted managed HSM. Required. + :type name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._purge_deleted_initial( + name=name, location=location, 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedManagedHsm"]: + """The List operation gets information about the deleted managed HSMs associated with the + subscription. + + :return: An iterator like instance of DeletedManagedHsm + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.DeletedManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedManagedHsm]] = 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_managed_hsms_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DeletedManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def check_mhsm_name_availability( + self, + mhsm_name: _models.CheckMhsmNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_mhsm_name_availability( + self, mhsm_name: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_mhsm_name_availability( + self, mhsm_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: 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: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_mhsm_name_availability( + self, mhsm_name: Union[_models.CheckMhsmNameAvailabilityParameters, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Is one of the following types: + CheckMhsmNameAvailabilityParameters, JSON, IO[bytes] Required. + :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters or JSON or + IO[bytes] + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckMhsmNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(mhsm_name, (IOBase, bytes)): + _content = mhsm_name + else: + _content = json.dumps(mhsm_name, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_check_mhsm_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.CheckMhsmNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`secrets` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, secret_name: str, **kwargs: Any) -> _models.Secret: + """Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. + Users should use the data-plane REST service for interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + _request = build_secrets_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: _models.SecretCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: 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: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: Union[_models.SecretCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Is one of the following types: + SecretCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters or JSON or + IO[bytes] + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + 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, + secret_name: str, + parameters: _models.SecretPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: 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: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: Union[_models.SecretPatchParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Is one of the following types: + SecretPatchParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters or JSON or IO[bytes] + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Secret"]: + """The List operation gets information about the secrets in a vault. NOTE: This API is intended + for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Secret + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Secret]] = 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_secrets_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Secret], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class KeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`keys` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, key_name: str, **kwargs: Any) -> _models.Key: + """Gets the current version of the specified key from the specified key 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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + _request = build_keys_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: _models.KeyCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: 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: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: Union[_models.KeyCreateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Is one of the following + types: KeyCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters or JSON or IO[bytes] + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_keys_create_if_not_exist_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Key"]: + """Lists the keys in the specified key 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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :return: An iterator like instance of Key + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Key] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Key]] = 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_keys_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Key], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + 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_version( + self, resource_group_name: str, vault_name: str, key_name: str, key_version: str, **kwargs: Any + ) -> _models.Key: + """Gets the specified version of the specified key in the specified key 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 name of the vault which contains the key version to be retrieved. + Required. + :type vault_name: str + :param key_name: The name of the key version to be retrieved. Required. + :type key_name: str + :param key_version: The version of the key to be retrieved. Required. + :type key_version: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + _request = build_keys_get_version_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + key_version=key_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_versions( + self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Key"]: + """Lists the keys in the specified key 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 name of the vault which contains the key version to be retrieved. + Required. + :type vault_name: str + :param key_name: The name of the key version to be retrieved. Required. + :type key_name: str + :return: An iterator like instance of Key + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Key] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Key]] = 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_keys_list_versions_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Key], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedHsmKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`managed_hsm_keys` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, name: str, key_name: str, **kwargs: Any) -> _models.ManagedHsmKey: + """Gets the current version of the specified key from the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + _request = build_managed_hsm_keys_get_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: _models.ManagedHsmKeyCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: 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: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: Union[_models.ManagedHsmKeyCreateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Is one of the following + types: ManagedHsmKeyCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters or JSON or + IO[bytes] + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsm_keys_create_if_not_exist_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncItemPaged["_models.ManagedHsmKey"]: + """Lists the keys in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :return: An iterator like instance of ManagedHsmKey + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsmKey]] = 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_managed_hsm_keys_list_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsmKey], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + 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_version( + self, resource_group_name: str, name: str, key_name: str, key_version: str, **kwargs: Any + ) -> _models.ManagedHsmKey: + """Gets the specified version of the specified key in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param key_version: The version of the key to be retrieved. Required. + :type key_version: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + _request = build_managed_hsm_keys_get_version_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + key_version=key_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_versions( + self, resource_group_name: str, name: str, key_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedHsmKey"]: + """Lists the keys in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :return: An iterator like instance of ManagedHsmKey + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsmKey]] = 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_managed_hsm_keys_list_versions_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsmKey], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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 list_by_vault( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources supported for the key 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 name of the vault. Required. + :type vault_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateLinkResourceListResult + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_link_resources_list_by_vault_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MHSMPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`mhsm_private_link_resources` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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 list_by_mhsm_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> _models.MHSMPrivateLinkResourceListResult: + """Gets the private link resources supported for the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: MHSMPrivateLinkResourceListResult. The MHSMPrivateLinkResourceListResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_mhsm_private_link_resources_list_by_mhsm_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MHSMRegionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`mhsm_regions` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MHSMGeoReplicatedRegion"]: + """The List operation gets information about the regions associated with the managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An iterator like instance of MHSMGeoReplicatedRegion + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.MHSMGeoReplicatedRegion]] = 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_mhsm_regions_list_by_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.MHSMGeoReplicatedRegion], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class MHSMPrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s + :attr:`mhsm_private_endpoint_connections` attribute. + """ + + 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: KeyVaultManagementClientConfiguration = 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, name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_mhsm_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: _models.MHSMPrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: 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: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: Union[_models.MHSMPrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Is one of the following + types: MHSMPrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection or JSON or + IO[bytes] + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_mhsm_private_endpoint_connections_put_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_mhsm_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + 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, name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.MHSMPrivateEndpointConnection]: + """Deletes the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns MHSMPrivateEndpointConnection. The + MHSMPrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateEndpointConnection] = 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, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MHSMPrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MHSMPrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.MHSMPrivateEndpointConnection"]: + """The List operation gets information about the private endpoint connections associated with the + managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An iterator like instance of MHSMPrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.MHSMPrivateEndpointConnection]] = 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_mhsm_private_endpoint_connections_list_by_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.MHSMPrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_patch.py index 3e907c37e646..87676c65a8f0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_patch.py @@ -1,121 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, Optional, List, Literal -import urllib.parse -from collections.abc import MutableMapping -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 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 ._vaults_operations import VaultsOperations as _VaultsOperations, ClsType -from ...operations._vaults_operations import build_list_request - - -class VaultsOperations(_VaultsOperations): - - @distributed_trace - def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.Resource"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Resource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.v2024_11_01.models.Resource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( - "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") - ) - api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) - cls: ClsType[_models.ResourceListResult] = 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( - subscription_id=self._config.subscription_id, - top=top, - filter=filter, - 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"] = 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("ResourceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -__all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 5875e489635b..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,479 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - 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_by_resource_request, - build_put_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'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: KeyVaultManagementClientConfiguration = 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, private_endpoint_connection_name: str, **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - """Gets the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or None or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or None - :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[Optional[_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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: ~azure.mgmt.keyvault.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.keyvault.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: 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.keyvault.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or IO[bytes] - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.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(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "PrivateEndpointConnection") - - _request = build_put_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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # 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 [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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[_models.PrivateEndpointConnection]: - """Deletes the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.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.PrivateEndpointConnection] = 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): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_resource( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: - """The List operation gets information about the private endpoint connections associated with the - vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. 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.keyvault.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_by_resource_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index bcecb2f19819..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,109 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -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._private_link_resources_operations import build_list_by_vault_request -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'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: KeyVaultManagementClientConfiguration = 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 list_by_vault( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources supported for the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.PrivateLinkResourceListResult - :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_vault_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) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_secrets_operations.py deleted file mode 100644 index b44a70659918..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_secrets_operations.py +++ /dev/null @@ -1,507 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, 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, - 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._secrets_operations import ( - build_create_or_update_request, - build_get_request, - build_list_request, - build_update_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SecretsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`secrets` 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: KeyVaultManagementClientConfiguration = 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 create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: _models.SecretCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Required. - :type parameters: 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: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: Union[_models.SecretCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Is either a - SecretCreateOrUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters or IO[bytes] - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SecretCreateOrUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", 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, - secret_name: str, - parameters: _models.SecretPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Required. - :type parameters: 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: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: Union[_models.SecretPatchParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Is either a SecretPatchParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters or IO[bytes] - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SecretPatchParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: - """Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. - Users should use the data-plane REST service for interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param secret_name: The name of the secret. Required. - :type secret_name: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Secret"]: - """The List operation gets information about the secrets in a vault. NOTE: This API is intended - for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Secret or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Secret] - :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.SecretListResult] = 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, - top=top, - 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("SecretListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_vaults_operations.py deleted file mode 100644 index a7c40cb59ceb..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/aio/operations/_vaults_operations.py +++ /dev/null @@ -1,1214 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Literal, 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._vaults_operations import ( - build_check_name_availability_request, - build_create_or_update_request, - build_delete_request, - build_get_deleted_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_list_deleted_request, - build_list_request, - build_purge_deleted_request, - build_update_access_policy_request, - build_update_request, -) -from .._configuration import KeyVaultManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class VaultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.aio.KeyVaultManagementClient`'s - :attr:`vaults` 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: KeyVaultManagementClientConfiguration = 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") - - async def _create_or_update_initial( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultCreateOrUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - vault_name=vault_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) - - _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 [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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: _models.VaultCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters - :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 Vault or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Required. - :type parameters: 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 Vault or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Is either a - VaultCreateOrUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Vault or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.keyvault.models.Vault] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Vault] = 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._create_or_update_initial( - resource_group_name=resource_group_name, - vault_name=vault_name, - parameters=parameters, - 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): - deserialized = self._deserialize("Vault", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Vault].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Vault]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @overload - async def update( - self, - resource_group_name: str, - vault_name: str, - parameters: _models.VaultPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - vault_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Required. - :type parameters: 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: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultPatchParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Is either a VaultPatchParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters or IO[bytes] - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :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.Vault] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultPatchParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - vault_name=vault_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> None: - """Deletes the specified Azure key vault. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault to delete. Required. - :type vault_name: str - :return: None or the result of cls(response) - :rtype: None - :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[None] = kwargs.pop("cls", None) - - _request = build_delete_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) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.Vault: - """Gets the specified Azure key vault. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :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.Vault] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: _models.VaultAccessPolicyParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Required. - :type parameters: 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: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: Union[_models.VaultAccessPolicyParameters, IO[bytes]], - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Is either a - VaultAccessPolicyParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters or IO[bytes] - :return: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :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.VaultAccessPolicyParameters] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultAccessPolicyParameters") - - _request = build_update_access_policy_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - operation_kind=operation_kind, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Vault"]: - """The List operation gets information about the vaults associated with the subscription and - within the specified resource group. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Vault or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Vault] - :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.VaultListResult] = 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_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=top, - 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("VaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.Vault"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Vault or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Vault] - :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.VaultListResult] = 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, - top=top, - 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("VaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_deleted(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedVault"]: - """Gets information about the deleted vaults in a subscription. - - :return: An iterator like instance of either DeletedVault or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.DeletedVault] - :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.DeletedVaultListResult] = 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_deleted_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("DeletedVaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models.DeletedVault: - """Gets the deleted Azure key vault. - - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param location: The location of the deleted vault. Required. - :type location: str - :return: DeletedVault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.DeletedVault - :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.DeletedVault] = kwargs.pop("cls", None) - - _request = build_get_deleted_request( - vault_name=vault_name, - location=location, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeletedVault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _purge_deleted_initial(self, vault_name: str, location: 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_purge_deleted_request( - vault_name=vault_name, - location=location, - 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 [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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_purge_deleted(self, vault_name: str, location: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. - - :param vault_name: The name of the soft-deleted vault. Required. - :type vault_name: str - :param location: The location of the soft-deleted vault. Required. - :type location: 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._purge_deleted_initial( - vault_name=vault_name, - location=location, - 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, **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 - - @distributed_trace - def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.Resource"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Resource or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.keyvault.models.Resource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( - "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") - ) - api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) - cls: ClsType[_models.ResourceListResult] = 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( - subscription_id=self._config.subscription_id, - top=top, - filter=filter, - 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("ResourceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def check_name_availability( - self, - vault_name: _models.VaultCheckNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Required. - :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, vault_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Required. - :type vault_name: 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: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, vault_name: Union[_models.VaultCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Is either a VaultCheckNameAvailabilityParameters type - or a IO[bytes] type. Required. - :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters or IO[bytes] - :return: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :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.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vault_name, (IOBase, bytes)): - _content = vault_name - else: - _json = self._serialize.body(vault_name, "VaultCheckNameAvailabilityParameters") - - _request = build_check_name_availability_request( - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/__init__.py index 5b57250a3406..0e7b087fadf1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,19 +13,18 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore AccessPolicyEntry, Action, Attributes, CheckMhsmNameAvailabilityParameters, CheckMhsmNameAvailabilityResult, CheckNameAvailabilityResult, + CloudError, CloudErrorBody, DeletedManagedHsm, - DeletedManagedHsmListResult, DeletedManagedHsmProperties, DeletedVault, - DeletedVaultListResult, DeletedVaultProperties, DimensionProperties, Error, @@ -33,7 +32,6 @@ Key, KeyAttributes, KeyCreateParameters, - KeyListResult, KeyProperties, KeyReleasePolicy, KeyRotationPolicyAttributes, @@ -45,11 +43,11 @@ MHSMPrivateEndpoint, MHSMPrivateEndpointConnection, MHSMPrivateEndpointConnectionItem, - MHSMPrivateEndpointConnectionsListResult, + MHSMPrivateEndpointConnectionProperties, MHSMPrivateLinkResource, MHSMPrivateLinkResourceListResult, + MHSMPrivateLinkResourceProperties, MHSMPrivateLinkServiceConnectionState, - MHSMRegionsListResult, MHSMServiceTagRule, MHSMVirtualNetworkRule, ManagedHSMSecurityDomainProperties, @@ -59,12 +57,10 @@ ManagedHsmKey, ManagedHsmKeyAttributes, ManagedHsmKeyCreateParameters, - ManagedHsmKeyListResult, ManagedHsmKeyProperties, ManagedHsmKeyReleasePolicy, ManagedHsmKeyRotationPolicyAttributes, ManagedHsmLifetimeAction, - ManagedHsmListResult, ManagedHsmProperties, ManagedHsmResource, ManagedHsmRotationPolicy, @@ -75,29 +71,29 @@ NetworkRuleSet, Operation, OperationDisplay, - OperationListResult, + OperationProperties, Permissions, PrivateEndpoint, PrivateEndpointConnection, PrivateEndpointConnectionItem, - PrivateEndpointConnectionListResult, + PrivateEndpointConnectionProperties, PrivateLinkResource, PrivateLinkResourceListResult, + PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, - ProxyResourceWithoutSystemData, + ProxyResource, Resource, - ResourceListResult, RotationPolicy, Secret, SecretAttributes, SecretCreateOrUpdateParameters, - SecretListResult, SecretPatchParameters, SecretPatchProperties, SecretProperties, ServiceSpecification, Sku, SystemData, + TrackedResource, Trigger, UserAssignedIdentity, Vault, @@ -105,14 +101,13 @@ VaultAccessPolicyProperties, VaultCheckNameAvailabilityParameters, VaultCreateOrUpdateParameters, - VaultListResult, VaultPatchParameters, VaultPatchProperties, VaultProperties, VirtualNetworkRule, ) -from ._key_vault_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AccessPolicyUpdateKind, ActionsRequired, ActivationStatus, @@ -153,12 +148,11 @@ "CheckMhsmNameAvailabilityParameters", "CheckMhsmNameAvailabilityResult", "CheckNameAvailabilityResult", + "CloudError", "CloudErrorBody", "DeletedManagedHsm", - "DeletedManagedHsmListResult", "DeletedManagedHsmProperties", "DeletedVault", - "DeletedVaultListResult", "DeletedVaultProperties", "DimensionProperties", "Error", @@ -166,7 +160,6 @@ "Key", "KeyAttributes", "KeyCreateParameters", - "KeyListResult", "KeyProperties", "KeyReleasePolicy", "KeyRotationPolicyAttributes", @@ -178,11 +171,11 @@ "MHSMPrivateEndpoint", "MHSMPrivateEndpointConnection", "MHSMPrivateEndpointConnectionItem", - "MHSMPrivateEndpointConnectionsListResult", + "MHSMPrivateEndpointConnectionProperties", "MHSMPrivateLinkResource", "MHSMPrivateLinkResourceListResult", + "MHSMPrivateLinkResourceProperties", "MHSMPrivateLinkServiceConnectionState", - "MHSMRegionsListResult", "MHSMServiceTagRule", "MHSMVirtualNetworkRule", "ManagedHSMSecurityDomainProperties", @@ -192,12 +185,10 @@ "ManagedHsmKey", "ManagedHsmKeyAttributes", "ManagedHsmKeyCreateParameters", - "ManagedHsmKeyListResult", "ManagedHsmKeyProperties", "ManagedHsmKeyReleasePolicy", "ManagedHsmKeyRotationPolicyAttributes", "ManagedHsmLifetimeAction", - "ManagedHsmListResult", "ManagedHsmProperties", "ManagedHsmResource", "ManagedHsmRotationPolicy", @@ -208,29 +199,29 @@ "NetworkRuleSet", "Operation", "OperationDisplay", - "OperationListResult", + "OperationProperties", "Permissions", "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionItem", - "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionProperties", "PrivateLinkResource", "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", - "ProxyResourceWithoutSystemData", + "ProxyResource", "Resource", - "ResourceListResult", "RotationPolicy", "Secret", "SecretAttributes", "SecretCreateOrUpdateParameters", - "SecretListResult", "SecretPatchParameters", "SecretPatchProperties", "SecretProperties", "ServiceSpecification", "Sku", "SystemData", + "TrackedResource", "Trigger", "UserAssignedIdentity", "Vault", @@ -238,7 +229,6 @@ "VaultAccessPolicyProperties", "VaultCheckNameAvailabilityParameters", "VaultCreateOrUpdateParameters", - "VaultListResult", "VaultPatchParameters", "VaultPatchProperties", "VaultProperties", diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_key_vault_management_client_enums.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_enums.py similarity index 93% rename from sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_key_vault_management_client_enums.py rename to sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_enums.py index 37c7908f43d1..2a21c3638735 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_key_vault_management_client_enums.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -11,7 +11,7 @@ class AccessPolicyUpdateKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessPolicyUpdateKind.""" + """Type of AccessPolicyUpdateKind.""" ADD = "add" REPLACE = "replace" @@ -38,7 +38,7 @@ class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): class CertificatePermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CertificatePermissions.""" + """Type of CertificatePermissions.""" ALL = "all" GET = "get" @@ -57,7 +57,6 @@ class CertificatePermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): PURGE = "purge" BACKUP = "backup" RESTORE = "restore" - IMPORT_ENUM = "import" class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -91,12 +90,16 @@ class GeoReplicationRegionProvisioningState(str, Enum, metaclass=CaseInsensitive class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class JsonWebKeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -123,7 +126,6 @@ class JsonWebKeyOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): UNWRAP_KEY = "unwrapKey" IMPORT = "import" RELEASE = "release" - IMPORT_ENUM = "import" class JsonWebKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -136,7 +138,7 @@ class JsonWebKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class KeyPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyPermissions.""" + """Type of KeyPermissions.""" ALL = "all" ENCRYPT = "encrypt" @@ -159,7 +161,6 @@ class KeyPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): ROTATE = "rotate" GETROTATIONPOLICY = "getrotationpolicy" SETROTATIONPOLICY = "setrotationpolicy" - IMPORT_ENUM = "import" class KeyRotationPolicyActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -192,9 +193,13 @@ class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NONE = "None" + """No managed identity.""" SYSTEM_ASSIGNED = "SystemAssigned" + """System assigned managed identity.""" USER_ASSIGNED = "UserAssigned" + """User assigned managed identity.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + """System and user assigned managed identity.""" class NetworkRuleAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -273,7 +278,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SecretPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SecretPermissions.""" + """Type of SecretPermissions.""" ALL = "all" GET = "get" @@ -300,7 +305,7 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): class StoragePermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """StoragePermissions.""" + """Type of StoragePermissions.""" ALL = "all" GET = "get" diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models.py new file mode 100644 index 000000000000..921a943cc7c9 --- /dev/null +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models.py @@ -0,0 +1,4291 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AccessPolicyEntry(_Model): + """An identity that have access to the key vault. All identities in the array must use the same + tenant ID as the key vault's tenant ID. + + :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating + requests to the key vault. Required. + :vartype tenant_id: str + :ivar object_id: The object ID of a user, service principal or security group in the Azure + Active Directory tenant for the vault. The object ID must be unique for the list of access + policies. Required. + :vartype object_id: str + :ivar application_id: Application ID of the client making request on behalf of a principal. + :vartype application_id: str + :ivar permissions: Permissions the identity has for keys, secrets and certificates. Required. + :vartype permissions: ~azure.mgmt.keyvault.models.Permissions + """ + + tenant_id: str = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The Azure Active Directory tenant ID that should be used for authenticating requests to the key + vault. Required.""" + object_id: str = rest_field(name="objectId", visibility=["read", "create", "update", "delete", "query"]) + """The object ID of a user, service principal or security group in the Azure Active Directory + tenant for the vault. The object ID must be unique for the list of access policies. Required.""" + application_id: Optional[str] = rest_field( + name="applicationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Application ID of the client making request on behalf of a principal.""" + permissions: "_models.Permissions" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Permissions the identity has for keys, secrets and certificates. Required.""" + + @overload + def __init__( + self, + *, + tenant_id: str, + object_id: str, + permissions: "_models.Permissions", + application_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Action(_Model): + """Action. + + :ivar type: The type of action. Known values are: "rotate" and "notify". + :vartype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType + """ + + type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of action. Known values are: \"rotate\" and \"notify\".""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Attributes(_Model): + """The object attributes managed by the KeyVault service. + + :ivar enabled: Determines whether the object is enabled. + :vartype enabled: bool + :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. + :vartype not_before: ~datetime.datetime + :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. + :vartype expires: ~datetime.datetime + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: ~datetime.datetime + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: ~datetime.datetime + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether the object is enabled.""" + not_before: Optional[datetime.datetime] = rest_field( + name="nbf", visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """Not before date in seconds since 1970-01-01T00:00:00Z.""" + expires: Optional[datetime.datetime] = rest_field( + name="exp", visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """Expiry date in seconds since 1970-01-01T00:00:00Z.""" + created: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """Creation time in seconds since 1970-01-01T00:00:00Z.""" + updated: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """Last updated time in seconds since 1970-01-01T00:00:00Z.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + not_before: Optional[datetime.datetime] = None, + expires: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckMhsmNameAvailabilityParameters(_Model): + """The parameters used to check the availability of the managed hsm name. + + :ivar name: The managed hsm name. Required. + :vartype name: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The managed hsm name. Required.""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckMhsmNameAvailabilityResult(_Model): + """The CheckMhsmNameAvailability operation response. + + :ivar name_available: A boolean value that indicates whether the name is available for you to + use. If true, the name is available. If false, the name has already been taken or is invalid + and cannot be used. + :vartype name_available: bool + :ivar reason: The reason that a managed hsm name could not be used. The reason element is only + returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". + :vartype reason: str or ~azure.mgmt.keyvault.models.Reason + :ivar message: An error message explaining the Reason value in more detail. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """A boolean value that indicates whether the name is available for you to use. If true, the name + is available. If false, the name has already been taken or is invalid and cannot be used.""" + reason: Optional[Union[str, "_models.Reason"]] = rest_field(visibility=["read"]) + """The reason that a managed hsm name could not be used. The reason element is only returned if + NameAvailable is false. Known values are: \"AccountNameInvalid\" and \"AlreadyExists\".""" + message: Optional[str] = rest_field(visibility=["read"]) + """An error message explaining the Reason value in more detail.""" + + +class CheckNameAvailabilityResult(_Model): + """The CheckNameAvailability operation response. + + :ivar name_available: A boolean value that indicates whether the name is available for you to + use. If true, the name is available. If false, the name has already been taken or is invalid + and cannot be used. + :vartype name_available: bool + :ivar reason: The reason that a vault name could not be used. The Reason element is only + returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". + :vartype reason: str or ~azure.mgmt.keyvault.models.Reason + :ivar message: An error message explaining the Reason value in more detail. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """A boolean value that indicates whether the name is available for you to use. If true, the name + is available. If false, the name has already been taken or is invalid and cannot be used.""" + reason: Optional[Union[str, "_models.Reason"]] = rest_field(visibility=["read"]) + """The reason that a vault name could not be used. The Reason element is only returned if + NameAvailable is false. Known values are: \"AccountNameInvalid\" and \"AlreadyExists\".""" + message: Optional[str] = rest_field(visibility=["read"]) + """An error message explaining the Reason value in more detail.""" + + +class CloudError(_Model): + """An error response from Key Vault resource provider. + + :ivar error: An error response from Key Vault resource provider. + :vartype error: ~azure.mgmt.keyvault.models.CloudErrorBody + """ + + error: Optional["_models.CloudErrorBody"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An error response from Key Vault resource provider.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.CloudErrorBody"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CloudErrorBody(_Model): + """An error response from Key Vault resource provider. + + :ivar code: Error code. This is a mnemonic that can be consumed programmatically. + :vartype code: str + :ivar message: User friendly error message. The message is typically localized and may vary + with service version. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error code. This is a mnemonic that can be consumed programmatically.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User friendly error message. The message is typically localized and may vary with service + version.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + """ + + +class DeletedManagedHsm(ProxyResource): + """Concrete proxy resource types can be created by aliasing this type using a specific property + type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Properties of the deleted managed HSM. + :vartype properties: ~azure.mgmt.keyvault.models.DeletedManagedHsmProperties + """ + + properties: Optional["_models.DeletedManagedHsmProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the deleted managed HSM.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeletedManagedHsmProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeletedManagedHsmProperties(_Model): + """Properties of the deleted managed HSM. + + :ivar mhsm_id: The resource id of the original managed HSM. + :vartype mhsm_id: str + :ivar location: The location of the original managed HSM. + :vartype location: str + :ivar deletion_date: The deleted date. + :vartype deletion_date: ~datetime.datetime + :ivar scheduled_purge_date: The scheduled purged date. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar purge_protection_enabled: Purge protection status of the original managed HSM. + :vartype purge_protection_enabled: bool + :ivar tags: Tags of the original managed HSM. + :vartype tags: dict[str, str] + """ + + mhsm_id: Optional[str] = rest_field(name="mhsmId", visibility=["read"]) + """The resource id of the original managed HSM.""" + location: Optional[str] = rest_field(visibility=["read"]) + """The location of the original managed HSM.""" + deletion_date: Optional[datetime.datetime] = rest_field(name="deletionDate", visibility=["read"], format="rfc3339") + """The deleted date.""" + scheduled_purge_date: Optional[datetime.datetime] = rest_field( + name="scheduledPurgeDate", visibility=["read"], format="rfc3339" + ) + """The scheduled purged date.""" + purge_protection_enabled: Optional[bool] = rest_field(name="purgeProtectionEnabled", visibility=["read"]) + """Purge protection status of the original managed HSM.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Tags of the original managed HSM.""" + + +class DeletedVault(ProxyResource): + """Deleted vault information with extended details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Properties of the vault. + :vartype properties: ~azure.mgmt.keyvault.models.DeletedVaultProperties + """ + + properties: Optional["_models.DeletedVaultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the vault.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeletedVaultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeletedVaultProperties(_Model): + """Properties of the deleted vault. + + :ivar vault_id: The resource id of the original vault. + :vartype vault_id: str + :ivar location: The location of the original vault. + :vartype location: str + :ivar deletion_date: The deleted date. + :vartype deletion_date: ~datetime.datetime + :ivar scheduled_purge_date: The scheduled purged date. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar tags: Tags of the original vault. + :vartype tags: dict[str, str] + :ivar purge_protection_enabled: Purge protection status of the original vault. + :vartype purge_protection_enabled: bool + """ + + vault_id: Optional[str] = rest_field(name="vaultId", visibility=["read"]) + """The resource id of the original vault.""" + location: Optional[str] = rest_field(visibility=["read"]) + """The location of the original vault.""" + deletion_date: Optional[datetime.datetime] = rest_field(name="deletionDate", visibility=["read"], format="rfc3339") + """The deleted date.""" + scheduled_purge_date: Optional[datetime.datetime] = rest_field( + name="scheduledPurgeDate", visibility=["read"], format="rfc3339" + ) + """The scheduled purged date.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Tags of the original vault.""" + purge_protection_enabled: Optional[bool] = rest_field(name="purgeProtectionEnabled", visibility=["read"]) + """Purge protection status of the original vault.""" + + +class DimensionProperties(_Model): + """Type of operation: get, read, delete, etc. + + :ivar name: Name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Property to specify whether the dimension should be exported + for Shoebox. + :vartype to_be_exported_for_shoebox: bool + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of dimension.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of dimension.""" + to_be_exported_for_shoebox: Optional[bool] = rest_field( + name="toBeExportedForShoebox", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the dimension should be exported for Shoebox.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Error(_Model): + """The server error. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar inner_error: The inner error, contains a more specific error code. + :vartype inner_error: ~azure.mgmt.keyvault.models.Error + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + inner_error: Optional["_models.Error"] = rest_field(name="innererror", visibility=["read"]) + """The inner error, contains a more specific error code.""" + + +class IPRule(_Model): + """A rule governing the accessibility of a vault from a specific ip address or ip range. + + :ivar value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) + or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. + :vartype value: str + """ + + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) or + '124.56.78.0/24' (all addresses that start with 124.56.78). Required.""" + + @overload + def __init__( + self, + *, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Key(ProxyResource): + """The key resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: The properties of the key. Required. + :vartype properties: ~azure.mgmt.keyvault.models.KeyProperties + :ivar location: The supported Azure location where the managed HSM Pool should be created. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: "_models.KeyProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the key. Required.""" + location: Optional[str] = rest_field(visibility=["read"]) + """The supported Azure location where the managed HSM Pool should be created.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Resource tags.""" + + __flattened_items = [ + "attributes", + "kty", + "key_ops", + "key_size", + "curve_name", + "key_uri", + "key_uri_with_version", + "rotation_policy", + "release_policy", + ] + + @overload + def __init__( + self, + *, + properties: "_models.KeyProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class KeyAttributes(_Model): + """The object attributes managed by the Azure Key Vault service. + + :ivar enabled: Determines whether or not the object is enabled. + :vartype enabled: bool + :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. + :vartype not_before: int + :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. + :vartype expires: int + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: int + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: int + :ivar recovery_level: The deletion recovery level currently in effect for the object. If it + contains 'Purgeable', then the object can be permanently deleted by a privileged user; + otherwise, only the system can purge the object at the end of the retention interval. Known + values are: "Purgeable", "Recoverable+Purgeable", "Recoverable", and + "Recoverable+ProtectedSubscription". + :vartype recovery_level: str or ~azure.mgmt.keyvault.models.DeletionRecoveryLevel + :ivar exportable: Indicates if the private key can be exported. + :vartype exportable: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether or not the object is enabled.""" + not_before: Optional[int] = rest_field(name="nbf", visibility=["read", "create", "update", "delete", "query"]) + """Not before date in seconds since 1970-01-01T00:00:00Z.""" + expires: Optional[int] = rest_field(name="exp", visibility=["read", "create", "update", "delete", "query"]) + """Expiry date in seconds since 1970-01-01T00:00:00Z.""" + created: Optional[int] = rest_field(visibility=["read"]) + """Creation time in seconds since 1970-01-01T00:00:00Z.""" + updated: Optional[int] = rest_field(visibility=["read"]) + """Last updated time in seconds since 1970-01-01T00:00:00Z.""" + recovery_level: Optional[Union[str, "_models.DeletionRecoveryLevel"]] = rest_field( + name="recoveryLevel", visibility=["read"] + ) + """The deletion recovery level currently in effect for the object. If it contains 'Purgeable', + then the object can be permanently deleted by a privileged user; otherwise, only the system can + purge the object at the end of the retention interval. Known values are: \"Purgeable\", + \"Recoverable+Purgeable\", \"Recoverable\", and \"Recoverable+ProtectedSubscription\".""" + exportable: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Indicates if the private key can be exported.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + not_before: Optional[int] = None, + expires: Optional[int] = None, + exportable: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyCreateParameters(_Model): + """The parameters used to create a key. + + :ivar tags: The tags that will be assigned to the key. + :vartype tags: dict[str, str] + :ivar properties: The properties of the key to be created. Required. + :vartype properties: ~azure.mgmt.keyvault.models.KeyProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the key.""" + properties: "_models.KeyProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the key to be created. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.KeyProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyProperties(_Model): + """The properties of the key. + + :ivar attributes: The attributes of the key. + :vartype attributes: ~azure.mgmt.keyvault.models.KeyAttributes + :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", + "EC-HSM", "RSA", and "RSA-HSM". + :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType + :ivar key_ops: + :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] + :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA + and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys + default to 4096. + :vartype key_size: int + :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default + for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". + :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName + :ivar key_uri: The URI to retrieve the current version of the key. + :vartype key_uri: str + :ivar key_uri_with_version: The URI to retrieve the specific version of the key. + :vartype key_uri_with_version: str + :ivar rotation_policy: Key rotation policy in response. It will be used for both output and + input. Omitted if empty. + :vartype rotation_policy: ~azure.mgmt.keyvault.models.RotationPolicy + :ivar release_policy: Key release policy in response. It will be used for both output and + input. Omitted if empty. + :vartype release_policy: ~azure.mgmt.keyvault.models.KeyReleasePolicy + """ + + attributes: Optional["_models.KeyAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of the key.""" + kty: Optional[Union[str, "_models.JsonWebKeyType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of the key. For valid values, see JsonWebKeyType. Known values are: \"EC\", + \"EC-HSM\", \"RSA\", and \"RSA-HSM\".""" + key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = rest_field( + name="keyOps", visibility=["read", "create", "update", "delete", "query"] + ) + key_size: Optional[int] = rest_field(name="keySize", visibility=["read", "create", "update", "delete", "query"]) + """The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA and RSA-HSM + keys is 2048. Exception made for bring your own key (BYOK), key exchange keys default to 4096.""" + curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = rest_field( + name="curveName", visibility=["read", "create", "update", "delete", "query"] + ) + """The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default for EC and EC-HSM + keys is P-256. Known values are: \"P-256\", \"P-384\", \"P-521\", and \"P-256K\".""" + key_uri: Optional[str] = rest_field(name="keyUri", visibility=["read"]) + """The URI to retrieve the current version of the key.""" + key_uri_with_version: Optional[str] = rest_field(name="keyUriWithVersion", visibility=["read"]) + """The URI to retrieve the specific version of the key.""" + rotation_policy: Optional["_models.RotationPolicy"] = rest_field( + name="rotationPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Key rotation policy in response. It will be used for both output and input. Omitted if empty.""" + release_policy: Optional["_models.KeyReleasePolicy"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Key release policy in response. It will be used for both output and input. Omitted if empty.""" + + @overload + def __init__( + self, + *, + attributes: Optional["_models.KeyAttributes"] = None, + kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, + key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, + key_size: Optional[int] = None, + curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, + rotation_policy: Optional["_models.RotationPolicy"] = None, + release_policy: Optional["_models.KeyReleasePolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyReleasePolicy(_Model): + """KeyReleasePolicy. + + :ivar content_type: Content type and version of key release policy. + :vartype content_type: str + :ivar data: Blob encoding the policy rules under which the key can be released. + :vartype data: bytes + """ + + content_type: Optional[str] = rest_field( + name="contentType", visibility=["read", "create", "update", "delete", "query"] + ) + """Content type and version of key release policy.""" + data: Optional[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") + """Blob encoding the policy rules under which the key can be released.""" + + @overload + def __init__( + self, + *, + content_type: Optional[str] = None, + data: Optional[bytes] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyRotationPolicyAttributes(_Model): + """KeyRotationPolicyAttributes. + + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: int + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: int + :ivar expiry_time: The expiration time for the new key version. It should be in ISO8601 format. + Eg: 'P90D', 'P1Y'. + :vartype expiry_time: str + """ + + created: Optional[int] = rest_field(visibility=["read"]) + """Creation time in seconds since 1970-01-01T00:00:00Z.""" + updated: Optional[int] = rest_field(visibility=["read"]) + """Last updated time in seconds since 1970-01-01T00:00:00Z.""" + expiry_time: Optional[str] = rest_field( + name="expiryTime", visibility=["read", "create", "update", "delete", "query"] + ) + """The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'.""" + + @overload + def __init__( + self, + *, + expiry_time: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LifetimeAction(_Model): + """LifetimeAction. + + :ivar trigger: The trigger of key rotation policy lifetimeAction. + :vartype trigger: ~azure.mgmt.keyvault.models.Trigger + :ivar action: The action of key rotation policy lifetimeAction. + :vartype action: ~azure.mgmt.keyvault.models.Action + """ + + trigger: Optional["_models.Trigger"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The trigger of key rotation policy lifetimeAction.""" + action: Optional["_models.Action"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The action of key rotation policy lifetimeAction.""" + + @overload + def __init__( + self, + *, + trigger: Optional["_models.Trigger"] = None, + action: Optional["_models.Action"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LogSpecification(_Model): + """Log specification of operation. + + :ivar name: Name of log specification. + :vartype name: str + :ivar display_name: Display name of log specification. + :vartype display_name: str + :ivar blob_duration: Blob duration of specification. + :vartype blob_duration: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of log specification.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of log specification.""" + blob_duration: Optional[str] = rest_field( + name="blobDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """Blob duration of specification.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsm(Resource): + """Resource information with extended details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Properties of the managed HSM. + :vartype properties: ~azure.mgmt.keyvault.models.ManagedHsmProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku + :ivar identity: Managed service identity. + :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity + """ + + properties: Optional["_models.ManagedHsmProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the managed HSM.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives.""" + sku: Optional["_models.ManagedHsmSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU details.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedHsmProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + sku: Optional["_models.ManagedHsmSku"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmAction(_Model): + """ManagedHsmAction. + + :ivar type: The type of action. Known values are: "rotate" and "notify". + :vartype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType + """ + + type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of action. Known values are: \"rotate\" and \"notify\".""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmError(_Model): + """The error exception. + + :ivar error: The server error. + :vartype error: ~azure.mgmt.keyvault.models.Error + """ + + error: Optional["_models.Error"] = rest_field(visibility=["read"]) + """The server error.""" + + +class ManagedHsmKey(ProxyResource): + """The key resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: The properties of the key. Required. + :vartype properties: ~azure.mgmt.keyvault.models.ManagedHsmKeyProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: "_models.ManagedHsmKeyProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the key. Required.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + __flattened_items = [ + "attributes", + "kty", + "key_ops", + "key_size", + "curve_name", + "key_uri", + "key_uri_with_version", + "rotation_policy", + "release_policy", + ] + + @overload + def __init__( + self, + *, + properties: "_models.ManagedHsmKeyProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedHsmKeyAttributes(_Model): + """The object attributes managed by the Azure Key Vault service. + + :ivar enabled: Determines whether or not the object is enabled. + :vartype enabled: bool + :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. + :vartype not_before: int + :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. + :vartype expires: int + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: int + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: int + :ivar recovery_level: The deletion recovery level currently in effect for the object. If it + contains 'Purgeable', then the object can be permanently deleted by a privileged user; + otherwise, only the system can purge the object at the end of the retention interval. Known + values are: "Purgeable", "Recoverable+Purgeable", "Recoverable", and + "Recoverable+ProtectedSubscription". + :vartype recovery_level: str or ~azure.mgmt.keyvault.models.DeletionRecoveryLevel + :ivar exportable: Indicates if the private key can be exported. + :vartype exportable: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether or not the object is enabled.""" + not_before: Optional[int] = rest_field(name="nbf", visibility=["read", "create", "update", "delete", "query"]) + """Not before date in seconds since 1970-01-01T00:00:00Z.""" + expires: Optional[int] = rest_field(name="exp", visibility=["read", "create", "update", "delete", "query"]) + """Expiry date in seconds since 1970-01-01T00:00:00Z.""" + created: Optional[int] = rest_field(visibility=["read"]) + """Creation time in seconds since 1970-01-01T00:00:00Z.""" + updated: Optional[int] = rest_field(visibility=["read"]) + """Last updated time in seconds since 1970-01-01T00:00:00Z.""" + recovery_level: Optional[Union[str, "_models.DeletionRecoveryLevel"]] = rest_field( + name="recoveryLevel", visibility=["read"] + ) + """The deletion recovery level currently in effect for the object. If it contains 'Purgeable', + then the object can be permanently deleted by a privileged user; otherwise, only the system can + purge the object at the end of the retention interval. Known values are: \"Purgeable\", + \"Recoverable+Purgeable\", \"Recoverable\", and \"Recoverable+ProtectedSubscription\".""" + exportable: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Indicates if the private key can be exported.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + not_before: Optional[int] = None, + expires: Optional[int] = None, + exportable: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmKeyCreateParameters(_Model): + """The parameters used to create a key. + + :ivar tags: The tags that will be assigned to the key. + :vartype tags: dict[str, str] + :ivar properties: The properties of the key to be created. Required. + :vartype properties: ~azure.mgmt.keyvault.models.ManagedHsmKeyProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the key.""" + properties: "_models.ManagedHsmKeyProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the key to be created. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.ManagedHsmKeyProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmKeyProperties(_Model): + """The properties of the key. + + :ivar attributes: The attributes of the key. + :vartype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyAttributes + :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", + "EC-HSM", "RSA", and "RSA-HSM". + :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType + :ivar key_ops: + :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] + :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA + and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys + default to 4096. + :vartype key_size: int + :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default + for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". + :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName + :ivar key_uri: The URI to retrieve the current version of the key. + :vartype key_uri: str + :ivar key_uri_with_version: The URI to retrieve the specific version of the key. + :vartype key_uri_with_version: str + :ivar rotation_policy: Key rotation policy in response. It will be used for both output and + input. Omitted if empty. + :vartype rotation_policy: ~azure.mgmt.keyvault.models.ManagedHsmRotationPolicy + :ivar release_policy: Key release policy in response. It will be used for both output and + input. Omitted if empty. + :vartype release_policy: ~azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy + """ + + attributes: Optional["_models.ManagedHsmKeyAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of the key.""" + kty: Optional[Union[str, "_models.JsonWebKeyType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of the key. For valid values, see JsonWebKeyType. Known values are: \"EC\", + \"EC-HSM\", \"RSA\", and \"RSA-HSM\".""" + key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = rest_field( + name="keyOps", visibility=["read", "create", "update", "delete", "query"] + ) + key_size: Optional[int] = rest_field(name="keySize", visibility=["read", "create", "update", "delete", "query"]) + """The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA and RSA-HSM + keys is 2048. Exception made for bring your own key (BYOK), key exchange keys default to 4096.""" + curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = rest_field( + name="curveName", visibility=["read", "create", "update", "delete", "query"] + ) + """The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default for EC and EC-HSM + keys is P-256. Known values are: \"P-256\", \"P-384\", \"P-521\", and \"P-256K\".""" + key_uri: Optional[str] = rest_field(name="keyUri", visibility=["read"]) + """The URI to retrieve the current version of the key.""" + key_uri_with_version: Optional[str] = rest_field(name="keyUriWithVersion", visibility=["read"]) + """The URI to retrieve the specific version of the key.""" + rotation_policy: Optional["_models.ManagedHsmRotationPolicy"] = rest_field( + name="rotationPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Key rotation policy in response. It will be used for both output and input. Omitted if empty.""" + release_policy: Optional["_models.ManagedHsmKeyReleasePolicy"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Key release policy in response. It will be used for both output and input. Omitted if empty.""" + + @overload + def __init__( + self, + *, + attributes: Optional["_models.ManagedHsmKeyAttributes"] = None, + kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, + key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, + key_size: Optional[int] = None, + curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, + rotation_policy: Optional["_models.ManagedHsmRotationPolicy"] = None, + release_policy: Optional["_models.ManagedHsmKeyReleasePolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmKeyReleasePolicy(_Model): + """ManagedHsmKeyReleasePolicy. + + :ivar content_type: Content type and version of key release policy. + :vartype content_type: str + :ivar data: Blob encoding the policy rules under which the key can be released. + :vartype data: bytes + """ + + content_type: Optional[str] = rest_field( + name="contentType", visibility=["read", "create", "update", "delete", "query"] + ) + """Content type and version of key release policy.""" + data: Optional[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") + """Blob encoding the policy rules under which the key can be released.""" + + @overload + def __init__( + self, + *, + content_type: Optional[str] = None, + data: Optional[bytes] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmKeyRotationPolicyAttributes(_Model): + """ManagedHsmKeyRotationPolicyAttributes. + + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: int + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: int + :ivar expiry_time: The expiration time for the new key version. It should be in ISO8601 format. + Eg: 'P90D', 'P1Y'. + :vartype expiry_time: str + """ + + created: Optional[int] = rest_field(visibility=["read"]) + """Creation time in seconds since 1970-01-01T00:00:00Z.""" + updated: Optional[int] = rest_field(visibility=["read"]) + """Last updated time in seconds since 1970-01-01T00:00:00Z.""" + expiry_time: Optional[str] = rest_field( + name="expiryTime", visibility=["read", "create", "update", "delete", "query"] + ) + """The expiration time for the new key version. It should be in ISO8601 format. Eg: 'P90D', 'P1Y'.""" + + @overload + def __init__( + self, + *, + expiry_time: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmLifetimeAction(_Model): + """ManagedHsmLifetimeAction. + + :ivar trigger: The trigger of key rotation policy lifetimeAction. + :vartype trigger: ~azure.mgmt.keyvault.models.ManagedHsmTrigger + :ivar action: The action of key rotation policy lifetimeAction. + :vartype action: ~azure.mgmt.keyvault.models.ManagedHsmAction + """ + + trigger: Optional["_models.ManagedHsmTrigger"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The trigger of key rotation policy lifetimeAction.""" + action: Optional["_models.ManagedHsmAction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The action of key rotation policy lifetimeAction.""" + + @overload + def __init__( + self, + *, + trigger: Optional["_models.ManagedHsmTrigger"] = None, + action: Optional["_models.ManagedHsmAction"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmProperties(_Model): + """Properties of the managed HSM Pool. + + :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating + requests to the managed HSM pool. + :vartype tenant_id: str + :ivar initial_admin_object_ids: Array of initial administrators object ids for this managed hsm + pool. + :vartype initial_admin_object_ids: list[str] + :ivar hsm_uri: The URI of the managed hsm pool for performing operations on keys. + :vartype hsm_uri: str + :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is + enabled for this managed HSM pool. Soft delete is enabled by default for all managed HSMs and + is immutable. + :vartype enable_soft_delete: bool + :ivar soft_delete_retention_in_days: Soft deleted data retention days. When you delete an HSM + or a key, it will remain recoverable for the configured retention period or for a default + period of 90 days. It accepts values between 7 and 90. + :vartype soft_delete_retention_in_days: int + :ivar enable_purge_protection: Property specifying whether protection against purge is enabled + for this managed HSM pool. Setting this property to true activates protection against purge for + this managed HSM pool and its content - only the Managed HSM service may initiate a hard, + irrecoverable deletion. Enabling this functionality is irreversible. + :vartype enable_purge_protection: bool + :ivar create_mode: The create mode to indicate whether the resource is being created or is + being recovered from a deleted resource. Known values are: "recover" and "default". + :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode + :ivar status_message: Resource Status Message. + :vartype status_message: str + :ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Provisioning", + "Failed", "Updating", "Deleting", "Activated", "SecurityDomainRestore", and "Restoring". + :vartype provisioning_state: str or ~azure.mgmt.keyvault.models.ProvisioningState + :ivar network_acls: Rules governing the accessibility of the key vault from specific network + locations. + :vartype network_acls: ~azure.mgmt.keyvault.models.MHSMNetworkRuleSet + :ivar regions: List of all regions associated with the managed hsm pool. + :vartype regions: list[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] + :ivar private_endpoint_connections: List of private endpoint connections associated with the + managed hsm pool. + :vartype private_endpoint_connections: + list[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionItem] + :ivar public_network_access: Control permission to the managed HSM from public networks. Known + values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.keyvault.models.PublicNetworkAccess + :ivar scheduled_purge_date: The scheduled purge date in UTC. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar security_domain_properties: Managed HSM security domain properties. + :vartype security_domain_properties: + ~azure.mgmt.keyvault.models.ManagedHSMSecurityDomainProperties + """ + + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The Azure Active Directory tenant ID that should be used for authenticating requests to the + managed HSM pool.""" + initial_admin_object_ids: Optional[list[str]] = rest_field( + name="initialAdminObjectIds", visibility=["read", "create", "update", "delete", "query"] + ) + """Array of initial administrators object ids for this managed hsm pool.""" + hsm_uri: Optional[str] = rest_field(name="hsmUri", visibility=["read"]) + """The URI of the managed hsm pool for performing operations on keys.""" + enable_soft_delete: Optional[bool] = rest_field( + name="enableSoftDelete", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the 'soft delete' functionality is enabled for this managed HSM + pool. Soft delete is enabled by default for all managed HSMs and is immutable.""" + soft_delete_retention_in_days: Optional[int] = rest_field( + name="softDeleteRetentionInDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Soft deleted data retention days. When you delete an HSM or a key, it will remain recoverable + for the configured retention period or for a default period of 90 days. It accepts values + between 7 and 90.""" + enable_purge_protection: Optional[bool] = rest_field( + name="enablePurgeProtection", visibility=["read", "create", "update", "delete", "query"] + ) + """Property specifying whether protection against purge is enabled for this managed HSM pool. + Setting this property to true activates protection against purge for this managed HSM pool and + its content - only the Managed HSM service may initiate a hard, irrecoverable deletion. + Enabling this functionality is irreversible.""" + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field( + name="createMode", visibility=["create", "update"] + ) + """The create mode to indicate whether the resource is being created or is being recovered from a + deleted resource. Known values are: \"recover\" and \"default\".""" + status_message: Optional[str] = rest_field(name="statusMessage", visibility=["read"]) + """Resource Status Message.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state. Known values are: \"Succeeded\", \"Provisioning\", \"Failed\", + \"Updating\", \"Deleting\", \"Activated\", \"SecurityDomainRestore\", and \"Restoring\".""" + network_acls: Optional["_models.MHSMNetworkRuleSet"] = rest_field( + name="networkAcls", visibility=["read", "create", "update", "delete", "query"] + ) + """Rules governing the accessibility of the key vault from specific network locations.""" + regions: Optional[list["_models.MHSMGeoReplicatedRegion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of all regions associated with the managed hsm pool.""" + private_endpoint_connections: Optional[list["_models.MHSMPrivateEndpointConnectionItem"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """List of private endpoint connections associated with the managed hsm pool.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Control permission to the managed HSM from public networks. Known values are: \"Enabled\" and + \"Disabled\".""" + scheduled_purge_date: Optional[datetime.datetime] = rest_field( + name="scheduledPurgeDate", visibility=["read"], format="rfc3339" + ) + """The scheduled purge date in UTC.""" + security_domain_properties: Optional["_models.ManagedHSMSecurityDomainProperties"] = rest_field( + name="securityDomainProperties", visibility=["read"] + ) + """Managed HSM security domain properties.""" + + @overload + def __init__( + self, + *, + tenant_id: Optional[str] = None, + initial_admin_object_ids: Optional[list[str]] = None, + enable_soft_delete: Optional[bool] = None, + soft_delete_retention_in_days: Optional[int] = None, + enable_purge_protection: Optional[bool] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + network_acls: Optional["_models.MHSMNetworkRuleSet"] = None, + regions: Optional[list["_models.MHSMGeoReplicatedRegion"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmResource(_Model): + """Managed HSM resource. + + :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. + :vartype id: str + :ivar name: The name of the managed HSM Pool. + :vartype name: str + :ivar type: The resource type of the managed HSM Pool. + :vartype type: str + :ivar location: The supported Azure location where the managed HSM Pool should be created. + :vartype location: str + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the key vault + resource. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar identity: Managed service identity (system assigned and/or user assigned identities). + :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The Azure Resource Manager resource ID for the managed HSM Pool.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the managed HSM Pool.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The resource type of the managed HSM Pool.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The supported Azure location where the managed HSM Pool should be created.""" + sku: Optional["_models.ManagedHsmSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU details.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Metadata pertaining to creation and last modification of the key vault resource.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity (system assigned and/or user assigned identities).""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + sku: Optional["_models.ManagedHsmSku"] = None, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmRotationPolicy(_Model): + """ManagedHsmRotationPolicy. + + :ivar attributes: The attributes of key rotation policy. + :vartype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyRotationPolicyAttributes + :ivar lifetime_actions: The lifetimeActions for key rotation action. + :vartype lifetime_actions: list[~azure.mgmt.keyvault.models.ManagedHsmLifetimeAction] + """ + + attributes: Optional["_models.ManagedHsmKeyRotationPolicyAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of key rotation policy.""" + lifetime_actions: Optional[list["_models.ManagedHsmLifetimeAction"]] = rest_field( + name="lifetimeActions", visibility=["read", "create", "update", "delete", "query"] + ) + """The lifetimeActions for key rotation action.""" + + @overload + def __init__( + self, + *, + attributes: Optional["_models.ManagedHsmKeyRotationPolicyAttributes"] = None, + lifetime_actions: Optional[list["_models.ManagedHsmLifetimeAction"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHSMSecurityDomainProperties(_Model): + """The security domain properties of the managed hsm. + + :ivar activation_status: Activation Status. Known values are: "Active", "NotActivated", + "Unknown", and "Failed". + :vartype activation_status: str or ~azure.mgmt.keyvault.models.ActivationStatus + :ivar activation_status_message: Activation Status Message. + :vartype activation_status_message: str + """ + + activation_status: Optional[Union[str, "_models.ActivationStatus"]] = rest_field( + name="activationStatus", visibility=["read"] + ) + """Activation Status. Known values are: \"Active\", \"NotActivated\", \"Unknown\", and \"Failed\".""" + activation_status_message: Optional[str] = rest_field(name="activationStatusMessage", visibility=["read"]) + """Activation Status Message.""" + + +class ManagedHsmSku(_Model): + """SKU details. + + :ivar family: SKU Family of the managed HSM Pool. Required. Known values are: "B" and "C". + :vartype family: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuFamily + :ivar name: SKU of the managed HSM Pool. Required. Known values are: "Standard_B1", + "Custom_B32", "Custom_B6", "Custom_C42", and "Custom_C10". + :vartype name: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuName + """ + + family: Union[str, "_models.ManagedHsmSkuFamily"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU Family of the managed HSM Pool. Required. Known values are: \"B\" and \"C\".""" + name: Union[str, "_models.ManagedHsmSkuName"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU of the managed HSM Pool. Required. Known values are: \"Standard_B1\", \"Custom_B32\", + \"Custom_B6\", \"Custom_C42\", and \"Custom_C10\".""" + + @overload + def __init__( + self, + *, + family: Union[str, "_models.ManagedHsmSkuFamily"], + name: Union[str, "_models.ManagedHsmSkuName"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedHsmTrigger(_Model): + """ManagedHsmTrigger. + + :ivar time_after_create: The time duration after key creation to rotate the key. It only + applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + :vartype time_after_create: str + :ivar time_before_expiry: The time duration before key expiring to rotate or notify. It will be + in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + :vartype time_before_expiry: str + """ + + time_after_create: Optional[str] = rest_field( + name="timeAfterCreate", visibility=["read", "create", "update", "delete", "query"] + ) + """The time duration after key creation to rotate the key. It only applies to rotate. It will be + in ISO 8601 duration format. Eg: 'P90D', 'P1Y'.""" + time_before_expiry: Optional[str] = rest_field( + name="timeBeforeExpiry", visibility=["read", "create", "update", "delete", "query"] + ) + """The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration + format. Eg: 'P90D', 'P1Y'.""" + + @overload + def __init__( + self, + *, + time_after_create: Optional[str] = None, + time_before_expiry: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServiceIdentity(_Model): + """Managed service identity (system assigned and/or user assigned identities). + + :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: The type of managed identity assigned to this resource. Required. Known values are: + "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.keyvault.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The identities assigned to this resource by the user. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.keyvault.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The service principal ID of the system assigned identity. This property will only be provided + for a system assigned identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of the system assigned identity. This property will only be provided for a system + assigned identity.""" + type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of managed identity assigned to this resource. Required. Known values are: \"None\", + \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The identities assigned to this resource by the user.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricSpecification(_Model): + """Metric specification of operation. + + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. + :vartype unit: str + :ivar aggregation_type: The metric aggregation type. Possible values include: 'Average', + 'Count', 'Total'. + :vartype aggregation_type: str + :ivar supported_aggregation_types: The supported aggregation types for the metrics. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: The supported time grain types for the metrics. + :vartype supported_time_grain_types: list[str] + :ivar lock_aggregation_type: The metric lock aggregation type. + :vartype lock_aggregation_type: str + :ivar dimensions: The dimensions of metric. + :vartype dimensions: list[~azure.mgmt.keyvault.models.DimensionProperties] + :ivar fill_gap_with_zero: Property to specify whether to fill gap with zero. + :vartype fill_gap_with_zero: bool + :ivar internal_metric_name: The internal metric name. + :vartype internal_metric_name: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of metric specification.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of metric specification.""" + display_description: Optional[str] = rest_field( + name="displayDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Display description of metric specification.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'.""" + aggregation_type: Optional[str] = rest_field( + name="aggregationType", visibility=["read", "create", "update", "delete", "query"] + ) + """The metric aggregation type. Possible values include: 'Average', 'Count', 'Total'.""" + supported_aggregation_types: Optional[list[str]] = rest_field( + name="supportedAggregationTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """The supported aggregation types for the metrics.""" + supported_time_grain_types: Optional[list[str]] = rest_field( + name="supportedTimeGrainTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """The supported time grain types for the metrics.""" + lock_aggregation_type: Optional[str] = rest_field( + name="lockAggregationType", visibility=["read", "create", "update", "delete", "query"] + ) + """The metric lock aggregation type.""" + dimensions: Optional[list["_models.DimensionProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The dimensions of metric.""" + fill_gap_with_zero: Optional[bool] = rest_field( + name="fillGapWithZero", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether to fill gap with zero.""" + internal_metric_name: Optional[str] = rest_field( + name="internalMetricName", visibility=["read", "create", "update", "delete", "query"] + ) + """The internal metric name.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + supported_aggregation_types: Optional[list[str]] = None, + supported_time_grain_types: Optional[list[str]] = None, + lock_aggregation_type: Optional[str] = None, + dimensions: Optional[list["_models.DimensionProperties"]] = None, + fill_gap_with_zero: Optional[bool] = None, + internal_metric_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMGeoReplicatedRegion(_Model): + """A region that this managed HSM Pool has been extended to. + + :ivar name: Name of the geo replicated region. + :vartype name: str + :ivar provisioning_state: Provisioning state of the geo replicated region. Known values are: + "Preprovisioning", "Provisioning", "Succeeded", "Failed", "Deleting", and "Cleanup". + :vartype provisioning_state: str or + ~azure.mgmt.keyvault.models.GeoReplicationRegionProvisioningState + :ivar is_primary: A boolean value that indicates whether the region is the primary region or a + secondary region. + :vartype is_primary: bool + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the geo replicated region.""" + provisioning_state: Optional[Union[str, "_models.GeoReplicationRegionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the geo replicated region. Known values are: \"Preprovisioning\", + \"Provisioning\", \"Succeeded\", \"Failed\", \"Deleting\", and \"Cleanup\".""" + is_primary: Optional[bool] = rest_field( + name="isPrimary", visibility=["read", "create", "update", "delete", "query"] + ) + """A boolean value that indicates whether the region is the primary region or a secondary region.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + is_primary: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMIPRule(_Model): + """A rule governing the accessibility of a managed HSM pool from a specific IP address or IP + range. + + :ivar value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) + or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. + :vartype value: str + """ + + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) or + '124.56.78.0/24' (all addresses that start with 124.56.78). Required.""" + + @overload + def __init__( + self, + *, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMNetworkRuleSet(_Model): + """A set of rules governing the network accessibility of a managed hsm pool. + + :ivar bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or + 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and + "None". + :vartype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions + :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules + match. This is only used after the bypass property has been evaluated. Known values are: + "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction + :ivar ip_rules: The list of IP address rules. + :vartype ip_rules: list[~azure.mgmt.keyvault.models.MHSMIPRule] + :ivar service_tags: The list of service tags. + :vartype service_tags: list[~azure.mgmt.keyvault.models.MHSMServiceTagRule] + :ivar virtual_network_rules: The list of virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.keyvault.models.MHSMVirtualNetworkRule] + """ + + bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tells what traffic can bypass network rules. This can be 'AzureServices' or 'None'. If not + specified the default is 'AzureServices'. Known values are: \"AzureServices\" and \"None\".""" + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = rest_field( + name="defaultAction", visibility=["read", "create", "update", "delete", "query"] + ) + """The default action when no rule from ipRules and from virtualNetworkRules match. This is only + used after the bypass property has been evaluated. Known values are: \"Allow\" and \"Deny\".""" + ip_rules: Optional[list["_models.MHSMIPRule"]] = rest_field( + name="ipRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of IP address rules.""" + service_tags: Optional[list["_models.MHSMServiceTagRule"]] = rest_field( + name="serviceTags", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of service tags.""" + virtual_network_rules: Optional[list["_models.MHSMVirtualNetworkRule"]] = rest_field( + name="virtualNetworkRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of virtual network rules.""" + + @overload + def __init__( + self, + *, + bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = None, + ip_rules: Optional[list["_models.MHSMIPRule"]] = None, + service_tags: Optional[list["_models.MHSMServiceTagRule"]] = None, + virtual_network_rules: Optional[list["_models.MHSMVirtualNetworkRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMPrivateEndpoint(_Model): + """Private endpoint object properties. + + :ivar id: Full identifier of the private endpoint resource. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Full identifier of the private endpoint resource.""" + + +class MHSMPrivateEndpointConnection(Resource): + """Private endpoint connection resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku + :ivar identity: Managed service identity. + :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity + :ivar etag: Modified whenever there is a change in the state of private endpoint connection. + :vartype etag: str + """ + + properties: Optional["_models.MHSMPrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives.""" + sku: Optional["_models.ManagedHsmSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU details.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity.""" + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Modified whenever there is a change in the state of private endpoint connection.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MHSMPrivateEndpointConnectionProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + sku: Optional["_models.ManagedHsmSku"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + etag: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MHSMPrivateEndpointConnectionItem(_Model): + """Private endpoint connection item. + + :ivar id: Id of private endpoint connection. + :vartype id: str + :ivar etag: Modified whenever there is a change in the state of private endpoint connection. + :vartype etag: str + :ivar properties: Private endpoint connection properties. + :vartype properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionProperties + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Id of private endpoint connection.""" + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Modified whenever there is a change in the state of private endpoint connection.""" + properties: Optional["_models.MHSMPrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint connection properties.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + etag: Optional[str] = None, + properties: Optional["_models.MHSMPrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MHSMPrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection resource. + + :ivar private_endpoint: Properties of the private endpoint object. + :vartype private_endpoint: ~azure.mgmt.keyvault.models.MHSMPrivateEndpoint + :ivar private_link_service_connection_state: Approval state of the private link connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState + :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values + are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". + :vartype provisioning_state: str or + ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState + """ + + private_endpoint: Optional["_models.MHSMPrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the private endpoint object.""" + private_link_service_connection_state: Optional["_models.MHSMPrivateLinkServiceConnectionState"] = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """Approval state of the private link connection.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the private endpoint connection. Known values are: \"Succeeded\", + \"Creating\", \"Updating\", \"Deleting\", \"Failed\", and \"Disconnected\".""" + + @overload + def __init__( + self, + *, + private_endpoint: Optional["_models.MHSMPrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.MHSMPrivateLinkServiceConnectionState"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMPrivateLinkResource(ManagedHsmResource): + """A private link resource. + + :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. + :vartype id: str + :ivar name: The name of the managed HSM Pool. + :vartype name: str + :ivar type: The resource type of the managed HSM Pool. + :vartype type: str + :ivar location: The supported Azure location where the managed HSM Pool should be created. + :vartype location: str + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the key vault + resource. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar identity: Managed service identity (system assigned and/or user assigned identities). + :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.keyvault.models.MHSMPrivateLinkResourceProperties + """ + + properties: Optional["_models.MHSMPrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names"] + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + sku: Optional["_models.ManagedHsmSku"] = None, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + properties: Optional["_models.MHSMPrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MHSMPrivateLinkResourceListResult(_Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.keyvault.models.MHSMPrivateLinkResource] + """ + + value: Optional[list["_models.MHSMPrivateLinkResource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of private link resources.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.MHSMPrivateLinkResource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMPrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: Group identifier of private link resource. + :vartype group_id: str + :ivar required_members: Required member names of private link resource. + :vartype required_members: list[str] + :ivar required_zone_names: Required DNS zone names of the the private link resource. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """Group identifier of private link resource.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """Required member names of private link resource.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Required DNS zone names of the the private link resource.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMPrivateLinkServiceConnectionState(_Model): + """An object that represents the approval state of the private link connection. + + :ivar status: Indicates whether the connection has been approved, rejected or removed by the + key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval or rejection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. "None" + :vartype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been approved, rejected or removed by the key vault owner. + Known values are: \"Pending\", \"Approved\", \"Rejected\", and \"Disconnected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval or rejection.""" + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer. + \"None\"""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMServiceTagRule(_Model): + """A rule governing the accessibility of a managed hsm pool from a specific service tags. + + :ivar tag: Name of the service tag. Required. + :vartype tag: str + """ + + tag: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the service tag. Required.""" + + @overload + def __init__( + self, + *, + tag: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MHSMVirtualNetworkRule(_Model): + """A rule governing the accessibility of a managed hsm pool from a specific virtual network. + + :ivar id: Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required. + :vartype id: str + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkRuleSet(_Model): + """A set of rules governing the network accessibility of a vault. + + :ivar bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or + 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and + "None". + :vartype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions + :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules + match. This is only used after the bypass property has been evaluated. Known values are: + "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction + :ivar ip_rules: The list of IP address rules. + :vartype ip_rules: list[~azure.mgmt.keyvault.models.IPRule] + :ivar virtual_network_rules: The list of virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.keyvault.models.VirtualNetworkRule] + """ + + bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tells what traffic can bypass network rules. This can be 'AzureServices' or 'None'. If not + specified the default is 'AzureServices'. Known values are: \"AzureServices\" and \"None\".""" + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = rest_field( + name="defaultAction", visibility=["read", "create", "update", "delete", "query"] + ) + """The default action when no rule from ipRules and from virtualNetworkRules match. This is only + used after the bypass property has been evaluated. Known values are: \"Allow\" and \"Deny\".""" + ip_rules: Optional[list["_models.IPRule"]] = rest_field( + name="ipRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of IP address rules.""" + virtual_network_rules: Optional[list["_models.VirtualNetworkRule"]] = rest_field( + name="virtualNetworkRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of virtual network rules.""" + + @overload + def __init__( + self, + *, + bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = None, + ip_rules: Optional[list["_models.IPRule"]] = None, + virtual_network_rules: Optional[list["_models.VirtualNetworkRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """Key Vault REST API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.keyvault.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str + :ivar operation_properties: Properties of operation, include metric specifications. + :vartype operation_properties: ~azure.mgmt.keyvault.models.OperationProperties + :ivar is_data_action: Property to specify whether the action is a data action. + :vartype is_data_action: bool + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation name: {provider}/{resource}/{operation}.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Display metadata associated with the operation.""" + origin: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The origin of operations.""" + operation_properties: Optional["_models.OperationProperties"] = rest_field( + name="properties", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of operation, include metric specifications.""" + is_data_action: Optional[bool] = rest_field( + name="isDataAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the action is a data action.""" + + __flattened_items = ["service_specification"] + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + operation_properties: Optional["_models.OperationProperties"] = None, + is_data_action: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.operation_properties is None: + return None + return getattr(self.operation_properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.operation_properties is None: + self.operation_properties = self._attr_to_rest_field["operation_properties"]._class_type() + setattr(self.operation_properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationDisplay(_Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft Key Vault. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Service provider: Microsoft Key Vault.""" + resource: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource on which the operation is performed etc.""" + operation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of operation: get, read, delete, etc.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of operation.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationProperties(_Model): + """Properties of operation, include metric specifications. + + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.keyvault.models.ServiceSpecification + """ + + service_specification: Optional["_models.ServiceSpecification"] = rest_field( + name="serviceSpecification", visibility=["read", "create", "update", "delete", "query"] + ) + """One property of operation, include metric specifications.""" + + @overload + def __init__( + self, + *, + service_specification: Optional["_models.ServiceSpecification"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Permissions(_Model): + """Permissions the identity has for keys, secrets, certificates and storage. + + :ivar keys_property: Permissions to keys. + :vartype keys_property: list[str or ~azure.mgmt.keyvault.models.KeyPermissions] + :ivar secrets: Permissions to secrets. + :vartype secrets: list[str or ~azure.mgmt.keyvault.models.SecretPermissions] + :ivar certificates: Permissions to certificates. + :vartype certificates: list[str or ~azure.mgmt.keyvault.models.CertificatePermissions] + :ivar storage: Permissions to storage accounts. + :vartype storage: list[str or ~azure.mgmt.keyvault.models.StoragePermissions] + """ + + keys_property: Optional[list[Union[str, "_models.KeyPermissions"]]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """Permissions to keys.""" + secrets: Optional[list[Union[str, "_models.SecretPermissions"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Permissions to secrets.""" + certificates: Optional[list[Union[str, "_models.CertificatePermissions"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Permissions to certificates.""" + storage: Optional[list[Union[str, "_models.StoragePermissions"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Permissions to storage accounts.""" + + @overload + def __init__( + self, + *, + keys_property: Optional[list[Union[str, "_models.KeyPermissions"]]] = None, + secrets: Optional[list[Union[str, "_models.SecretPermissions"]]] = None, + certificates: Optional[list[Union[str, "_models.CertificatePermissions"]]] = None, + storage: Optional[list[Union[str, "_models.StoragePermissions"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """Private endpoint object properties. + + :ivar id: Full identifier of the private endpoint resource. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Full identifier of the private endpoint resource.""" + + +class PrivateEndpointConnection(ProxyResource): + """Private endpoint connection resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProperties + :ivar location: Azure location of the key vault resource. + :vartype location: str + :ivar tags: Tags assigned to the key vault resource. + :vartype tags: dict[str, str] + :ivar etag: Modified whenever there is a change in the state of private endpoint connection. + :vartype etag: str + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Azure location of the key vault resource.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Tags assigned to the key vault resource.""" + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Modified whenever there is a change in the state of private endpoint connection.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + etag: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionItem(_Model): + """Private endpoint connection item. + + :ivar id: Id of private endpoint connection. + :vartype id: str + :ivar etag: Modified whenever there is a change in the state of private endpoint connection. + :vartype etag: str + :ivar properties: Private endpoint connection properties. + :vartype properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProperties + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Id of private endpoint connection.""" + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Modified whenever there is a change in the state of private endpoint connection.""" + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint connection properties.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + etag: Optional[str] = None, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection resource. + + :ivar private_endpoint: Properties of the private endpoint object. + :vartype private_endpoint: ~azure.mgmt.keyvault.models.PrivateEndpoint + :ivar private_link_service_connection_state: Approval state of the private link connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values + are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". + :vartype provisioning_state: str or + ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState + """ + + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the private endpoint object.""" + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """Approval state of the private link connection.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the private endpoint connection. Known values are: \"Succeeded\", + \"Creating\", \"Updating\", \"Deleting\", \"Failed\", and \"Disconnected\".""" + + @overload + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.keyvault.models.PrivateLinkResourceProperties + :ivar location: Azure location of the key vault resource. + :vartype location: str + :ivar tags: Tags assigned to the key vault resource. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Azure location of the key vault resource.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Tags assigned to the key vault resource.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateLinkResourceListResult(_Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.keyvault.models.PrivateLinkResource] + """ + + value: Optional[list["_models.PrivateLinkResource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of private link resources.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PrivateLinkResource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: Group identifier of private link resource. + :vartype group_id: str + :ivar required_members: Required member names of private link resource. + :vartype required_members: list[str] + :ivar required_zone_names: Required DNS zone names of the the private link resource. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """Group identifier of private link resource.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """Required member names of private link resource.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Required DNS zone names of the the private link resource.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """An object that represents the approval state of the private link connection. + + :ivar status: Indicates whether the connection has been approved, rejected or removed by the + key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval or rejection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. "None" + :vartype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been approved, rejected or removed by the key vault owner. + Known values are: \"Pending\", \"Approved\", \"Rejected\", and \"Disconnected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval or rejection.""" + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer. + \"None\"""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RotationPolicy(_Model): + """RotationPolicy. + + :ivar attributes: The attributes of key rotation policy. + :vartype attributes: ~azure.mgmt.keyvault.models.KeyRotationPolicyAttributes + :ivar lifetime_actions: The lifetimeActions for key rotation action. + :vartype lifetime_actions: list[~azure.mgmt.keyvault.models.LifetimeAction] + """ + + attributes: Optional["_models.KeyRotationPolicyAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of key rotation policy.""" + lifetime_actions: Optional[list["_models.LifetimeAction"]] = rest_field( + name="lifetimeActions", visibility=["read", "create", "update", "delete", "query"] + ) + """The lifetimeActions for key rotation action.""" + + @overload + def __init__( + self, + *, + attributes: Optional["_models.KeyRotationPolicyAttributes"] = None, + lifetime_actions: Optional[list["_models.LifetimeAction"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Secret(ProxyResource): + """Resource information with extended details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Properties of the secret. Required. + :vartype properties: ~azure.mgmt.keyvault.models.SecretProperties + :ivar location: Azure location of the key vault resource. + :vartype location: str + :ivar tags: Tags assigned to the key vault resource. + :vartype tags: dict[str, str] + """ + + properties: "_models.SecretProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of the secret. Required.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Azure location of the key vault resource.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Tags assigned to the key vault resource.""" + + @overload + def __init__( + self, + *, + properties: "_models.SecretProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecretAttributes(Attributes): + """The secret management attributes. + + :ivar enabled: Determines whether the object is enabled. + :vartype enabled: bool + :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. + :vartype not_before: ~datetime.datetime + :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. + :vartype expires: ~datetime.datetime + :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. + :vartype created: ~datetime.datetime + :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. + :vartype updated: ~datetime.datetime + """ + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + not_before: Optional[datetime.datetime] = None, + expires: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecretCreateOrUpdateParameters(_Model): + """Parameters for creating or updating a secret. + + :ivar tags: The tags that will be assigned to the secret. + :vartype tags: dict[str, str] + :ivar properties: Properties of the secret. Required. + :vartype properties: ~azure.mgmt.keyvault.models.SecretProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the secret.""" + properties: "_models.SecretProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of the secret. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.SecretProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecretPatchParameters(_Model): + """Parameters for patching a secret. + + :ivar tags: The tags that will be assigned to the secret. + :vartype tags: dict[str, str] + :ivar properties: Properties of the secret. + :vartype properties: ~azure.mgmt.keyvault.models.SecretPatchProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the secret.""" + properties: Optional["_models.SecretPatchProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the secret.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.SecretPatchProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecretPatchProperties(_Model): + """Properties of the secret. + + :ivar value: The value of the secret. + :vartype value: str + :ivar content_type: The content type of the secret. + :vartype content_type: str + :ivar attributes: The attributes of the secret. + :vartype attributes: ~azure.mgmt.keyvault.models.SecretAttributes + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value of the secret.""" + content_type: Optional[str] = rest_field( + name="contentType", visibility=["read", "create", "update", "delete", "query"] + ) + """The content type of the secret.""" + attributes: Optional["_models.SecretAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of the secret.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + content_type: Optional[str] = None, + attributes: Optional["_models.SecretAttributes"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecretProperties(_Model): + """Properties of the secret. + + :ivar value: The value of the secret. NOTE: 'value' will never be returned from the service, as + APIs using this model are is intended for internal use in ARM deployments. Users should use the + data-plane REST service for interaction with vault secrets. + :vartype value: str + :ivar content_type: The content type of the secret. + :vartype content_type: str + :ivar attributes: The attributes of the secret. + :vartype attributes: ~azure.mgmt.keyvault.models.SecretAttributes + :ivar secret_uri: The URI to retrieve the current version of the secret. + :vartype secret_uri: str + :ivar secret_uri_with_version: The URI to retrieve the specific version of the secret. + :vartype secret_uri_with_version: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value of the secret. NOTE: 'value' will never be returned from the service, as APIs using + this model are is intended for internal use in ARM deployments. Users should use the data-plane + REST service for interaction with vault secrets.""" + content_type: Optional[str] = rest_field( + name="contentType", visibility=["read", "create", "update", "delete", "query"] + ) + """The content type of the secret.""" + attributes: Optional["_models.SecretAttributes"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The attributes of the secret.""" + secret_uri: Optional[str] = rest_field(name="secretUri", visibility=["read"]) + """The URI to retrieve the current version of the secret.""" + secret_uri_with_version: Optional[str] = rest_field(name="secretUriWithVersion", visibility=["read"]) + """The URI to retrieve the specific version of the secret.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + content_type: Optional[str] = None, + attributes: Optional["_models.SecretAttributes"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServiceSpecification(_Model): + """One property of operation, include log specifications. + + :ivar log_specifications: Log specifications of operation. + :vartype log_specifications: list[~azure.mgmt.keyvault.models.LogSpecification] + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: list[~azure.mgmt.keyvault.models.MetricSpecification] + """ + + log_specifications: Optional[list["_models.LogSpecification"]] = rest_field( + name="logSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Log specifications of operation.""" + metric_specifications: Optional[list["_models.MetricSpecification"]] = rest_field( + name="metricSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Metric specifications of operation.""" + + @overload + def __init__( + self, + *, + log_specifications: Optional[list["_models.LogSpecification"]] = None, + metric_specifications: Optional[list["_models.MetricSpecification"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """SKU details. + + :ivar family: SKU family name. Required. "A" + :vartype family: str or ~azure.mgmt.keyvault.models.SkuFamily + :ivar name: SKU name to specify whether the key vault is a standard vault or a premium vault. + Required. Known values are: "standard" and "premium". + :vartype name: str or ~azure.mgmt.keyvault.models.SkuName + """ + + family: Union[str, "_models.SkuFamily"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU family name. Required. \"A\"""" + name: Union[str, "_models.SkuName"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU name to specify whether the key vault is a standard vault or a premium vault. Required. + Known values are: \"standard\" and \"premium\".""" + + @overload + def __init__( + self, + *, + family: Union[str, "_models.SkuFamily"], + name: Union[str, "_models.SkuName"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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.keyvault.models.IdentityType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :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.keyvault.models.IdentityType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.IdentityType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.IdentityType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Trigger(_Model): + """Trigger. + + :ivar time_after_create: The time duration after key creation to rotate the key. It only + applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + :vartype time_after_create: str + :ivar time_before_expiry: The time duration before key expiring to rotate or notify. It will be + in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. + :vartype time_before_expiry: str + """ + + time_after_create: Optional[str] = rest_field( + name="timeAfterCreate", visibility=["read", "create", "update", "delete", "query"] + ) + """The time duration after key creation to rotate the key. It only applies to rotate. It will be + in ISO 8601 duration format. Eg: 'P90D', 'P1Y'.""" + time_before_expiry: Optional[str] = rest_field( + name="timeBeforeExpiry", visibility=["read", "create", "update", "delete", "query"] + ) + """The time duration before key expiring to rotate or notify. It will be in ISO 8601 duration + format. Eg: 'P90D', 'P1Y'.""" + + @overload + def __init__( + self, + *, + time_after_create: Optional[str] = None, + time_before_expiry: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentity(_Model): + """User assigned identity properties. + + :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 + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client ID of the assigned identity.""" + + +class Vault(ProxyResource): + """Resource information with extended details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.keyvault.models.SystemData + :ivar properties: Properties of the vault. Required. + :vartype properties: ~azure.mgmt.keyvault.models.VaultProperties + :ivar location: Azure location of the key vault resource. + :vartype location: str + :ivar tags: Tags assigned to the key vault resource. + :vartype tags: dict[str, str] + """ + + properties: "_models.VaultProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of the vault. Required.""" + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Azure location of the key vault resource.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tags assigned to the key vault resource.""" + + @overload + def __init__( + self, + *, + properties: "_models.VaultProperties", + location: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultAccessPolicyParameters(_Model): + """Parameters for updating the access policy in a vault. + + :ivar id: The resource id of the access policy. + :vartype id: str + :ivar name: The resource name of the access policy. + :vartype name: str + :ivar type: The resource name of the access policy. + :vartype type: str + :ivar location: The resource type of the access policy. + :vartype location: str + :ivar properties: Properties of the access policy. Required. + :vartype properties: ~azure.mgmt.keyvault.models.VaultAccessPolicyProperties + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The resource id of the access policy.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The resource name of the access policy.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The resource name of the access policy.""" + location: Optional[str] = rest_field(visibility=["read"]) + """The resource type of the access policy.""" + properties: "_models.VaultAccessPolicyProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the access policy. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.VaultAccessPolicyProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultAccessPolicyProperties(_Model): + """Properties of the vault access policy. + + :ivar access_policies: An array of 0 to 16 identities that have access to the key vault. All + identities in the array must use the same tenant ID as the key vault's tenant ID. Required. + :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] + """ + + access_policies: list["_models.AccessPolicyEntry"] = rest_field( + name="accessPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """An array of 0 to 16 identities that have access to the key vault. All identities in the array + must use the same tenant ID as the key vault's tenant ID. Required.""" + + @overload + def __init__( + self, + *, + access_policies: list["_models.AccessPolicyEntry"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultCheckNameAvailabilityParameters(_Model): + """The parameters used to check the availability of the vault name. + + :ivar name: The vault name. Required. + :vartype name: str + :ivar type: The type of resource, Microsoft.KeyVault/vaults. Required. Default value is + "Microsoft.KeyVault/vaults". + :vartype type: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The vault name. Required.""" + type: Literal["Microsoft.KeyVault/vaults"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of resource, Microsoft.KeyVault/vaults. Required. Default value is + \"Microsoft.KeyVault/vaults\".""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type: Literal["Microsoft.KeyVault/vaults"] = "Microsoft.KeyVault/vaults" + + +class VaultCreateOrUpdateParameters(_Model): + """Parameters for creating or updating a vault. + + :ivar location: The supported Azure location where the key vault should be created. Required. + :vartype location: str + :ivar tags: The tags that will be assigned to the key vault. + :vartype tags: dict[str, str] + :ivar properties: Properties of the vault. Required. + :vartype properties: ~azure.mgmt.keyvault.models.VaultProperties + """ + + location: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The supported Azure location where the key vault should be created. Required.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the key vault.""" + properties: "_models.VaultProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of the vault. Required.""" + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.VaultProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultPatchParameters(_Model): + """Parameters for creating or updating a vault. + + :ivar tags: The tags that will be assigned to the key vault. + :vartype tags: dict[str, str] + :ivar properties: Properties of the vault. + :vartype properties: ~azure.mgmt.keyvault.models.VaultPatchProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tags that will be assigned to the key vault.""" + properties: Optional["_models.VaultPatchProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the vault.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.VaultPatchProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultPatchProperties(_Model): + """Properties of the vault. + + :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating + requests to the key vault. + :vartype tenant_id: str + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.keyvault.models.Sku + :ivar access_policies: An array of 0 to 16 identities that have access to the key vault. All + identities in the array must use the same tenant ID as the key vault's tenant ID. + :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] + :ivar enabled_for_deployment: Property to specify whether Azure Virtual Machines are permitted + to retrieve certificates stored as secrets from the key vault. + :vartype enabled_for_deployment: bool + :ivar enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is + permitted to retrieve secrets from the vault and unwrap keys. + :vartype enabled_for_disk_encryption: bool + :ivar enabled_for_template_deployment: Property to specify whether Azure Resource Manager is + permitted to retrieve secrets from the key vault. + :vartype enabled_for_template_deployment: bool + :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is + enabled for this key vault. Once set to true, it cannot be reverted to false. + :vartype enable_soft_delete: bool + :ivar enable_rbac_authorization: Property that controls how data actions are authorized. When + true, the key vault will use Role Based Access Control (RBAC) for authorization of data + actions, and the access policies specified in vault properties will be ignored. When false, + the key vault will use the access policies specified in vault properties, and any policy stored + on Azure Resource Manager will be ignored. If null or not specified, the value of this property + will not change. + :vartype enable_rbac_authorization: bool + :ivar soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and <=90. + :vartype soft_delete_retention_in_days: int + :ivar create_mode: The vault's create mode to indicate whether the vault need to be recovered + or not. Known values are: "recover" and "default". + :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode + :ivar enable_purge_protection: Property specifying whether protection against purge is enabled + for this vault. Setting this property to true activates protection against purge for this vault + and its content - only the Key Vault service may initiate a hard, irrecoverable deletion. The + setting is effective only if soft delete is also enabled. Enabling this functionality is + irreversible - that is, the property does not accept false as its value. + :vartype enable_purge_protection: bool + :ivar network_acls: A collection of rules governing the accessibility of the vault from + specific network locations. + :vartype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet + :ivar public_network_access: Property to specify whether the vault will accept traffic from + public internet. If set to 'disabled' all traffic except private endpoint traffic and that that + originates from trusted services will be blocked. This will override the set firewall rules, + meaning that even if the firewall rules are present we will not honor the rules. + :vartype public_network_access: str + """ + + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The Azure Active Directory tenant ID that should be used for authenticating requests to the key + vault.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU details.""" + access_policies: Optional[list["_models.AccessPolicyEntry"]] = rest_field( + name="accessPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """An array of 0 to 16 identities that have access to the key vault. All identities in the array + must use the same tenant ID as the key vault's tenant ID.""" + enabled_for_deployment: Optional[bool] = rest_field( + name="enabledForDeployment", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Virtual Machines are permitted to retrieve certificates + stored as secrets from the key vault.""" + enabled_for_disk_encryption: Optional[bool] = rest_field( + name="enabledForDiskEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Disk Encryption is permitted to retrieve secrets from the + vault and unwrap keys.""" + enabled_for_template_deployment: Optional[bool] = rest_field( + name="enabledForTemplateDeployment", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Resource Manager is permitted to retrieve secrets from the + key vault.""" + enable_soft_delete: Optional[bool] = rest_field( + name="enableSoftDelete", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the 'soft delete' functionality is enabled for this key vault. Once + set to true, it cannot be reverted to false.""" + enable_rbac_authorization: Optional[bool] = rest_field( + name="enableRbacAuthorization", visibility=["read", "create", "update", "delete", "query"] + ) + """Property that controls how data actions are authorized. When true, the key vault will use Role + Based Access Control (RBAC) for authorization of data actions, and the access policies + specified in vault properties will be ignored. When false, the key vault will use the access + policies specified in vault properties, and any policy stored on Azure Resource Manager will be + ignored. If null or not specified, the value of this property will not change.""" + soft_delete_retention_in_days: Optional[int] = rest_field( + name="softDeleteRetentionInDays", visibility=["read", "create", "update", "delete", "query"] + ) + """softDelete data retention days. It accepts >=7 and <=90.""" + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field( + name="createMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The vault's create mode to indicate whether the vault need to be recovered or not. Known values + are: \"recover\" and \"default\".""" + enable_purge_protection: Optional[bool] = rest_field( + name="enablePurgeProtection", visibility=["read", "create", "update", "delete", "query"] + ) + """Property specifying whether protection against purge is enabled for this vault. Setting this + property to true activates protection against purge for this vault and its content - only the + Key Vault service may initiate a hard, irrecoverable deletion. The setting is effective only if + soft delete is also enabled. Enabling this functionality is irreversible - that is, the + property does not accept false as its value.""" + network_acls: Optional["_models.NetworkRuleSet"] = rest_field( + name="networkAcls", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of rules governing the accessibility of the vault from specific network locations.""" + public_network_access: Optional[str] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the vault will accept traffic from public internet. If set to + 'disabled' all traffic except private endpoint traffic and that that originates from trusted + services will be blocked. This will override the set firewall rules, meaning that even if the + firewall rules are present we will not honor the rules.""" + + @overload + def __init__( + self, + *, + tenant_id: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + access_policies: Optional[list["_models.AccessPolicyEntry"]] = None, + enabled_for_deployment: Optional[bool] = None, + enabled_for_disk_encryption: Optional[bool] = None, + enabled_for_template_deployment: Optional[bool] = None, + enable_soft_delete: Optional[bool] = None, + enable_rbac_authorization: Optional[bool] = None, + soft_delete_retention_in_days: Optional[int] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + enable_purge_protection: Optional[bool] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + public_network_access: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VaultProperties(_Model): + """Properties of the vault. + + :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating + requests to the key vault. Required. + :vartype tenant_id: str + :ivar sku: SKU details. Required. + :vartype sku: ~azure.mgmt.keyvault.models.Sku + :ivar access_policies: An array of 0 to 1024 identities that have access to the key vault. All + identities in the array must use the same tenant ID as the key vault's tenant ID. When + ``createMode`` is set to ``recover``, access policies are not required. Otherwise, access + policies are required. + :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] + :ivar vault_uri: The URI of the vault for performing operations on keys and secrets. + :vartype vault_uri: str + :ivar hsm_pool_resource_id: The resource id of HSM Pool. + :vartype hsm_pool_resource_id: str + :ivar enabled_for_deployment: Property to specify whether Azure Virtual Machines are permitted + to retrieve certificates stored as secrets from the key vault. + :vartype enabled_for_deployment: bool + :ivar enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is + permitted to retrieve secrets from the vault and unwrap keys. + :vartype enabled_for_disk_encryption: bool + :ivar enabled_for_template_deployment: Property to specify whether Azure Resource Manager is + permitted to retrieve secrets from the key vault. + :vartype enabled_for_template_deployment: bool + :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is + enabled for this key vault. If it's not set to any value(true or false) when creating new key + vault, it will be set to true by default. Once set to true, it cannot be reverted to false. + :vartype enable_soft_delete: bool + :ivar soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and <=90. + :vartype soft_delete_retention_in_days: int + :ivar enable_rbac_authorization: Property that controls how data actions are authorized. When + true, the key vault will use Role Based Access Control (RBAC) for authorization of data + actions, and the access policies specified in vault properties will be ignored. When false, + the key vault will use the access policies specified in vault properties, and any policy stored + on Azure Resource Manager will be ignored. If null or not specified, the vault is created with + the default value of false. Note that management actions are always authorized with RBAC. + :vartype enable_rbac_authorization: bool + :ivar create_mode: The vault's create mode to indicate whether the vault need to be recovered + or not. Known values are: "recover" and "default". + :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode + :ivar enable_purge_protection: Property specifying whether protection against purge is enabled + for this vault. Setting this property to true activates protection against purge for this vault + and its content - only the Key Vault service may initiate a hard, irrecoverable deletion. The + setting is effective only if soft delete is also enabled. Enabling this functionality is + irreversible - that is, the property does not accept false as its value. + :vartype enable_purge_protection: bool + :ivar network_acls: Rules governing the accessibility of the key vault from specific network + locations. + :vartype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet + :ivar provisioning_state: Provisioning state of the vault. Known values are: "Succeeded" and + "RegisteringDns". + :vartype provisioning_state: str or ~azure.mgmt.keyvault.models.VaultProvisioningState + :ivar private_endpoint_connections: List of private endpoint connections associated with the + key vault. + :vartype private_endpoint_connections: + list[~azure.mgmt.keyvault.models.PrivateEndpointConnectionItem] + :ivar public_network_access: Property to specify whether the vault will accept traffic from + public internet. If set to 'disabled' all traffic except private endpoint traffic and that that + originates from trusted services will be blocked. This will override the set firewall rules, + meaning that even if the firewall rules are present we will not honor the rules. + :vartype public_network_access: str + """ + + tenant_id: str = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The Azure Active Directory tenant ID that should be used for authenticating requests to the key + vault. Required.""" + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SKU details. Required.""" + access_policies: Optional[list["_models.AccessPolicyEntry"]] = rest_field( + name="accessPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """An array of 0 to 1024 identities that have access to the key vault. All identities in the array + must use the same tenant ID as the key vault's tenant ID. When ``createMode`` is set to + ``recover``, access policies are not required. Otherwise, access policies are required.""" + vault_uri: Optional[str] = rest_field(name="vaultUri", visibility=["read", "create", "update", "delete", "query"]) + """The URI of the vault for performing operations on keys and secrets.""" + hsm_pool_resource_id: Optional[str] = rest_field(name="hsmPoolResourceId", visibility=["read"]) + """The resource id of HSM Pool.""" + enabled_for_deployment: Optional[bool] = rest_field( + name="enabledForDeployment", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Virtual Machines are permitted to retrieve certificates + stored as secrets from the key vault.""" + enabled_for_disk_encryption: Optional[bool] = rest_field( + name="enabledForDiskEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Disk Encryption is permitted to retrieve secrets from the + vault and unwrap keys.""" + enabled_for_template_deployment: Optional[bool] = rest_field( + name="enabledForTemplateDeployment", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether Azure Resource Manager is permitted to retrieve secrets from the + key vault.""" + enable_soft_delete: Optional[bool] = rest_field( + name="enableSoftDelete", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the 'soft delete' functionality is enabled for this key vault. If + it's not set to any value(true or false) when creating new key vault, it will be set to true by + default. Once set to true, it cannot be reverted to false.""" + soft_delete_retention_in_days: Optional[int] = rest_field( + name="softDeleteRetentionInDays", visibility=["read", "create", "update", "delete", "query"] + ) + """softDelete data retention days. It accepts >=7 and <=90.""" + enable_rbac_authorization: Optional[bool] = rest_field( + name="enableRbacAuthorization", visibility=["read", "create", "update", "delete", "query"] + ) + """Property that controls how data actions are authorized. When true, the key vault will use Role + Based Access Control (RBAC) for authorization of data actions, and the access policies + specified in vault properties will be ignored. When false, the key vault will use the access + policies specified in vault properties, and any policy stored on Azure Resource Manager will be + ignored. If null or not specified, the vault is created with the default value of false. Note + that management actions are always authorized with RBAC.""" + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field( + name="createMode", visibility=["create", "update"] + ) + """The vault's create mode to indicate whether the vault need to be recovered or not. Known values + are: \"recover\" and \"default\".""" + enable_purge_protection: Optional[bool] = rest_field( + name="enablePurgeProtection", visibility=["read", "create", "update", "delete", "query"] + ) + """Property specifying whether protection against purge is enabled for this vault. Setting this + property to true activates protection against purge for this vault and its content - only the + Key Vault service may initiate a hard, irrecoverable deletion. The setting is effective only if + soft delete is also enabled. Enabling this functionality is irreversible - that is, the + property does not accept false as its value.""" + network_acls: Optional["_models.NetworkRuleSet"] = rest_field( + name="networkAcls", visibility=["read", "create", "update", "delete", "query"] + ) + """Rules governing the accessibility of the key vault from specific network locations.""" + provisioning_state: Optional[Union[str, "_models.VaultProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read", "create", "update", "delete", "query"] + ) + """Provisioning state of the vault. Known values are: \"Succeeded\" and \"RegisteringDns\".""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnectionItem"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """List of private endpoint connections associated with the key vault.""" + public_network_access: Optional[str] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether the vault will accept traffic from public internet. If set to + 'disabled' all traffic except private endpoint traffic and that that originates from trusted + services will be blocked. This will override the set firewall rules, meaning that even if the + firewall rules are present we will not honor the rules.""" + + @overload + def __init__( + self, + *, + tenant_id: str, + sku: "_models.Sku", + access_policies: Optional[list["_models.AccessPolicyEntry"]] = None, + vault_uri: Optional[str] = None, + enabled_for_deployment: Optional[bool] = None, + enabled_for_disk_encryption: Optional[bool] = None, + enabled_for_template_deployment: Optional[bool] = None, + enable_soft_delete: Optional[bool] = None, + soft_delete_retention_in_days: Optional[int] = None, + enable_rbac_authorization: Optional[bool] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + enable_purge_protection: Optional[bool] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + provisioning_state: Optional[Union[str, "_models.VaultProvisioningState"]] = None, + public_network_access: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualNetworkRule(_Model): + """A rule governing the accessibility of a vault from a specific virtual network. + + :ivar id: Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required. + :vartype id: str + :ivar ignore_missing_vnet_service_endpoint: Property to specify whether NRP will ignore the + check if parent subnet has serviceEndpoints configured. + :vartype ignore_missing_vnet_service_endpoint: bool + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required.""" + ignore_missing_vnet_service_endpoint: Optional[bool] = rest_field( + name="ignoreMissingVnetServiceEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether NRP will ignore the check if parent subnet has serviceEndpoints + configured.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ignore_missing_vnet_service_endpoint: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models_py3.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models_py3.py deleted file mode 100644 index 57feb8e659d4..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_models_py3.py +++ /dev/null @@ -1,4581 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessPolicyEntry(_serialization.Model): - """An identity that have access to the key vault. All identities in the array must use the same - tenant ID as the key vault's tenant ID. - - All required parameters must be populated in order to send to server. - - :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. Required. - :vartype tenant_id: str - :ivar object_id: The object ID of a user, service principal or security group in the Azure - Active Directory tenant for the vault. The object ID must be unique for the list of access - policies. Required. - :vartype object_id: str - :ivar application_id: Application ID of the client making request on behalf of a principal. - :vartype application_id: str - :ivar permissions: Permissions the identity has for keys, secrets and certificates. Required. - :vartype permissions: ~azure.mgmt.keyvault.models.Permissions - """ - - _validation = { - "tenant_id": {"required": True}, - "object_id": {"required": True}, - "permissions": {"required": True}, - } - - _attribute_map = { - "tenant_id": {"key": "tenantId", "type": "str"}, - "object_id": {"key": "objectId", "type": "str"}, - "application_id": {"key": "applicationId", "type": "str"}, - "permissions": {"key": "permissions", "type": "Permissions"}, - } - - def __init__( - self, - *, - tenant_id: str, - object_id: str, - permissions: "_models.Permissions", - application_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. Required. - :paramtype tenant_id: str - :keyword object_id: The object ID of a user, service principal or security group in the Azure - Active Directory tenant for the vault. The object ID must be unique for the list of access - policies. Required. - :paramtype object_id: str - :keyword application_id: Application ID of the client making request on behalf of a principal. - :paramtype application_id: str - :keyword permissions: Permissions the identity has for keys, secrets and certificates. - Required. - :paramtype permissions: ~azure.mgmt.keyvault.models.Permissions - """ - super().__init__(**kwargs) - self.tenant_id = tenant_id - self.object_id = object_id - self.application_id = application_id - self.permissions = permissions - - -class Action(_serialization.Model): - """Action. - - :ivar type: The type of action. Known values are: "rotate" and "notify". - :vartype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, *, type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = None, **kwargs: Any - ) -> None: - """ - :keyword type: The type of action. Known values are: "rotate" and "notify". - :paramtype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType - """ - super().__init__(**kwargs) - self.type = type - - -class Attributes(_serialization.Model): - """The object attributes managed by the KeyVault service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar enabled: Determines whether the object is enabled. - :vartype enabled: bool - :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :vartype not_before: ~datetime.datetime - :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :vartype expires: ~datetime.datetime - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: ~datetime.datetime - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: ~datetime.datetime - """ - - _validation = { - "created": {"readonly": True}, - "updated": {"readonly": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "not_before": {"key": "nbf", "type": "unix-time"}, - "expires": {"key": "exp", "type": "unix-time"}, - "created": {"key": "created", "type": "unix-time"}, - "updated": {"key": "updated", "type": "unix-time"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - not_before: Optional[datetime.datetime] = None, - expires: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Determines whether the object is enabled. - :paramtype enabled: bool - :keyword not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :paramtype not_before: ~datetime.datetime - :keyword expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :paramtype expires: ~datetime.datetime - """ - super().__init__(**kwargs) - self.enabled = enabled - self.not_before = not_before - self.expires = expires - self.created: Optional[datetime.datetime] = None - self.updated: Optional[datetime.datetime] = None - - -class CheckMhsmNameAvailabilityParameters(_serialization.Model): - """The parameters used to check the availability of the managed hsm name. - - All required parameters must be populated in order to send to server. - - :ivar name: The managed hsm name. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: The managed hsm name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckMhsmNameAvailabilityResult(_serialization.Model): - """The CheckMhsmNameAvailability operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: A boolean value that indicates whether the name is available for you to - use. If true, the name is available. If false, the name has already been taken or is invalid - and cannot be used. - :vartype name_available: bool - :ivar reason: The reason that a managed hsm name could not be used. The reason element is only - returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.keyvault.models.Reason - :ivar message: An error message explaining the Reason value in more detail. - :vartype message: str - """ - - _validation = { - "name_available": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name_available: Optional[bool] = None - self.reason: Optional[Union[str, "_models.Reason"]] = None - self.message: Optional[str] = None - - -class CheckNameAvailabilityResult(_serialization.Model): - """The CheckNameAvailability operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: A boolean value that indicates whether the name is available for you to - use. If true, the name is available. If false, the name has already been taken or is invalid - and cannot be used. - :vartype name_available: bool - :ivar reason: The reason that a vault name could not be used. The Reason element is only - returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.keyvault.models.Reason - :ivar message: An error message explaining the Reason value in more detail. - :vartype message: str - """ - - _validation = { - "name_available": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name_available: Optional[bool] = None - self.reason: Optional[Union[str, "_models.Reason"]] = None - self.message: Optional[str] = None - - -class CloudErrorBody(_serialization.Model): - """An error response from Key Vault resource provider. - - :ivar code: Error code. This is a mnemonic that can be consumed programmatically. - :vartype code: str - :ivar message: User friendly error message. The message is typically localized and may vary - with service version. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. This is a mnemonic that can be consumed programmatically. - :paramtype code: str - :keyword message: User friendly error message. The message is typically localized and may vary - with service version. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class DeletedManagedHsm(_serialization.Model): - """DeletedManagedHsm. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure Resource Manager resource ID for the deleted managed HSM Pool. - :vartype id: str - :ivar name: The name of the managed HSM Pool. - :vartype name: str - :ivar type: The resource type of the managed HSM Pool. - :vartype type: str - :ivar properties: Properties of the deleted managed HSM. - :vartype properties: ~azure.mgmt.keyvault.models.DeletedManagedHsmProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "DeletedManagedHsmProperties"}, - } - - def __init__(self, *, properties: Optional["_models.DeletedManagedHsmProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Properties of the deleted managed HSM. - :paramtype properties: ~azure.mgmt.keyvault.models.DeletedManagedHsmProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.properties = properties - - -class DeletedManagedHsmListResult(_serialization.Model): - """List of deleted managed HSM Pools. - - :ivar value: The list of deleted managed HSM Pools. - :vartype value: list[~azure.mgmt.keyvault.models.DeletedManagedHsm] - :ivar next_link: The URL to get the next set of deleted managed HSM Pools. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DeletedManagedHsm]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.DeletedManagedHsm"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of deleted managed HSM Pools. - :paramtype value: list[~azure.mgmt.keyvault.models.DeletedManagedHsm] - :keyword next_link: The URL to get the next set of deleted managed HSM Pools. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DeletedManagedHsmProperties(_serialization.Model): - """Properties of the deleted managed HSM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar mhsm_id: The resource id of the original managed HSM. - :vartype mhsm_id: str - :ivar location: The location of the original managed HSM. - :vartype location: str - :ivar deletion_date: The deleted date. - :vartype deletion_date: ~datetime.datetime - :ivar scheduled_purge_date: The scheduled purged date. - :vartype scheduled_purge_date: ~datetime.datetime - :ivar purge_protection_enabled: Purge protection status of the original managed HSM. - :vartype purge_protection_enabled: bool - :ivar tags: Tags of the original managed HSM. - :vartype tags: dict[str, str] - """ - - _validation = { - "mhsm_id": {"readonly": True}, - "location": {"readonly": True}, - "deletion_date": {"readonly": True}, - "scheduled_purge_date": {"readonly": True}, - "purge_protection_enabled": {"readonly": True}, - "tags": {"readonly": True}, - } - - _attribute_map = { - "mhsm_id": {"key": "mhsmId", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "deletion_date": {"key": "deletionDate", "type": "iso-8601"}, - "scheduled_purge_date": {"key": "scheduledPurgeDate", "type": "iso-8601"}, - "purge_protection_enabled": {"key": "purgeProtectionEnabled", "type": "bool"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.mhsm_id: Optional[str] = None - self.location: Optional[str] = None - self.deletion_date: Optional[datetime.datetime] = None - self.scheduled_purge_date: Optional[datetime.datetime] = None - self.purge_protection_enabled: Optional[bool] = None - self.tags: Optional[dict[str, str]] = None - - -class DeletedVault(_serialization.Model): - """Deleted vault information with extended details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource ID for the deleted key vault. - :vartype id: str - :ivar name: The name of the key vault. - :vartype name: str - :ivar type: The resource type of the key vault. - :vartype type: str - :ivar properties: Properties of the vault. - :vartype properties: ~azure.mgmt.keyvault.models.DeletedVaultProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "DeletedVaultProperties"}, - } - - def __init__(self, *, properties: Optional["_models.DeletedVaultProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: Properties of the vault. - :paramtype properties: ~azure.mgmt.keyvault.models.DeletedVaultProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.properties = properties - - -class DeletedVaultListResult(_serialization.Model): - """List of vaults. - - :ivar value: The list of deleted vaults. - :vartype value: list[~azure.mgmt.keyvault.models.DeletedVault] - :ivar next_link: The URL to get the next set of deleted vaults. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DeletedVault]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.DeletedVault"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of deleted vaults. - :paramtype value: list[~azure.mgmt.keyvault.models.DeletedVault] - :keyword next_link: The URL to get the next set of deleted vaults. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DeletedVaultProperties(_serialization.Model): - """Properties of the deleted vault. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vault_id: The resource id of the original vault. - :vartype vault_id: str - :ivar location: The location of the original vault. - :vartype location: str - :ivar deletion_date: The deleted date. - :vartype deletion_date: ~datetime.datetime - :ivar scheduled_purge_date: The scheduled purged date. - :vartype scheduled_purge_date: ~datetime.datetime - :ivar tags: Tags of the original vault. - :vartype tags: dict[str, str] - :ivar purge_protection_enabled: Purge protection status of the original vault. - :vartype purge_protection_enabled: bool - """ - - _validation = { - "vault_id": {"readonly": True}, - "location": {"readonly": True}, - "deletion_date": {"readonly": True}, - "scheduled_purge_date": {"readonly": True}, - "tags": {"readonly": True}, - "purge_protection_enabled": {"readonly": True}, - } - - _attribute_map = { - "vault_id": {"key": "vaultId", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "deletion_date": {"key": "deletionDate", "type": "iso-8601"}, - "scheduled_purge_date": {"key": "scheduledPurgeDate", "type": "iso-8601"}, - "tags": {"key": "tags", "type": "{str}"}, - "purge_protection_enabled": {"key": "purgeProtectionEnabled", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vault_id: Optional[str] = None - self.location: Optional[str] = None - self.deletion_date: Optional[datetime.datetime] = None - self.scheduled_purge_date: Optional[datetime.datetime] = None - self.tags: Optional[dict[str, str]] = None - self.purge_protection_enabled: Optional[bool] = None - - -class DimensionProperties(_serialization.Model): - """Type of operation: get, read, delete, etc. - - :ivar name: Name of dimension. - :vartype name: str - :ivar display_name: Display name of dimension. - :vartype display_name: str - :ivar to_be_exported_for_shoebox: Property to specify whether the dimension should be exported - for Shoebox. - :vartype to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - to_be_exported_for_shoebox: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of dimension. - :paramtype name: str - :keyword display_name: Display name of dimension. - :paramtype display_name: str - :keyword to_be_exported_for_shoebox: Property to specify whether the dimension should be - exported for Shoebox. - :paramtype to_be_exported_for_shoebox: bool - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.to_be_exported_for_shoebox = to_be_exported_for_shoebox - - -class Error(_serialization.Model): - """The server error. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar inner_error: The inner error, contains a more specific error code. - :vartype inner_error: ~azure.mgmt.keyvault.models.Error - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "inner_error": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "inner_error": {"key": "innererror", "type": "Error"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.inner_error: Optional["_models.Error"] = None - - -class IPRule(_serialization.Model): - """A rule governing the accessibility of a vault from a specific ip address or ip range. - - All required parameters must be populated in order to send to server. - - :ivar value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) - or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. - :vartype value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: str, **kwargs: Any) -> None: - """ - :keyword value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP - address) or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class Resource(_serialization.Model): - """Key Vault resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.tags: Optional[dict[str, str]] = None - - -class Key(Resource): - """The key resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - :ivar attributes: The attributes of the key. - :vartype attributes: ~azure.mgmt.keyvault.models.KeyAttributes - :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", - "EC-HSM", "RSA", and "RSA-HSM". - :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :ivar key_ops: - :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA - and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :vartype key_size: int - :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default - for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". - :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :ivar key_uri: The URI to retrieve the current version of the key. - :vartype key_uri: str - :ivar key_uri_with_version: The URI to retrieve the specific version of the key. - :vartype key_uri_with_version: str - :ivar rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :vartype rotation_policy: ~azure.mgmt.keyvault.models.RotationPolicy - :ivar release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :vartype release_policy: ~azure.mgmt.keyvault.models.KeyReleasePolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": True}, - "key_uri": {"readonly": True}, - "key_uri_with_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "attributes": {"key": "properties.attributes", "type": "KeyAttributes"}, - "kty": {"key": "properties.kty", "type": "str"}, - "key_ops": {"key": "properties.keyOps", "type": "[str]"}, - "key_size": {"key": "properties.keySize", "type": "int"}, - "curve_name": {"key": "properties.curveName", "type": "str"}, - "key_uri": {"key": "properties.keyUri", "type": "str"}, - "key_uri_with_version": {"key": "properties.keyUriWithVersion", "type": "str"}, - "rotation_policy": {"key": "properties.rotationPolicy", "type": "RotationPolicy"}, - "release_policy": {"key": "properties.release_policy", "type": "KeyReleasePolicy"}, - } - - def __init__( - self, - *, - attributes: Optional["_models.KeyAttributes"] = None, - kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, - key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, - key_size: Optional[int] = None, - curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, - rotation_policy: Optional["_models.RotationPolicy"] = None, - release_policy: Optional["_models.KeyReleasePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword attributes: The attributes of the key. - :paramtype attributes: ~azure.mgmt.keyvault.models.KeyAttributes - :keyword kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: - "EC", "EC-HSM", "RSA", and "RSA-HSM". - :paramtype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :keyword key_ops: - :paramtype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :keyword key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for - RSA and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :paramtype key_size: int - :keyword curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. - Default for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and - "P-256K". - :paramtype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :keyword rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype rotation_policy: ~azure.mgmt.keyvault.models.RotationPolicy - :keyword release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype release_policy: ~azure.mgmt.keyvault.models.KeyReleasePolicy - """ - super().__init__(**kwargs) - self.attributes = attributes - self.kty = kty - self.key_ops = key_ops - self.key_size = key_size - self.curve_name = curve_name - self.key_uri: Optional[str] = None - self.key_uri_with_version: Optional[str] = None - self.rotation_policy = rotation_policy - self.release_policy = release_policy - - -class KeyAttributes(_serialization.Model): - """The object attributes managed by the Azure Key Vault service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar enabled: Determines whether or not the object is enabled. - :vartype enabled: bool - :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :vartype not_before: int - :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :vartype expires: int - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: int - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: int - :ivar recovery_level: The deletion recovery level currently in effect for the object. If it - contains 'Purgeable', then the object can be permanently deleted by a privileged user; - otherwise, only the system can purge the object at the end of the retention interval. Known - values are: "Purgeable", "Recoverable+Purgeable", "Recoverable", and - "Recoverable+ProtectedSubscription". - :vartype recovery_level: str or ~azure.mgmt.keyvault.models.DeletionRecoveryLevel - :ivar exportable: Indicates if the private key can be exported. - :vartype exportable: bool - """ - - _validation = { - "created": {"readonly": True}, - "updated": {"readonly": True}, - "recovery_level": {"readonly": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "not_before": {"key": "nbf", "type": "int"}, - "expires": {"key": "exp", "type": "int"}, - "created": {"key": "created", "type": "int"}, - "updated": {"key": "updated", "type": "int"}, - "recovery_level": {"key": "recoveryLevel", "type": "str"}, - "exportable": {"key": "exportable", "type": "bool"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - not_before: Optional[int] = None, - expires: Optional[int] = None, - exportable: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Determines whether or not the object is enabled. - :paramtype enabled: bool - :keyword not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :paramtype not_before: int - :keyword expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :paramtype expires: int - :keyword exportable: Indicates if the private key can be exported. - :paramtype exportable: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - self.not_before = not_before - self.expires = expires - self.created: Optional[int] = None - self.updated: Optional[int] = None - self.recovery_level: Optional[Union[str, "_models.DeletionRecoveryLevel"]] = None - self.exportable = exportable - - -class KeyCreateParameters(_serialization.Model): - """The parameters used to create a key. - - All required parameters must be populated in order to send to server. - - :ivar tags: The tags that will be assigned to the key. - :vartype tags: dict[str, str] - :ivar properties: The properties of the key to be created. Required. - :vartype properties: ~azure.mgmt.keyvault.models.KeyProperties - """ - - _validation = { - "properties": {"required": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "KeyProperties"}, - } - - def __init__( - self, *, properties: "_models.KeyProperties", tags: Optional[dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: The tags that will be assigned to the key. - :paramtype tags: dict[str, str] - :keyword properties: The properties of the key to be created. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.KeyProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class KeyListResult(_serialization.Model): - """The page of keys. - - :ivar value: The key resources. - :vartype value: list[~azure.mgmt.keyvault.models.Key] - :ivar next_link: The URL to get the next page of keys. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Key]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Key"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The key resources. - :paramtype value: list[~azure.mgmt.keyvault.models.Key] - :keyword next_link: The URL to get the next page of keys. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class KeyProperties(_serialization.Model): - """The properties of the key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar attributes: The attributes of the key. - :vartype attributes: ~azure.mgmt.keyvault.models.KeyAttributes - :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", - "EC-HSM", "RSA", and "RSA-HSM". - :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :ivar key_ops: - :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA - and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :vartype key_size: int - :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default - for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". - :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :ivar key_uri: The URI to retrieve the current version of the key. - :vartype key_uri: str - :ivar key_uri_with_version: The URI to retrieve the specific version of the key. - :vartype key_uri_with_version: str - :ivar rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :vartype rotation_policy: ~azure.mgmt.keyvault.models.RotationPolicy - :ivar release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :vartype release_policy: ~azure.mgmt.keyvault.models.KeyReleasePolicy - """ - - _validation = { - "key_uri": {"readonly": True}, - "key_uri_with_version": {"readonly": True}, - } - - _attribute_map = { - "attributes": {"key": "attributes", "type": "KeyAttributes"}, - "kty": {"key": "kty", "type": "str"}, - "key_ops": {"key": "keyOps", "type": "[str]"}, - "key_size": {"key": "keySize", "type": "int"}, - "curve_name": {"key": "curveName", "type": "str"}, - "key_uri": {"key": "keyUri", "type": "str"}, - "key_uri_with_version": {"key": "keyUriWithVersion", "type": "str"}, - "rotation_policy": {"key": "rotationPolicy", "type": "RotationPolicy"}, - "release_policy": {"key": "release_policy", "type": "KeyReleasePolicy"}, - } - - def __init__( - self, - *, - attributes: Optional["_models.KeyAttributes"] = None, - kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, - key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, - key_size: Optional[int] = None, - curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, - rotation_policy: Optional["_models.RotationPolicy"] = None, - release_policy: Optional["_models.KeyReleasePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword attributes: The attributes of the key. - :paramtype attributes: ~azure.mgmt.keyvault.models.KeyAttributes - :keyword kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: - "EC", "EC-HSM", "RSA", and "RSA-HSM". - :paramtype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :keyword key_ops: - :paramtype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :keyword key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for - RSA and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :paramtype key_size: int - :keyword curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. - Default for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and - "P-256K". - :paramtype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :keyword rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype rotation_policy: ~azure.mgmt.keyvault.models.RotationPolicy - :keyword release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype release_policy: ~azure.mgmt.keyvault.models.KeyReleasePolicy - """ - super().__init__(**kwargs) - self.attributes = attributes - self.kty = kty - self.key_ops = key_ops - self.key_size = key_size - self.curve_name = curve_name - self.key_uri: Optional[str] = None - self.key_uri_with_version: Optional[str] = None - self.rotation_policy = rotation_policy - self.release_policy = release_policy - - -class KeyReleasePolicy(_serialization.Model): - """KeyReleasePolicy. - - :ivar content_type: Content type and version of key release policy. - :vartype content_type: str - :ivar data: Blob encoding the policy rules under which the key can be released. - :vartype data: bytes - """ - - _attribute_map = { - "content_type": {"key": "contentType", "type": "str"}, - "data": {"key": "data", "type": "base64"}, - } - - def __init__( - self, *, content_type: str = "application/json; charset=utf-8", data: Optional[bytes] = None, **kwargs: Any - ) -> None: - """ - :keyword content_type: Content type and version of key release policy. - :paramtype content_type: str - :keyword data: Blob encoding the policy rules under which the key can be released. - :paramtype data: bytes - """ - super().__init__(**kwargs) - self.content_type = content_type - self.data = data - - -class KeyRotationPolicyAttributes(_serialization.Model): - """KeyRotationPolicyAttributes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: int - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: int - :ivar expiry_time: The expiration time for the new key version. It should be in ISO8601 format. - Eg: 'P90D', 'P1Y'. - :vartype expiry_time: str - """ - - _validation = { - "created": {"readonly": True}, - "updated": {"readonly": True}, - } - - _attribute_map = { - "created": {"key": "created", "type": "int"}, - "updated": {"key": "updated", "type": "int"}, - "expiry_time": {"key": "expiryTime", "type": "str"}, - } - - def __init__(self, *, expiry_time: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword expiry_time: The expiration time for the new key version. It should be in ISO8601 - format. Eg: 'P90D', 'P1Y'. - :paramtype expiry_time: str - """ - super().__init__(**kwargs) - self.created: Optional[int] = None - self.updated: Optional[int] = None - self.expiry_time = expiry_time - - -class LifetimeAction(_serialization.Model): - """LifetimeAction. - - :ivar trigger: The trigger of key rotation policy lifetimeAction. - :vartype trigger: ~azure.mgmt.keyvault.models.Trigger - :ivar action: The action of key rotation policy lifetimeAction. - :vartype action: ~azure.mgmt.keyvault.models.Action - """ - - _attribute_map = { - "trigger": {"key": "trigger", "type": "Trigger"}, - "action": {"key": "action", "type": "Action"}, - } - - def __init__( - self, *, trigger: Optional["_models.Trigger"] = None, action: Optional["_models.Action"] = None, **kwargs: Any - ) -> None: - """ - :keyword trigger: The trigger of key rotation policy lifetimeAction. - :paramtype trigger: ~azure.mgmt.keyvault.models.Trigger - :keyword action: The action of key rotation policy lifetimeAction. - :paramtype action: ~azure.mgmt.keyvault.models.Action - """ - super().__init__(**kwargs) - self.trigger = trigger - self.action = action - - -class LogSpecification(_serialization.Model): - """Log specification of operation. - - :ivar name: Name of log specification. - :vartype name: str - :ivar display_name: Display name of log specification. - :vartype display_name: str - :ivar blob_duration: Blob duration of specification. - :vartype blob_duration: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "blob_duration": {"key": "blobDuration", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - blob_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of log specification. - :paramtype name: str - :keyword display_name: Display name of log specification. - :paramtype display_name: str - :keyword blob_duration: Blob duration of specification. - :paramtype blob_duration: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.blob_duration = blob_duration - - -class ManagedHsmResource(_serialization.Model): - """Managed HSM resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. - :vartype id: str - :ivar name: The name of the managed HSM Pool. - :vartype name: str - :ivar type: The resource type of the managed HSM Pool. - :vartype type: str - :ivar location: The supported Azure location where the managed HSM Pool should be created. - :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the key vault - resource. - :vartype system_data: ~azure.mgmt.keyvault.models.SystemData - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - """ - - _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"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ManagedHsmSku"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - sku: Optional["_models.ManagedHsmSku"] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the managed HSM Pool should be created. - :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.sku = sku - self.tags = tags - self.system_data: Optional["_models.SystemData"] = None - self.identity = identity - - -class ManagedHsm(ManagedHsmResource): - """Resource information with extended details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. - :vartype id: str - :ivar name: The name of the managed HSM Pool. - :vartype name: str - :ivar type: The resource type of the managed HSM Pool. - :vartype type: str - :ivar location: The supported Azure location where the managed HSM Pool should be created. - :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the key vault - resource. - :vartype system_data: ~azure.mgmt.keyvault.models.SystemData - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :ivar properties: Properties of the managed HSM. - :vartype properties: ~azure.mgmt.keyvault.models.ManagedHsmProperties - """ - - _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"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ManagedHsmSku"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "properties": {"key": "properties", "type": "ManagedHsmProperties"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - sku: Optional["_models.ManagedHsmSku"] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - properties: Optional["_models.ManagedHsmProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the managed HSM Pool should be created. - :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :keyword properties: Properties of the managed HSM. - :paramtype properties: ~azure.mgmt.keyvault.models.ManagedHsmProperties - """ - super().__init__(location=location, sku=sku, tags=tags, identity=identity, **kwargs) - self.properties = properties - - -class ManagedHsmAction(_serialization.Model): - """ManagedHsmAction. - - :ivar type: The type of action. Known values are: "rotate" and "notify". - :vartype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, *, type: Optional[Union[str, "_models.KeyRotationPolicyActionType"]] = None, **kwargs: Any - ) -> None: - """ - :keyword type: The type of action. Known values are: "rotate" and "notify". - :paramtype type: str or ~azure.mgmt.keyvault.models.KeyRotationPolicyActionType - """ - super().__init__(**kwargs) - self.type = type - - -class ManagedHsmError(_serialization.Model): - """The error exception. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error: The server error. - :vartype error: ~azure.mgmt.keyvault.models.Error - """ - - _validation = { - "error": {"readonly": True}, - } - - _attribute_map = { - "error": {"key": "error", "type": "Error"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.error: Optional["_models.Error"] = None - - -class ProxyResourceWithoutSystemData(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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 tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class ManagedHsmKey(ProxyResourceWithoutSystemData): - """The key resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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 tags: Resource tags. - :vartype tags: dict[str, str] - :ivar attributes: The attributes of the key. - :vartype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyAttributes - :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", - "EC-HSM", "RSA", and "RSA-HSM". - :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :ivar key_ops: - :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA - and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :vartype key_size: int - :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default - for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". - :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :ivar key_uri: The URI to retrieve the current version of the key. - :vartype key_uri: str - :ivar key_uri_with_version: The URI to retrieve the specific version of the key. - :vartype key_uri_with_version: str - :ivar rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :vartype rotation_policy: ~azure.mgmt.keyvault.models.ManagedHsmRotationPolicy - :ivar release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :vartype release_policy: ~azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "key_uri": {"readonly": True}, - "key_uri_with_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "attributes": {"key": "properties.attributes", "type": "ManagedHsmKeyAttributes"}, - "kty": {"key": "properties.kty", "type": "str"}, - "key_ops": {"key": "properties.keyOps", "type": "[str]"}, - "key_size": {"key": "properties.keySize", "type": "int"}, - "curve_name": {"key": "properties.curveName", "type": "str"}, - "key_uri": {"key": "properties.keyUri", "type": "str"}, - "key_uri_with_version": {"key": "properties.keyUriWithVersion", "type": "str"}, - "rotation_policy": {"key": "properties.rotationPolicy", "type": "ManagedHsmRotationPolicy"}, - "release_policy": {"key": "properties.release_policy", "type": "ManagedHsmKeyReleasePolicy"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - attributes: Optional["_models.ManagedHsmKeyAttributes"] = None, - kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, - key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, - key_size: Optional[int] = None, - curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, - rotation_policy: Optional["_models.ManagedHsmRotationPolicy"] = None, - release_policy: Optional["_models.ManagedHsmKeyReleasePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword attributes: The attributes of the key. - :paramtype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyAttributes - :keyword kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: - "EC", "EC-HSM", "RSA", and "RSA-HSM". - :paramtype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :keyword key_ops: - :paramtype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :keyword key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for - RSA and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :paramtype key_size: int - :keyword curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. - Default for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and - "P-256K". - :paramtype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :keyword rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype rotation_policy: ~azure.mgmt.keyvault.models.ManagedHsmRotationPolicy - :keyword release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype release_policy: ~azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy - """ - super().__init__(tags=tags, **kwargs) - self.attributes = attributes - self.kty = kty - self.key_ops = key_ops - self.key_size = key_size - self.curve_name = curve_name - self.key_uri: Optional[str] = None - self.key_uri_with_version: Optional[str] = None - self.rotation_policy = rotation_policy - self.release_policy = release_policy - - -class ManagedHsmKeyAttributes(_serialization.Model): - """The object attributes managed by the Azure Key Vault service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar enabled: Determines whether or not the object is enabled. - :vartype enabled: bool - :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :vartype not_before: int - :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :vartype expires: int - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: int - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: int - :ivar recovery_level: The deletion recovery level currently in effect for the object. If it - contains 'Purgeable', then the object can be permanently deleted by a privileged user; - otherwise, only the system can purge the object at the end of the retention interval. Known - values are: "Purgeable", "Recoverable+Purgeable", "Recoverable", and - "Recoverable+ProtectedSubscription". - :vartype recovery_level: str or ~azure.mgmt.keyvault.models.DeletionRecoveryLevel - :ivar exportable: Indicates if the private key can be exported. - :vartype exportable: bool - """ - - _validation = { - "created": {"readonly": True}, - "updated": {"readonly": True}, - "recovery_level": {"readonly": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "not_before": {"key": "nbf", "type": "int"}, - "expires": {"key": "exp", "type": "int"}, - "created": {"key": "created", "type": "int"}, - "updated": {"key": "updated", "type": "int"}, - "recovery_level": {"key": "recoveryLevel", "type": "str"}, - "exportable": {"key": "exportable", "type": "bool"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - not_before: Optional[int] = None, - expires: Optional[int] = None, - exportable: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Determines whether or not the object is enabled. - :paramtype enabled: bool - :keyword not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :paramtype not_before: int - :keyword expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :paramtype expires: int - :keyword exportable: Indicates if the private key can be exported. - :paramtype exportable: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - self.not_before = not_before - self.expires = expires - self.created: Optional[int] = None - self.updated: Optional[int] = None - self.recovery_level: Optional[Union[str, "_models.DeletionRecoveryLevel"]] = None - self.exportable = exportable - - -class ManagedHsmKeyCreateParameters(_serialization.Model): - """The parameters used to create a key. - - All required parameters must be populated in order to send to server. - - :ivar tags: The tags that will be assigned to the key. - :vartype tags: dict[str, str] - :ivar properties: The properties of the key to be created. Required. - :vartype properties: ~azure.mgmt.keyvault.models.ManagedHsmKeyProperties - """ - - _validation = { - "properties": {"required": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "ManagedHsmKeyProperties"}, - } - - def __init__( - self, *, properties: "_models.ManagedHsmKeyProperties", tags: Optional[dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: The tags that will be assigned to the key. - :paramtype tags: dict[str, str] - :keyword properties: The properties of the key to be created. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.ManagedHsmKeyProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class ManagedHsmKeyListResult(_serialization.Model): - """The page of keys. - - :ivar value: The key resources. - :vartype value: list[~azure.mgmt.keyvault.models.ManagedHsmKey] - :ivar next_link: The URL to get the next page of keys. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedHsmKey]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.ManagedHsmKey"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The key resources. - :paramtype value: list[~azure.mgmt.keyvault.models.ManagedHsmKey] - :keyword next_link: The URL to get the next page of keys. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ManagedHsmKeyProperties(_serialization.Model): - """The properties of the key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar attributes: The attributes of the key. - :vartype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyAttributes - :ivar kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", - "EC-HSM", "RSA", and "RSA-HSM". - :vartype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :ivar key_ops: - :vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :ivar key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA - and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :vartype key_size: int - :ivar curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. Default - for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". - :vartype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :ivar key_uri: The URI to retrieve the current version of the key. - :vartype key_uri: str - :ivar key_uri_with_version: The URI to retrieve the specific version of the key. - :vartype key_uri_with_version: str - :ivar rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :vartype rotation_policy: ~azure.mgmt.keyvault.models.ManagedHsmRotationPolicy - :ivar release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :vartype release_policy: ~azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy - """ - - _validation = { - "key_uri": {"readonly": True}, - "key_uri_with_version": {"readonly": True}, - } - - _attribute_map = { - "attributes": {"key": "attributes", "type": "ManagedHsmKeyAttributes"}, - "kty": {"key": "kty", "type": "str"}, - "key_ops": {"key": "keyOps", "type": "[str]"}, - "key_size": {"key": "keySize", "type": "int"}, - "curve_name": {"key": "curveName", "type": "str"}, - "key_uri": {"key": "keyUri", "type": "str"}, - "key_uri_with_version": {"key": "keyUriWithVersion", "type": "str"}, - "rotation_policy": {"key": "rotationPolicy", "type": "ManagedHsmRotationPolicy"}, - "release_policy": {"key": "release_policy", "type": "ManagedHsmKeyReleasePolicy"}, - } - - def __init__( - self, - *, - attributes: Optional["_models.ManagedHsmKeyAttributes"] = None, - kty: Optional[Union[str, "_models.JsonWebKeyType"]] = None, - key_ops: Optional[list[Union[str, "_models.JsonWebKeyOperation"]]] = None, - key_size: Optional[int] = None, - curve_name: Optional[Union[str, "_models.JsonWebKeyCurveName"]] = None, - rotation_policy: Optional["_models.ManagedHsmRotationPolicy"] = None, - release_policy: Optional["_models.ManagedHsmKeyReleasePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword attributes: The attributes of the key. - :paramtype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyAttributes - :keyword kty: The type of the key. For valid values, see JsonWebKeyType. Known values are: - "EC", "EC-HSM", "RSA", and "RSA-HSM". - :paramtype kty: str or ~azure.mgmt.keyvault.models.JsonWebKeyType - :keyword key_ops: - :paramtype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation] - :keyword key_size: The key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for - RSA and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys - default to 4096. - :paramtype key_size: int - :keyword curve_name: The elliptic curve name. For valid values, see JsonWebKeyCurveName. - Default for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and - "P-256K". - :paramtype curve_name: str or ~azure.mgmt.keyvault.models.JsonWebKeyCurveName - :keyword rotation_policy: Key rotation policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype rotation_policy: ~azure.mgmt.keyvault.models.ManagedHsmRotationPolicy - :keyword release_policy: Key release policy in response. It will be used for both output and - input. Omitted if empty. - :paramtype release_policy: ~azure.mgmt.keyvault.models.ManagedHsmKeyReleasePolicy - """ - super().__init__(**kwargs) - self.attributes = attributes - self.kty = kty - self.key_ops = key_ops - self.key_size = key_size - self.curve_name = curve_name - self.key_uri: Optional[str] = None - self.key_uri_with_version: Optional[str] = None - self.rotation_policy = rotation_policy - self.release_policy = release_policy - - -class ManagedHsmKeyReleasePolicy(_serialization.Model): - """ManagedHsmKeyReleasePolicy. - - :ivar content_type: Content type and version of key release policy. - :vartype content_type: str - :ivar data: Blob encoding the policy rules under which the key can be released. - :vartype data: bytes - """ - - _attribute_map = { - "content_type": {"key": "contentType", "type": "str"}, - "data": {"key": "data", "type": "base64"}, - } - - def __init__( - self, *, content_type: str = "application/json; charset=utf-8", data: Optional[bytes] = None, **kwargs: Any - ) -> None: - """ - :keyword content_type: Content type and version of key release policy. - :paramtype content_type: str - :keyword data: Blob encoding the policy rules under which the key can be released. - :paramtype data: bytes - """ - super().__init__(**kwargs) - self.content_type = content_type - self.data = data - - -class ManagedHsmKeyRotationPolicyAttributes(_serialization.Model): - """ManagedHsmKeyRotationPolicyAttributes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: int - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: int - :ivar expiry_time: The expiration time for the new key version. It should be in ISO8601 format. - Eg: 'P90D', 'P1Y'. - :vartype expiry_time: str - """ - - _validation = { - "created": {"readonly": True}, - "updated": {"readonly": True}, - } - - _attribute_map = { - "created": {"key": "created", "type": "int"}, - "updated": {"key": "updated", "type": "int"}, - "expiry_time": {"key": "expiryTime", "type": "str"}, - } - - def __init__(self, *, expiry_time: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword expiry_time: The expiration time for the new key version. It should be in ISO8601 - format. Eg: 'P90D', 'P1Y'. - :paramtype expiry_time: str - """ - super().__init__(**kwargs) - self.created: Optional[int] = None - self.updated: Optional[int] = None - self.expiry_time = expiry_time - - -class ManagedHsmLifetimeAction(_serialization.Model): - """ManagedHsmLifetimeAction. - - :ivar trigger: The trigger of key rotation policy lifetimeAction. - :vartype trigger: ~azure.mgmt.keyvault.models.ManagedHsmTrigger - :ivar action: The action of key rotation policy lifetimeAction. - :vartype action: ~azure.mgmt.keyvault.models.ManagedHsmAction - """ - - _attribute_map = { - "trigger": {"key": "trigger", "type": "ManagedHsmTrigger"}, - "action": {"key": "action", "type": "ManagedHsmAction"}, - } - - def __init__( - self, - *, - trigger: Optional["_models.ManagedHsmTrigger"] = None, - action: Optional["_models.ManagedHsmAction"] = None, - **kwargs: Any - ) -> None: - """ - :keyword trigger: The trigger of key rotation policy lifetimeAction. - :paramtype trigger: ~azure.mgmt.keyvault.models.ManagedHsmTrigger - :keyword action: The action of key rotation policy lifetimeAction. - :paramtype action: ~azure.mgmt.keyvault.models.ManagedHsmAction - """ - super().__init__(**kwargs) - self.trigger = trigger - self.action = action - - -class ManagedHsmListResult(_serialization.Model): - """List of managed HSM Pools. - - :ivar value: The list of managed HSM Pools. - :vartype value: list[~azure.mgmt.keyvault.models.ManagedHsm] - :ivar next_link: The URL to get the next set of managed HSM Pools. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedHsm]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.ManagedHsm"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of managed HSM Pools. - :paramtype value: list[~azure.mgmt.keyvault.models.ManagedHsm] - :keyword next_link: The URL to get the next set of managed HSM Pools. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ManagedHsmProperties(_serialization.Model): - """Properties of the managed HSM Pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the managed HSM pool. - :vartype tenant_id: str - :ivar initial_admin_object_ids: Array of initial administrators object ids for this managed hsm - pool. - :vartype initial_admin_object_ids: list[str] - :ivar hsm_uri: The URI of the managed hsm pool for performing operations on keys. - :vartype hsm_uri: str - :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this managed HSM pool. Soft delete is enabled by default for all managed HSMs and - is immutable. - :vartype enable_soft_delete: bool - :ivar soft_delete_retention_in_days: Soft deleted data retention days. When you delete an HSM - or a key, it will remain recoverable for the configured retention period or for a default - period of 90 days. It accepts values between 7 and 90. - :vartype soft_delete_retention_in_days: int - :ivar enable_purge_protection: Property specifying whether protection against purge is enabled - for this managed HSM pool. Setting this property to true activates protection against purge for - this managed HSM pool and its content - only the Managed HSM service may initiate a hard, - irrecoverable deletion. Enabling this functionality is irreversible. - :vartype enable_purge_protection: bool - :ivar create_mode: The create mode to indicate whether the resource is being created or is - being recovered from a deleted resource. Known values are: "recover" and "default". - :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :ivar status_message: Resource Status Message. - :vartype status_message: str - :ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Provisioning", - "Failed", "Updating", "Deleting", "Activated", "SecurityDomainRestore", and "Restoring". - :vartype provisioning_state: str or ~azure.mgmt.keyvault.models.ProvisioningState - :ivar network_acls: Rules governing the accessibility of the key vault from specific network - locations. - :vartype network_acls: ~azure.mgmt.keyvault.models.MHSMNetworkRuleSet - :ivar regions: List of all regions associated with the managed hsm pool. - :vartype regions: list[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :ivar private_endpoint_connections: List of private endpoint connections associated with the - managed hsm pool. - :vartype private_endpoint_connections: - list[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnectionItem] - :ivar public_network_access: Control permission to the managed HSM from public networks. Known - values are: "Enabled" and "Disabled". - :vartype public_network_access: str or ~azure.mgmt.keyvault.models.PublicNetworkAccess - :ivar scheduled_purge_date: The scheduled purge date in UTC. - :vartype scheduled_purge_date: ~datetime.datetime - :ivar security_domain_properties: Managed HSM security domain properties. - :vartype security_domain_properties: - ~azure.mgmt.keyvault.models.ManagedHSMSecurityDomainProperties - """ - - _validation = { - "hsm_uri": {"readonly": True}, - "status_message": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "scheduled_purge_date": {"readonly": True}, - "security_domain_properties": {"readonly": True}, - } - - _attribute_map = { - "tenant_id": {"key": "tenantId", "type": "str"}, - "initial_admin_object_ids": {"key": "initialAdminObjectIds", "type": "[str]"}, - "hsm_uri": {"key": "hsmUri", "type": "str"}, - "enable_soft_delete": {"key": "enableSoftDelete", "type": "bool"}, - "soft_delete_retention_in_days": {"key": "softDeleteRetentionInDays", "type": "int"}, - "enable_purge_protection": {"key": "enablePurgeProtection", "type": "bool"}, - "create_mode": {"key": "createMode", "type": "str"}, - "status_message": {"key": "statusMessage", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "network_acls": {"key": "networkAcls", "type": "MHSMNetworkRuleSet"}, - "regions": {"key": "regions", "type": "[MHSMGeoReplicatedRegion]"}, - "private_endpoint_connections": { - "key": "privateEndpointConnections", - "type": "[MHSMPrivateEndpointConnectionItem]", - }, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - "scheduled_purge_date": {"key": "scheduledPurgeDate", "type": "iso-8601"}, - "security_domain_properties": {"key": "securityDomainProperties", "type": "ManagedHSMSecurityDomainProperties"}, - } - - def __init__( - self, - *, - tenant_id: Optional[str] = None, - initial_admin_object_ids: Optional[list[str]] = None, - enable_soft_delete: bool = True, - soft_delete_retention_in_days: int = 90, - enable_purge_protection: bool = True, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - network_acls: Optional["_models.MHSMNetworkRuleSet"] = None, - regions: Optional[list["_models.MHSMGeoReplicatedRegion"]] = None, - public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", - **kwargs: Any - ) -> None: - """ - :keyword tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the managed HSM pool. - :paramtype tenant_id: str - :keyword initial_admin_object_ids: Array of initial administrators object ids for this managed - hsm pool. - :paramtype initial_admin_object_ids: list[str] - :keyword enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this managed HSM pool. Soft delete is enabled by default for all managed HSMs and - is immutable. - :paramtype enable_soft_delete: bool - :keyword soft_delete_retention_in_days: Soft deleted data retention days. When you delete an - HSM or a key, it will remain recoverable for the configured retention period or for a default - period of 90 days. It accepts values between 7 and 90. - :paramtype soft_delete_retention_in_days: int - :keyword enable_purge_protection: Property specifying whether protection against purge is - enabled for this managed HSM pool. Setting this property to true activates protection against - purge for this managed HSM pool and its content - only the Managed HSM service may initiate a - hard, irrecoverable deletion. Enabling this functionality is irreversible. - :paramtype enable_purge_protection: bool - :keyword create_mode: The create mode to indicate whether the resource is being created or is - being recovered from a deleted resource. Known values are: "recover" and "default". - :paramtype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :keyword network_acls: Rules governing the accessibility of the key vault from specific network - locations. - :paramtype network_acls: ~azure.mgmt.keyvault.models.MHSMNetworkRuleSet - :keyword regions: List of all regions associated with the managed hsm pool. - :paramtype regions: list[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :keyword public_network_access: Control permission to the managed HSM from public networks. - Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or ~azure.mgmt.keyvault.models.PublicNetworkAccess - """ - super().__init__(**kwargs) - self.tenant_id = tenant_id - self.initial_admin_object_ids = initial_admin_object_ids - self.hsm_uri: Optional[str] = None - self.enable_soft_delete = enable_soft_delete - self.soft_delete_retention_in_days = soft_delete_retention_in_days - self.enable_purge_protection = enable_purge_protection - self.create_mode = create_mode - self.status_message: Optional[str] = None - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - self.network_acls = network_acls - self.regions = regions - self.private_endpoint_connections: Optional[list["_models.MHSMPrivateEndpointConnectionItem"]] = None - self.public_network_access = public_network_access - self.scheduled_purge_date: Optional[datetime.datetime] = None - self.security_domain_properties: Optional["_models.ManagedHSMSecurityDomainProperties"] = None - - -class ManagedHsmRotationPolicy(_serialization.Model): - """ManagedHsmRotationPolicy. - - :ivar attributes: The attributes of key rotation policy. - :vartype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyRotationPolicyAttributes - :ivar lifetime_actions: The lifetimeActions for key rotation action. - :vartype lifetime_actions: list[~azure.mgmt.keyvault.models.ManagedHsmLifetimeAction] - """ - - _attribute_map = { - "attributes": {"key": "attributes", "type": "ManagedHsmKeyRotationPolicyAttributes"}, - "lifetime_actions": {"key": "lifetimeActions", "type": "[ManagedHsmLifetimeAction]"}, - } - - def __init__( - self, - *, - attributes: Optional["_models.ManagedHsmKeyRotationPolicyAttributes"] = None, - lifetime_actions: Optional[list["_models.ManagedHsmLifetimeAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword attributes: The attributes of key rotation policy. - :paramtype attributes: ~azure.mgmt.keyvault.models.ManagedHsmKeyRotationPolicyAttributes - :keyword lifetime_actions: The lifetimeActions for key rotation action. - :paramtype lifetime_actions: list[~azure.mgmt.keyvault.models.ManagedHsmLifetimeAction] - """ - super().__init__(**kwargs) - self.attributes = attributes - self.lifetime_actions = lifetime_actions - - -class ManagedHSMSecurityDomainProperties(_serialization.Model): - """The security domain properties of the managed hsm. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar activation_status: Activation Status. Known values are: "Active", "NotActivated", - "Unknown", and "Failed". - :vartype activation_status: str or ~azure.mgmt.keyvault.models.ActivationStatus - :ivar activation_status_message: Activation Status Message. - :vartype activation_status_message: str - """ - - _validation = { - "activation_status": {"readonly": True}, - "activation_status_message": {"readonly": True}, - } - - _attribute_map = { - "activation_status": {"key": "activationStatus", "type": "str"}, - "activation_status_message": {"key": "activationStatusMessage", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.activation_status: Optional[Union[str, "_models.ActivationStatus"]] = None - self.activation_status_message: Optional[str] = None - - -class ManagedHsmSku(_serialization.Model): - """SKU details. - - All required parameters must be populated in order to send to server. - - :ivar family: SKU Family of the managed HSM Pool. Known values are: "B" and "C". - :vartype family: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuFamily - :ivar name: SKU of the managed HSM Pool. Required. Known values are: "Standard_B1", - "Custom_B32", "Custom_B6", "Custom_C42", and "Custom_C10". - :vartype name: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuName - """ - - _validation = { - "family": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "family": {"key": "family", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - family: Union[str, "_models.ManagedHsmSkuFamily"] = "B", - name: Union[str, "_models.ManagedHsmSkuName"], - **kwargs: Any - ) -> None: - """ - :keyword family: SKU Family of the managed HSM Pool. Known values are: "B" and "C". - :paramtype family: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuFamily - :keyword name: SKU of the managed HSM Pool. Required. Known values are: "Standard_B1", - "Custom_B32", "Custom_B6", "Custom_C42", and "Custom_C10". - :paramtype name: str or ~azure.mgmt.keyvault.models.ManagedHsmSkuName - """ - super().__init__(**kwargs) - self.family = family - self.name = name - - -class ManagedHsmTrigger(_serialization.Model): - """ManagedHsmTrigger. - - :ivar time_after_create: The time duration after key creation to rotate the key. It only - applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :vartype time_after_create: str - :ivar time_before_expiry: The time duration before key expiring to rotate or notify. It will be - in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :vartype time_before_expiry: str - """ - - _attribute_map = { - "time_after_create": {"key": "timeAfterCreate", "type": "str"}, - "time_before_expiry": {"key": "timeBeforeExpiry", "type": "str"}, - } - - def __init__( - self, *, time_after_create: Optional[str] = None, time_before_expiry: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword time_after_create: The time duration after key creation to rotate the key. It only - applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :paramtype time_after_create: str - :keyword time_before_expiry: The time duration before key expiring to rotate or notify. It will - be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :paramtype time_before_expiry: str - """ - super().__init__(**kwargs) - self.time_after_create = time_after_create - self.time_before_expiry = time_before_expiry - - -class ManagedServiceIdentity(_serialization.Model): - """Managed service identity (system assigned and/or user assigned identities). - - 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.keyvault.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.keyvault.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "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, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :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.keyvault.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.keyvault.models.UserAssignedIdentity] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class MetricSpecification(_serialization.Model): - """Metric specification of operation. - - :ivar name: Name of metric specification. - :vartype name: str - :ivar display_name: Display name of metric specification. - :vartype display_name: str - :ivar display_description: Display description of metric specification. - :vartype display_description: str - :ivar unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. - :vartype unit: str - :ivar aggregation_type: The metric aggregation type. Possible values include: 'Average', - 'Count', 'Total'. - :vartype aggregation_type: str - :ivar supported_aggregation_types: The supported aggregation types for the metrics. - :vartype supported_aggregation_types: list[str] - :ivar supported_time_grain_types: The supported time grain types for the metrics. - :vartype supported_time_grain_types: list[str] - :ivar lock_aggregation_type: The metric lock aggregation type. - :vartype lock_aggregation_type: str - :ivar dimensions: The dimensions of metric. - :vartype dimensions: list[~azure.mgmt.keyvault.models.DimensionProperties] - :ivar fill_gap_with_zero: Property to specify whether to fill gap with zero. - :vartype fill_gap_with_zero: bool - :ivar internal_metric_name: The internal metric name. - :vartype internal_metric_name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "aggregation_type": {"key": "aggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, - "lock_aggregation_type": {"key": "lockAggregationType", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[DimensionProperties]"}, - "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, - "internal_metric_name": {"key": "internalMetricName", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - display_description: Optional[str] = None, - unit: Optional[str] = None, - aggregation_type: Optional[str] = None, - supported_aggregation_types: Optional[list[str]] = None, - supported_time_grain_types: Optional[list[str]] = None, - lock_aggregation_type: Optional[str] = None, - dimensions: Optional[list["_models.DimensionProperties"]] = None, - fill_gap_with_zero: Optional[bool] = None, - internal_metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of metric specification. - :paramtype name: str - :keyword display_name: Display name of metric specification. - :paramtype display_name: str - :keyword display_description: Display description of metric specification. - :paramtype display_description: str - :keyword unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. - :paramtype unit: str - :keyword aggregation_type: The metric aggregation type. Possible values include: 'Average', - 'Count', 'Total'. - :paramtype aggregation_type: str - :keyword supported_aggregation_types: The supported aggregation types for the metrics. - :paramtype supported_aggregation_types: list[str] - :keyword supported_time_grain_types: The supported time grain types for the metrics. - :paramtype supported_time_grain_types: list[str] - :keyword lock_aggregation_type: The metric lock aggregation type. - :paramtype lock_aggregation_type: str - :keyword dimensions: The dimensions of metric. - :paramtype dimensions: list[~azure.mgmt.keyvault.models.DimensionProperties] - :keyword fill_gap_with_zero: Property to specify whether to fill gap with zero. - :paramtype fill_gap_with_zero: bool - :keyword internal_metric_name: The internal metric name. - :paramtype internal_metric_name: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.display_description = display_description - self.unit = unit - self.aggregation_type = aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.supported_time_grain_types = supported_time_grain_types - self.lock_aggregation_type = lock_aggregation_type - self.dimensions = dimensions - self.fill_gap_with_zero = fill_gap_with_zero - self.internal_metric_name = internal_metric_name - - -class MHSMGeoReplicatedRegion(_serialization.Model): - """A region that this managed HSM Pool has been extended to. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the geo replicated region. - :vartype name: str - :ivar provisioning_state: Provisioning state of the geo replicated region. Known values are: - "Preprovisioning", "Provisioning", "Succeeded", "Failed", "Deleting", and "Cleanup". - :vartype provisioning_state: str or - ~azure.mgmt.keyvault.models.GeoReplicationRegionProvisioningState - :ivar is_primary: A boolean value that indicates whether the region is the primary region or a - secondary region. - :vartype is_primary: bool - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "is_primary": {"key": "isPrimary", "type": "bool"}, - } - - def __init__(self, *, name: Optional[str] = None, is_primary: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword name: Name of the geo replicated region. - :paramtype name: str - :keyword is_primary: A boolean value that indicates whether the region is the primary region or - a secondary region. - :paramtype is_primary: bool - """ - super().__init__(**kwargs) - self.name = name - self.provisioning_state: Optional[Union[str, "_models.GeoReplicationRegionProvisioningState"]] = None - self.is_primary = is_primary - - -class MHSMIPRule(_serialization.Model): - """A rule governing the accessibility of a managed HSM pool from a specific IP address or IP - range. - - All required parameters must be populated in order to send to server. - - :ivar value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) - or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. - :vartype value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: str, **kwargs: Any) -> None: - """ - :keyword value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP - address) or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class MHSMNetworkRuleSet(_serialization.Model): - """A set of rules governing the network accessibility of a managed hsm pool. - - :ivar bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or - 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and - "None". - :vartype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions - :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules - match. This is only used after the bypass property has been evaluated. Known values are: - "Allow" and "Deny". - :vartype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction - :ivar ip_rules: The list of IP address rules. - :vartype ip_rules: list[~azure.mgmt.keyvault.models.MHSMIPRule] - :ivar service_tags: The list of service tags. - :vartype service_tags: list[~azure.mgmt.keyvault.models.MHSMServiceTagRule] - :ivar virtual_network_rules: The list of virtual network rules. - :vartype virtual_network_rules: list[~azure.mgmt.keyvault.models.MHSMVirtualNetworkRule] - """ - - _attribute_map = { - "bypass": {"key": "bypass", "type": "str"}, - "default_action": {"key": "defaultAction", "type": "str"}, - "ip_rules": {"key": "ipRules", "type": "[MHSMIPRule]"}, - "service_tags": {"key": "serviceTags", "type": "[MHSMServiceTagRule]"}, - "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[MHSMVirtualNetworkRule]"}, - } - - def __init__( - self, - *, - bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, - default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = None, - ip_rules: Optional[list["_models.MHSMIPRule"]] = None, - service_tags: Optional[list["_models.MHSMServiceTagRule"]] = None, - virtual_network_rules: Optional[list["_models.MHSMVirtualNetworkRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or - 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and - "None". - :paramtype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions - :keyword default_action: The default action when no rule from ipRules and from - virtualNetworkRules match. This is only used after the bypass property has been evaluated. - Known values are: "Allow" and "Deny". - :paramtype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction - :keyword ip_rules: The list of IP address rules. - :paramtype ip_rules: list[~azure.mgmt.keyvault.models.MHSMIPRule] - :keyword service_tags: The list of service tags. - :paramtype service_tags: list[~azure.mgmt.keyvault.models.MHSMServiceTagRule] - :keyword virtual_network_rules: The list of virtual network rules. - :paramtype virtual_network_rules: list[~azure.mgmt.keyvault.models.MHSMVirtualNetworkRule] - """ - super().__init__(**kwargs) - self.bypass = bypass - self.default_action = default_action - self.ip_rules = ip_rules - self.service_tags = service_tags - self.virtual_network_rules = virtual_network_rules - - -class MHSMPrivateEndpoint(_serialization.Model): - """Private endpoint object properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Full identifier of the private endpoint resource. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class MHSMPrivateEndpointConnection(ManagedHsmResource): - """Private endpoint connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. - :vartype id: str - :ivar name: The name of the managed HSM Pool. - :vartype name: str - :ivar type: The resource type of the managed HSM Pool. - :vartype type: str - :ivar location: The supported Azure location where the managed HSM Pool should be created. - :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the key vault - resource. - :vartype system_data: ~azure.mgmt.keyvault.models.SystemData - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :ivar etag: Modified whenever there is a change in the state of private endpoint connection. - :vartype etag: str - :ivar private_endpoint: Properties of the private endpoint object. - :vartype private_endpoint: ~azure.mgmt.keyvault.models.MHSMPrivateEndpoint - :ivar private_link_service_connection_state: Approval state of the private link connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState - :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values - are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - - _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"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ManagedHsmSku"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "etag": {"key": "etag", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "MHSMPrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "MHSMPrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - sku: Optional["_models.ManagedHsmSku"] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - etag: Optional[str] = None, - private_endpoint: Optional["_models.MHSMPrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.MHSMPrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the managed HSM Pool should be created. - :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :keyword etag: Modified whenever there is a change in the state of private endpoint connection. - :paramtype etag: str - :keyword private_endpoint: Properties of the private endpoint object. - :paramtype private_endpoint: ~azure.mgmt.keyvault.models.MHSMPrivateEndpoint - :keyword private_link_service_connection_state: Approval state of the private link connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState - :keyword provisioning_state: Provisioning state of the private endpoint connection. Known - values are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :paramtype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - super().__init__(location=location, sku=sku, tags=tags, identity=identity, **kwargs) - self.etag = etag - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = provisioning_state - - -class MHSMPrivateEndpointConnectionItem(_serialization.Model): - """Private endpoint connection item. - - :ivar id: Id of private endpoint connection. - :vartype id: str - :ivar etag: Modified whenever there is a change in the state of private endpoint connection. - :vartype etag: str - :ivar private_endpoint: Properties of the private endpoint object. - :vartype private_endpoint: ~azure.mgmt.keyvault.models.MHSMPrivateEndpoint - :ivar private_link_service_connection_state: Approval state of the private link connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState - :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values - are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "MHSMPrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "MHSMPrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - etag: Optional[str] = None, - private_endpoint: Optional["_models.MHSMPrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.MHSMPrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of private endpoint connection. - :paramtype id: str - :keyword etag: Modified whenever there is a change in the state of private endpoint connection. - :paramtype etag: str - :keyword private_endpoint: Properties of the private endpoint object. - :paramtype private_endpoint: ~azure.mgmt.keyvault.models.MHSMPrivateEndpoint - :keyword private_link_service_connection_state: Approval state of the private link connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.MHSMPrivateLinkServiceConnectionState - :keyword provisioning_state: Provisioning state of the private endpoint connection. Known - values are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :paramtype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - super().__init__(**kwargs) - self.id = id - self.etag = etag - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = provisioning_state - - -class MHSMPrivateEndpointConnectionsListResult(_serialization.Model): - """List of private endpoint connections associated with a managed HSM Pools. - - :ivar value: The private endpoint connection associated with a managed HSM Pools. - :vartype value: list[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :ivar next_link: The URL to get the next set of managed HSM Pools. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MHSMPrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.MHSMPrivateEndpointConnection"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The private endpoint connection associated with a managed HSM Pools. - :paramtype value: list[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :keyword next_link: The URL to get the next set of managed HSM Pools. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class MHSMPrivateLinkResource(ManagedHsmResource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The Azure Resource Manager resource ID for the managed HSM Pool. - :vartype id: str - :ivar name: The name of the managed HSM Pool. - :vartype name: str - :ivar type: The resource type of the managed HSM Pool. - :vartype type: str - :ivar location: The supported Azure location where the managed HSM Pool should be created. - :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the key vault - resource. - :vartype system_data: ~azure.mgmt.keyvault.models.SystemData - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :ivar group_id: Group identifier of private link resource. - :vartype group_id: str - :ivar required_members: Required member names of private link resource. - :vartype required_members: list[str] - :ivar required_zone_names: Required DNS zone names of the the private link resource. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ManagedHsmSku"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - sku: Optional["_models.ManagedHsmSku"] = None, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - required_zone_names: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the managed HSM Pool should be created. - :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.keyvault.models.ManagedHsmSku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.keyvault.models.ManagedServiceIdentity - :keyword required_zone_names: Required DNS zone names of the the private link resource. - :paramtype required_zone_names: list[str] - """ - super().__init__(location=location, sku=sku, tags=tags, identity=identity, **kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - self.required_zone_names = required_zone_names - - -class MHSMPrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.keyvault.models.MHSMPrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MHSMPrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[list["_models.MHSMPrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.keyvault.models.MHSMPrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class MHSMPrivateLinkServiceConnectionState(_serialization.Model): - """An object that represents the approval state of the private link connection. - - :ivar status: Indicates whether the connection has been approved, rejected or removed by the - key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval or rejection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. "None" - :vartype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired - """ - - _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.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been approved, rejected or removed by the - key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval or rejection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. "None" - :paramtype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class MHSMRegionsListResult(_serialization.Model): - """List of regions associated with a managed HSM Pools. - - :ivar value: The region associated with a managed HSM Pools. - :vartype value: list[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :ivar next_link: The URL to get the next set of managed HSM Pools. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MHSMGeoReplicatedRegion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.MHSMGeoReplicatedRegion"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The region associated with a managed HSM Pools. - :paramtype value: list[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :keyword next_link: The URL to get the next set of managed HSM Pools. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class MHSMServiceTagRule(_serialization.Model): - """A rule governing the accessibility of a managed hsm pool from a specific service tags. - - All required parameters must be populated in order to send to server. - - :ivar tag: Name of the service tag. Required. - :vartype tag: str - """ - - _validation = { - "tag": {"required": True}, - } - - _attribute_map = { - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, tag: str, **kwargs: Any) -> None: - """ - :keyword tag: Name of the service tag. Required. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.tag = tag - - -class MHSMVirtualNetworkRule(_serialization.Model): - """A rule governing the accessibility of a managed hsm pool from a specific virtual network. - - All required parameters must be populated in order to send to server. - - :ivar id: Full resource id of a vnet subnet, such as - '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - Required. - :vartype id: str - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Full resource id of a vnet subnet, such as - '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class NetworkRuleSet(_serialization.Model): - """A set of rules governing the network accessibility of a vault. - - :ivar bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or - 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and - "None". - :vartype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions - :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules - match. This is only used after the bypass property has been evaluated. Known values are: - "Allow" and "Deny". - :vartype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction - :ivar ip_rules: The list of IP address rules. - :vartype ip_rules: list[~azure.mgmt.keyvault.models.IPRule] - :ivar virtual_network_rules: The list of virtual network rules. - :vartype virtual_network_rules: list[~azure.mgmt.keyvault.models.VirtualNetworkRule] - """ - - _attribute_map = { - "bypass": {"key": "bypass", "type": "str"}, - "default_action": {"key": "defaultAction", "type": "str"}, - "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, - "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, - } - - def __init__( - self, - *, - bypass: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, - default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = None, - ip_rules: Optional[list["_models.IPRule"]] = None, - virtual_network_rules: Optional[list["_models.VirtualNetworkRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword bypass: Tells what traffic can bypass network rules. This can be 'AzureServices' or - 'None'. If not specified the default is 'AzureServices'. Known values are: "AzureServices" and - "None". - :paramtype bypass: str or ~azure.mgmt.keyvault.models.NetworkRuleBypassOptions - :keyword default_action: The default action when no rule from ipRules and from - virtualNetworkRules match. This is only used after the bypass property has been evaluated. - Known values are: "Allow" and "Deny". - :paramtype default_action: str or ~azure.mgmt.keyvault.models.NetworkRuleAction - :keyword ip_rules: The list of IP address rules. - :paramtype ip_rules: list[~azure.mgmt.keyvault.models.IPRule] - :keyword virtual_network_rules: The list of virtual network rules. - :paramtype virtual_network_rules: list[~azure.mgmt.keyvault.models.VirtualNetworkRule] - """ - super().__init__(**kwargs) - self.bypass = bypass - self.default_action = default_action - self.ip_rules = ip_rules - self.virtual_network_rules = virtual_network_rules - - -class Operation(_serialization.Model): - """Key Vault REST API operation definition. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: Display metadata associated with the operation. - :vartype display: ~azure.mgmt.keyvault.models.OperationDisplay - :ivar origin: The origin of operations. - :vartype origin: str - :ivar is_data_action: Property to specify whether the action is a data action. - :vartype is_data_action: bool - :ivar service_specification: One property of operation, include metric specifications. - :vartype service_specification: ~azure.mgmt.keyvault.models.ServiceSpecification - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - is_data_action: Optional[bool] = None, - service_specification: Optional["_models.ServiceSpecification"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword display: Display metadata associated with the operation. - :paramtype display: ~azure.mgmt.keyvault.models.OperationDisplay - :keyword origin: The origin of operations. - :paramtype origin: str - :keyword is_data_action: Property to specify whether the action is a data action. - :paramtype is_data_action: bool - :keyword service_specification: One property of operation, include metric specifications. - :paramtype service_specification: ~azure.mgmt.keyvault.models.ServiceSpecification - """ - super().__init__(**kwargs) - self.name = name - self.display = display - self.origin = origin - self.is_data_action = is_data_action - self.service_specification = service_specification - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - :ivar provider: Service provider: Microsoft Key Vault. - :vartype provider: str - :ivar resource: Resource on which the operation is performed etc. - :vartype resource: str - :ivar operation: Type of operation: get, read, delete, etc. - :vartype operation: str - :ivar description: Description of operation. - :vartype description: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "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: Service provider: Microsoft Key Vault. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed etc. - :paramtype resource: str - :keyword operation: Type of operation: get, read, delete, etc. - :paramtype operation: str - :keyword description: Description of operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(_serialization.Model): - """Result of the request to list Storage operations. It contains a list of operations and a URL - link to get the next set of results. - - :ivar value: List of Storage operations supported by the Storage resource provider. - :vartype value: list[~azure.mgmt.keyvault.models.Operation] - :ivar next_link: The URL to get the next set of operations. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of Storage operations supported by the Storage resource provider. - :paramtype value: list[~azure.mgmt.keyvault.models.Operation] - :keyword next_link: The URL to get the next set of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Permissions(_serialization.Model): - """Permissions the identity has for keys, secrets, certificates and storage. - - :ivar keys: Permissions to keys. - :vartype keys: list[str or ~azure.mgmt.keyvault.models.KeyPermissions] - :ivar secrets: Permissions to secrets. - :vartype secrets: list[str or ~azure.mgmt.keyvault.models.SecretPermissions] - :ivar certificates: Permissions to certificates. - :vartype certificates: list[str or ~azure.mgmt.keyvault.models.CertificatePermissions] - :ivar storage: Permissions to storage accounts. - :vartype storage: list[str or ~azure.mgmt.keyvault.models.StoragePermissions] - """ - - _attribute_map = { - "keys": {"key": "keys", "type": "[str]"}, - "secrets": {"key": "secrets", "type": "[str]"}, - "certificates": {"key": "certificates", "type": "[str]"}, - "storage": {"key": "storage", "type": "[str]"}, - } - - def __init__( - self, - *, - keys: Optional[list[Union[str, "_models.KeyPermissions"]]] = None, - secrets: Optional[list[Union[str, "_models.SecretPermissions"]]] = None, - certificates: Optional[list[Union[str, "_models.CertificatePermissions"]]] = None, - storage: Optional[list[Union[str, "_models.StoragePermissions"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword keys: Permissions to keys. - :paramtype keys: list[str or ~azure.mgmt.keyvault.models.KeyPermissions] - :keyword secrets: Permissions to secrets. - :paramtype secrets: list[str or ~azure.mgmt.keyvault.models.SecretPermissions] - :keyword certificates: Permissions to certificates. - :paramtype certificates: list[str or ~azure.mgmt.keyvault.models.CertificatePermissions] - :keyword storage: Permissions to storage accounts. - :paramtype storage: list[str or ~azure.mgmt.keyvault.models.StoragePermissions] - """ - super().__init__(**kwargs) - self.keys = keys - self.secrets = secrets - self.certificates = certificates - self.storage = storage - - -class PrivateEndpoint(_serialization.Model): - """Private endpoint object properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Full identifier of the private endpoint resource. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(Resource): - """Private endpoint connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - :ivar etag: Modified whenever there is a change in the state of private endpoint connection. - :vartype etag: str - :ivar private_endpoint: Properties of the private endpoint object. - :vartype private_endpoint: ~azure.mgmt.keyvault.models.PrivateEndpoint - :ivar private_link_service_connection_state: Approval state of the private link connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values - are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - etag: Optional[str] = None, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword etag: Modified whenever there is a change in the state of private endpoint connection. - :paramtype etag: str - :keyword private_endpoint: Properties of the private endpoint object. - :paramtype private_endpoint: ~azure.mgmt.keyvault.models.PrivateEndpoint - :keyword private_link_service_connection_state: Approval state of the private link connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState - :keyword provisioning_state: Provisioning state of the private endpoint connection. Known - values are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :paramtype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - super().__init__(**kwargs) - self.etag = etag - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = provisioning_state - - -class PrivateEndpointConnectionItem(_serialization.Model): - """Private endpoint connection item. - - :ivar id: Id of private endpoint connection. - :vartype id: str - :ivar etag: Modified whenever there is a change in the state of private endpoint connection. - :vartype etag: str - :ivar private_endpoint: Properties of the private endpoint object. - :vartype private_endpoint: ~azure.mgmt.keyvault.models.PrivateEndpoint - :ivar private_link_service_connection_state: Approval state of the private link connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: Provisioning state of the private endpoint connection. Known values - are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :vartype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - etag: Optional[str] = None, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of private endpoint connection. - :paramtype id: str - :keyword etag: Modified whenever there is a change in the state of private endpoint connection. - :paramtype etag: str - :keyword private_endpoint: Properties of the private endpoint object. - :paramtype private_endpoint: ~azure.mgmt.keyvault.models.PrivateEndpoint - :keyword private_link_service_connection_state: Approval state of the private link connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.keyvault.models.PrivateLinkServiceConnectionState - :keyword provisioning_state: Provisioning state of the private endpoint connection. Known - values are: "Succeeded", "Creating", "Updating", "Deleting", "Failed", and "Disconnected". - :paramtype provisioning_state: str or - ~azure.mgmt.keyvault.models.PrivateEndpointConnectionProvisioningState - """ - super().__init__(**kwargs) - self.id = id - self.etag = etag - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = provisioning_state - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """List of private endpoint connections. - - :ivar value: The list of private endpoint connections. - :vartype value: list[~azure.mgmt.keyvault.models.PrivateEndpointConnection] - :ivar next_link: The URL to get the next set of private endpoint connections. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.PrivateEndpointConnection"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of private endpoint connections. - :paramtype value: list[~azure.mgmt.keyvault.models.PrivateEndpointConnection] - :keyword next_link: The URL to get the next set of private endpoint connections. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - :ivar group_id: Group identifier of private link resource. - :vartype group_id: str - :ivar required_members: Required member names of private link resource. - :vartype required_members: list[str] - :ivar required_zone_names: Required DNS zone names of the the private link resource. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: Required DNS zone names of the the private link resource. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.keyvault.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[list["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.keyvault.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """An object that represents the approval state of the private link connection. - - :ivar status: Indicates whether the connection has been approved, rejected or removed by the - key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :vartype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval or rejection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. "None" - :vartype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired - """ - - _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.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been approved, rejected or removed by the - key vault owner. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.keyvault.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval or rejection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. "None" - :paramtype actions_required: str or ~azure.mgmt.keyvault.models.ActionsRequired - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ResourceListResult(_serialization.Model): - """List of vault resources. - - :ivar value: The list of vault resources. - :vartype value: list[~azure.mgmt.keyvault.models.Resource] - :ivar next_link: The URL to get the next set of vault resources. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Resource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Resource"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of vault resources. - :paramtype value: list[~azure.mgmt.keyvault.models.Resource] - :keyword next_link: The URL to get the next set of vault resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RotationPolicy(_serialization.Model): - """RotationPolicy. - - :ivar attributes: The attributes of key rotation policy. - :vartype attributes: ~azure.mgmt.keyvault.models.KeyRotationPolicyAttributes - :ivar lifetime_actions: The lifetimeActions for key rotation action. - :vartype lifetime_actions: list[~azure.mgmt.keyvault.models.LifetimeAction] - """ - - _attribute_map = { - "attributes": {"key": "attributes", "type": "KeyRotationPolicyAttributes"}, - "lifetime_actions": {"key": "lifetimeActions", "type": "[LifetimeAction]"}, - } - - def __init__( - self, - *, - attributes: Optional["_models.KeyRotationPolicyAttributes"] = None, - lifetime_actions: Optional[list["_models.LifetimeAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword attributes: The attributes of key rotation policy. - :paramtype attributes: ~azure.mgmt.keyvault.models.KeyRotationPolicyAttributes - :keyword lifetime_actions: The lifetimeActions for key rotation action. - :paramtype lifetime_actions: list[~azure.mgmt.keyvault.models.LifetimeAction] - """ - super().__init__(**kwargs) - self.attributes = attributes - self.lifetime_actions = lifetime_actions - - -class Secret(Resource): - """Resource information with extended details. - - 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 identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - :ivar properties: Properties of the secret. Required. - :vartype properties: ~azure.mgmt.keyvault.models.SecretProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "SecretProperties"}, - } - - def __init__(self, *, properties: "_models.SecretProperties", **kwargs: Any) -> None: - """ - :keyword properties: Properties of the secret. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.SecretProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class SecretAttributes(Attributes): - """The secret management attributes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar enabled: Determines whether the object is enabled. - :vartype enabled: bool - :ivar not_before: Not before date in seconds since 1970-01-01T00:00:00Z. - :vartype not_before: ~datetime.datetime - :ivar expires: Expiry date in seconds since 1970-01-01T00:00:00Z. - :vartype expires: ~datetime.datetime - :ivar created: Creation time in seconds since 1970-01-01T00:00:00Z. - :vartype created: ~datetime.datetime - :ivar updated: Last updated time in seconds since 1970-01-01T00:00:00Z. - :vartype updated: ~datetime.datetime - """ - - -class SecretCreateOrUpdateParameters(_serialization.Model): - """Parameters for creating or updating a secret. - - All required parameters must be populated in order to send to server. - - :ivar tags: The tags that will be assigned to the secret. - :vartype tags: dict[str, str] - :ivar properties: Properties of the secret. Required. - :vartype properties: ~azure.mgmt.keyvault.models.SecretProperties - """ - - _validation = { - "properties": {"required": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "SecretProperties"}, - } - - def __init__( - self, *, properties: "_models.SecretProperties", tags: Optional[dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: The tags that will be assigned to the secret. - :paramtype tags: dict[str, str] - :keyword properties: Properties of the secret. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.SecretProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class SecretListResult(_serialization.Model): - """List of secrets. - - :ivar value: The list of secrets. - :vartype value: list[~azure.mgmt.keyvault.models.Secret] - :ivar next_link: The URL to get the next set of secrets. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Secret]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Secret"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of secrets. - :paramtype value: list[~azure.mgmt.keyvault.models.Secret] - :keyword next_link: The URL to get the next set of secrets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SecretPatchParameters(_serialization.Model): - """Parameters for patching a secret. - - :ivar tags: The tags that will be assigned to the secret. - :vartype tags: dict[str, str] - :ivar properties: Properties of the secret. - :vartype properties: ~azure.mgmt.keyvault.models.SecretPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "SecretPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - properties: Optional["_models.SecretPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The tags that will be assigned to the secret. - :paramtype tags: dict[str, str] - :keyword properties: Properties of the secret. - :paramtype properties: ~azure.mgmt.keyvault.models.SecretPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class SecretPatchProperties(_serialization.Model): - """Properties of the secret. - - :ivar value: The value of the secret. - :vartype value: str - :ivar content_type: The content type of the secret. - :vartype content_type: str - :ivar attributes: The attributes of the secret. - :vartype attributes: ~azure.mgmt.keyvault.models.SecretAttributes - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "content_type": {"key": "contentType", "type": "str"}, - "attributes": {"key": "attributes", "type": "SecretAttributes"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - content_type: Optional[str] = None, - attributes: Optional["_models.SecretAttributes"] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The value of the secret. - :paramtype value: str - :keyword content_type: The content type of the secret. - :paramtype content_type: str - :keyword attributes: The attributes of the secret. - :paramtype attributes: ~azure.mgmt.keyvault.models.SecretAttributes - """ - super().__init__(**kwargs) - self.value = value - self.content_type = content_type - self.attributes = attributes - - -class SecretProperties(_serialization.Model): - """Properties of the secret. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value of the secret. NOTE: 'value' will never be returned from the service, as - APIs using this model are is intended for internal use in ARM deployments. Users should use the - data-plane REST service for interaction with vault secrets. - :vartype value: str - :ivar content_type: The content type of the secret. - :vartype content_type: str - :ivar attributes: The attributes of the secret. - :vartype attributes: ~azure.mgmt.keyvault.models.SecretAttributes - :ivar secret_uri: The URI to retrieve the current version of the secret. - :vartype secret_uri: str - :ivar secret_uri_with_version: The URI to retrieve the specific version of the secret. - :vartype secret_uri_with_version: str - """ - - _validation = { - "secret_uri": {"readonly": True}, - "secret_uri_with_version": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "content_type": {"key": "contentType", "type": "str"}, - "attributes": {"key": "attributes", "type": "SecretAttributes"}, - "secret_uri": {"key": "secretUri", "type": "str"}, - "secret_uri_with_version": {"key": "secretUriWithVersion", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - content_type: Optional[str] = None, - attributes: Optional["_models.SecretAttributes"] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The value of the secret. NOTE: 'value' will never be returned from the service, - as APIs using this model are is intended for internal use in ARM deployments. Users should use - the data-plane REST service for interaction with vault secrets. - :paramtype value: str - :keyword content_type: The content type of the secret. - :paramtype content_type: str - :keyword attributes: The attributes of the secret. - :paramtype attributes: ~azure.mgmt.keyvault.models.SecretAttributes - """ - super().__init__(**kwargs) - self.value = value - self.content_type = content_type - self.attributes = attributes - self.secret_uri: Optional[str] = None - self.secret_uri_with_version: Optional[str] = None - - -class ServiceSpecification(_serialization.Model): - """One property of operation, include log specifications. - - :ivar log_specifications: Log specifications of operation. - :vartype log_specifications: list[~azure.mgmt.keyvault.models.LogSpecification] - :ivar metric_specifications: Metric specifications of operation. - :vartype metric_specifications: list[~azure.mgmt.keyvault.models.MetricSpecification] - """ - - _attribute_map = { - "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, - "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, - } - - def __init__( - self, - *, - log_specifications: Optional[list["_models.LogSpecification"]] = None, - metric_specifications: Optional[list["_models.MetricSpecification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_specifications: Log specifications of operation. - :paramtype log_specifications: list[~azure.mgmt.keyvault.models.LogSpecification] - :keyword metric_specifications: Metric specifications of operation. - :paramtype metric_specifications: list[~azure.mgmt.keyvault.models.MetricSpecification] - """ - super().__init__(**kwargs) - self.log_specifications = log_specifications - self.metric_specifications = metric_specifications - - -class Sku(_serialization.Model): - """SKU details. - - All required parameters must be populated in order to send to server. - - :ivar family: SKU family name. "A" - :vartype family: str or ~azure.mgmt.keyvault.models.SkuFamily - :ivar name: SKU name to specify whether the key vault is a standard vault or a premium vault. - Required. Known values are: "standard" and "premium". - :vartype name: str or ~azure.mgmt.keyvault.models.SkuName - """ - - _validation = { - "family": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "family": {"key": "family", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, family: Union[str, "_models.SkuFamily"] = "A", name: Union[str, "_models.SkuName"], **kwargs: Any - ) -> None: - """ - :keyword family: SKU family name. "A" - :paramtype family: str or ~azure.mgmt.keyvault.models.SkuFamily - :keyword name: SKU name to specify whether the key vault is a standard vault or a premium - vault. Required. Known values are: "standard" and "premium". - :paramtype name: str or ~azure.mgmt.keyvault.models.SkuName - """ - super().__init__(**kwargs) - self.family = family - self.name = name - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the key vault resource. - - :ivar created_by: The identity that created the key vault resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the key vault resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.keyvault.models.IdentityType - :ivar created_at: The timestamp of the key vault resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the key vault resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the key vault resource. - Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.keyvault.models.IdentityType - :ivar last_modified_at: The timestamp of the key vault 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[Union[str, "_models.IdentityType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the key vault resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the key vault resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.keyvault.models.IdentityType - :keyword created_at: The timestamp of the key vault resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the key vault resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the key vault resource. - Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.keyvault.models.IdentityType - :keyword last_modified_at: The timestamp of the key vault 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 Trigger(_serialization.Model): - """Trigger. - - :ivar time_after_create: The time duration after key creation to rotate the key. It only - applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :vartype time_after_create: str - :ivar time_before_expiry: The time duration before key expiring to rotate or notify. It will be - in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :vartype time_before_expiry: str - """ - - _attribute_map = { - "time_after_create": {"key": "timeAfterCreate", "type": "str"}, - "time_before_expiry": {"key": "timeBeforeExpiry", "type": "str"}, - } - - def __init__( - self, *, time_after_create: Optional[str] = None, time_before_expiry: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword time_after_create: The time duration after key creation to rotate the key. It only - applies to rotate. It will be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :paramtype time_after_create: str - :keyword time_before_expiry: The time duration before key expiring to rotate or notify. It will - be in ISO 8601 duration format. Eg: 'P90D', 'P1Y'. - :paramtype time_before_expiry: str - """ - super().__init__(**kwargs) - self.time_after_create = time_after_create - self.time_before_expiry = time_before_expiry - - -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 Vault(_serialization.Model): - """Resource information with extended details. - - 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 identifier of the key vault resource. - :vartype id: str - :ivar name: Name of the key vault resource. - :vartype name: str - :ivar type: Resource type of the key vault resource. - :vartype type: str - :ivar location: Azure location of the key vault resource. - :vartype location: str - :ivar tags: Tags assigned to the key vault resource. - :vartype tags: dict[str, str] - :ivar system_data: System metadata for the key vault. - :vartype system_data: ~azure.mgmt.keyvault.models.SystemData - :ivar properties: Properties of the vault. Required. - :vartype properties: ~azure.mgmt.keyvault.models.VaultProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "VaultProperties"}, - } - - def __init__( - self, - *, - properties: "_models.VaultProperties", - location: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Azure location of the key vault resource. - :paramtype location: str - :keyword tags: Tags assigned to the key vault resource. - :paramtype tags: dict[str, str] - :keyword properties: Properties of the vault. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.VaultProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - self.system_data: Optional["_models.SystemData"] = None - self.properties = properties - - -class VaultAccessPolicyParameters(_serialization.Model): - """Parameters for updating the access policy in a vault. - - 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: The resource id of the access policy. - :vartype id: str - :ivar name: The resource name of the access policy. - :vartype name: str - :ivar type: The resource name of the access policy. - :vartype type: str - :ivar location: The resource type of the access policy. - :vartype location: str - :ivar properties: Properties of the access policy. Required. - :vartype properties: ~azure.mgmt.keyvault.models.VaultAccessPolicyProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "VaultAccessPolicyProperties"}, - } - - def __init__(self, *, properties: "_models.VaultAccessPolicyProperties", **kwargs: Any) -> None: - """ - :keyword properties: Properties of the access policy. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.VaultAccessPolicyProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.properties = properties - - -class VaultAccessPolicyProperties(_serialization.Model): - """Properties of the vault access policy. - - All required parameters must be populated in order to send to server. - - :ivar access_policies: An array of 0 to 16 identities that have access to the key vault. All - identities in the array must use the same tenant ID as the key vault's tenant ID. Required. - :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - """ - - _validation = { - "access_policies": {"required": True}, - } - - _attribute_map = { - "access_policies": {"key": "accessPolicies", "type": "[AccessPolicyEntry]"}, - } - - def __init__(self, *, access_policies: list["_models.AccessPolicyEntry"], **kwargs: Any) -> None: - """ - :keyword access_policies: An array of 0 to 16 identities that have access to the key vault. All - identities in the array must use the same tenant ID as the key vault's tenant ID. Required. - :paramtype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - """ - super().__init__(**kwargs) - self.access_policies = access_policies - - -class VaultCheckNameAvailabilityParameters(_serialization.Model): - """The parameters used to check the availability of the vault name. - - 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 name: The vault name. Required. - :vartype name: str - :ivar type: The type of resource, Microsoft.KeyVault/vaults. Required. Default value is - "Microsoft.KeyVault/vaults". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.KeyVault/vaults" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: The vault name. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class VaultCreateOrUpdateParameters(_serialization.Model): - """Parameters for creating or updating a vault. - - All required parameters must be populated in order to send to server. - - :ivar location: The supported Azure location where the key vault should be created. Required. - :vartype location: str - :ivar tags: The tags that will be assigned to the key vault. - :vartype tags: dict[str, str] - :ivar properties: Properties of the vault. Required. - :vartype properties: ~azure.mgmt.keyvault.models.VaultProperties - """ - - _validation = { - "location": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "VaultProperties"}, - } - - def __init__( - self, - *, - location: str, - properties: "_models.VaultProperties", - tags: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the key vault should be created. - Required. - :paramtype location: str - :keyword tags: The tags that will be assigned to the key vault. - :paramtype tags: dict[str, str] - :keyword properties: Properties of the vault. Required. - :paramtype properties: ~azure.mgmt.keyvault.models.VaultProperties - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.properties = properties - - -class VaultListResult(_serialization.Model): - """List of vaults. - - :ivar value: The list of vaults. - :vartype value: list[~azure.mgmt.keyvault.models.Vault] - :ivar next_link: The URL to get the next set of vaults. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Vault]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Vault"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of vaults. - :paramtype value: list[~azure.mgmt.keyvault.models.Vault] - :keyword next_link: The URL to get the next set of vaults. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VaultPatchParameters(_serialization.Model): - """Parameters for creating or updating a vault. - - :ivar tags: The tags that will be assigned to the key vault. - :vartype tags: dict[str, str] - :ivar properties: Properties of the vault. - :vartype properties: ~azure.mgmt.keyvault.models.VaultPatchProperties - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "VaultPatchProperties"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - properties: Optional["_models.VaultPatchProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The tags that will be assigned to the key vault. - :paramtype tags: dict[str, str] - :keyword properties: Properties of the vault. - :paramtype properties: ~azure.mgmt.keyvault.models.VaultPatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class VaultPatchProperties(_serialization.Model): - """Properties of the vault. - - :ivar tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. - :vartype tenant_id: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.keyvault.models.Sku - :ivar access_policies: An array of 0 to 16 identities that have access to the key vault. All - identities in the array must use the same tenant ID as the key vault's tenant ID. - :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - :ivar enabled_for_deployment: Property to specify whether Azure Virtual Machines are permitted - to retrieve certificates stored as secrets from the key vault. - :vartype enabled_for_deployment: bool - :ivar enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is - permitted to retrieve secrets from the vault and unwrap keys. - :vartype enabled_for_disk_encryption: bool - :ivar enabled_for_template_deployment: Property to specify whether Azure Resource Manager is - permitted to retrieve secrets from the key vault. - :vartype enabled_for_template_deployment: bool - :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this key vault. Once set to true, it cannot be reverted to false. - :vartype enable_soft_delete: bool - :ivar enable_rbac_authorization: Property that controls how data actions are authorized. When - true, the key vault will use Role Based Access Control (RBAC) for authorization of data - actions, and the access policies specified in vault properties will be ignored. When false, - the key vault will use the access policies specified in vault properties, and any policy stored - on Azure Resource Manager will be ignored. If null or not specified, the value of this property - will not change. - :vartype enable_rbac_authorization: bool - :ivar soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and <=90. - :vartype soft_delete_retention_in_days: int - :ivar create_mode: The vault's create mode to indicate whether the vault need to be recovered - or not. Known values are: "recover" and "default". - :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :ivar enable_purge_protection: Property specifying whether protection against purge is enabled - for this vault. Setting this property to true activates protection against purge for this vault - and its content - only the Key Vault service may initiate a hard, irrecoverable deletion. The - setting is effective only if soft delete is also enabled. Enabling this functionality is - irreversible - that is, the property does not accept false as its value. - :vartype enable_purge_protection: bool - :ivar network_acls: A collection of rules governing the accessibility of the vault from - specific network locations. - :vartype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet - :ivar public_network_access: Property to specify whether the vault will accept traffic from - public internet. If set to 'disabled' all traffic except private endpoint traffic and that that - originates from trusted services will be blocked. This will override the set firewall rules, - meaning that even if the firewall rules are present we will not honor the rules. - :vartype public_network_access: str - """ - - _attribute_map = { - "tenant_id": {"key": "tenantId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "access_policies": {"key": "accessPolicies", "type": "[AccessPolicyEntry]"}, - "enabled_for_deployment": {"key": "enabledForDeployment", "type": "bool"}, - "enabled_for_disk_encryption": {"key": "enabledForDiskEncryption", "type": "bool"}, - "enabled_for_template_deployment": {"key": "enabledForTemplateDeployment", "type": "bool"}, - "enable_soft_delete": {"key": "enableSoftDelete", "type": "bool"}, - "enable_rbac_authorization": {"key": "enableRbacAuthorization", "type": "bool"}, - "soft_delete_retention_in_days": {"key": "softDeleteRetentionInDays", "type": "int"}, - "create_mode": {"key": "createMode", "type": "str"}, - "enable_purge_protection": {"key": "enablePurgeProtection", "type": "bool"}, - "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - tenant_id: Optional[str] = None, - sku: Optional["_models.Sku"] = None, - access_policies: Optional[list["_models.AccessPolicyEntry"]] = None, - enabled_for_deployment: Optional[bool] = None, - enabled_for_disk_encryption: Optional[bool] = None, - enabled_for_template_deployment: Optional[bool] = None, - enable_soft_delete: Optional[bool] = None, - enable_rbac_authorization: Optional[bool] = None, - soft_delete_retention_in_days: Optional[int] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - enable_purge_protection: Optional[bool] = None, - network_acls: Optional["_models.NetworkRuleSet"] = None, - public_network_access: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. - :paramtype tenant_id: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.keyvault.models.Sku - :keyword access_policies: An array of 0 to 16 identities that have access to the key vault. All - identities in the array must use the same tenant ID as the key vault's tenant ID. - :paramtype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - :keyword enabled_for_deployment: Property to specify whether Azure Virtual Machines are - permitted to retrieve certificates stored as secrets from the key vault. - :paramtype enabled_for_deployment: bool - :keyword enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is - permitted to retrieve secrets from the vault and unwrap keys. - :paramtype enabled_for_disk_encryption: bool - :keyword enabled_for_template_deployment: Property to specify whether Azure Resource Manager is - permitted to retrieve secrets from the key vault. - :paramtype enabled_for_template_deployment: bool - :keyword enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this key vault. Once set to true, it cannot be reverted to false. - :paramtype enable_soft_delete: bool - :keyword enable_rbac_authorization: Property that controls how data actions are authorized. - When true, the key vault will use Role Based Access Control (RBAC) for authorization of data - actions, and the access policies specified in vault properties will be ignored. When false, - the key vault will use the access policies specified in vault properties, and any policy stored - on Azure Resource Manager will be ignored. If null or not specified, the value of this property - will not change. - :paramtype enable_rbac_authorization: bool - :keyword soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and - <=90. - :paramtype soft_delete_retention_in_days: int - :keyword create_mode: The vault's create mode to indicate whether the vault need to be - recovered or not. Known values are: "recover" and "default". - :paramtype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :keyword enable_purge_protection: Property specifying whether protection against purge is - enabled for this vault. Setting this property to true activates protection against purge for - this vault and its content - only the Key Vault service may initiate a hard, irrecoverable - deletion. The setting is effective only if soft delete is also enabled. Enabling this - functionality is irreversible - that is, the property does not accept false as its value. - :paramtype enable_purge_protection: bool - :keyword network_acls: A collection of rules governing the accessibility of the vault from - specific network locations. - :paramtype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet - :keyword public_network_access: Property to specify whether the vault will accept traffic from - public internet. If set to 'disabled' all traffic except private endpoint traffic and that that - originates from trusted services will be blocked. This will override the set firewall rules, - meaning that even if the firewall rules are present we will not honor the rules. - :paramtype public_network_access: str - """ - super().__init__(**kwargs) - self.tenant_id = tenant_id - self.sku = sku - self.access_policies = access_policies - self.enabled_for_deployment = enabled_for_deployment - self.enabled_for_disk_encryption = enabled_for_disk_encryption - self.enabled_for_template_deployment = enabled_for_template_deployment - self.enable_soft_delete = enable_soft_delete - self.enable_rbac_authorization = enable_rbac_authorization - self.soft_delete_retention_in_days = soft_delete_retention_in_days - self.create_mode = create_mode - self.enable_purge_protection = enable_purge_protection - self.network_acls = network_acls - self.public_network_access = public_network_access - - -class VaultProperties(_serialization.Model): - """Properties of the vault. - - 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 tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. Required. - :vartype tenant_id: str - :ivar sku: SKU details. Required. - :vartype sku: ~azure.mgmt.keyvault.models.Sku - :ivar access_policies: An array of 0 to 1024 identities that have access to the key vault. All - identities in the array must use the same tenant ID as the key vault's tenant ID. When - ``createMode`` is set to ``recover``\\ , access policies are not required. Otherwise, access - policies are required. - :vartype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - :ivar vault_uri: The URI of the vault for performing operations on keys and secrets. - :vartype vault_uri: str - :ivar hsm_pool_resource_id: The resource id of HSM Pool. - :vartype hsm_pool_resource_id: str - :ivar enabled_for_deployment: Property to specify whether Azure Virtual Machines are permitted - to retrieve certificates stored as secrets from the key vault. - :vartype enabled_for_deployment: bool - :ivar enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is - permitted to retrieve secrets from the vault and unwrap keys. - :vartype enabled_for_disk_encryption: bool - :ivar enabled_for_template_deployment: Property to specify whether Azure Resource Manager is - permitted to retrieve secrets from the key vault. - :vartype enabled_for_template_deployment: bool - :ivar enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this key vault. If it's not set to any value(true or false) when creating new key - vault, it will be set to true by default. Once set to true, it cannot be reverted to false. - :vartype enable_soft_delete: bool - :ivar soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and <=90. - :vartype soft_delete_retention_in_days: int - :ivar enable_rbac_authorization: Property that controls how data actions are authorized. When - true, the key vault will use Role Based Access Control (RBAC) for authorization of data - actions, and the access policies specified in vault properties will be ignored. When false, - the key vault will use the access policies specified in vault properties, and any policy stored - on Azure Resource Manager will be ignored. If null or not specified, the vault is created with - the default value of false. Note that management actions are always authorized with RBAC. - :vartype enable_rbac_authorization: bool - :ivar create_mode: The vault's create mode to indicate whether the vault need to be recovered - or not. Known values are: "recover" and "default". - :vartype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :ivar enable_purge_protection: Property specifying whether protection against purge is enabled - for this vault. Setting this property to true activates protection against purge for this vault - and its content - only the Key Vault service may initiate a hard, irrecoverable deletion. The - setting is effective only if soft delete is also enabled. Enabling this functionality is - irreversible - that is, the property does not accept false as its value. - :vartype enable_purge_protection: bool - :ivar network_acls: Rules governing the accessibility of the key vault from specific network - locations. - :vartype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet - :ivar provisioning_state: Provisioning state of the vault. Known values are: "Succeeded" and - "RegisteringDns". - :vartype provisioning_state: str or ~azure.mgmt.keyvault.models.VaultProvisioningState - :ivar private_endpoint_connections: List of private endpoint connections associated with the - key vault. - :vartype private_endpoint_connections: - list[~azure.mgmt.keyvault.models.PrivateEndpointConnectionItem] - :ivar public_network_access: Property to specify whether the vault will accept traffic from - public internet. If set to 'disabled' all traffic except private endpoint traffic and that that - originates from trusted services will be blocked. This will override the set firewall rules, - meaning that even if the firewall rules are present we will not honor the rules. - :vartype public_network_access: str - """ - - _validation = { - "tenant_id": {"required": True}, - "sku": {"required": True}, - "hsm_pool_resource_id": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "tenant_id": {"key": "tenantId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "access_policies": {"key": "accessPolicies", "type": "[AccessPolicyEntry]"}, - "vault_uri": {"key": "vaultUri", "type": "str"}, - "hsm_pool_resource_id": {"key": "hsmPoolResourceId", "type": "str"}, - "enabled_for_deployment": {"key": "enabledForDeployment", "type": "bool"}, - "enabled_for_disk_encryption": {"key": "enabledForDiskEncryption", "type": "bool"}, - "enabled_for_template_deployment": {"key": "enabledForTemplateDeployment", "type": "bool"}, - "enable_soft_delete": {"key": "enableSoftDelete", "type": "bool"}, - "soft_delete_retention_in_days": {"key": "softDeleteRetentionInDays", "type": "int"}, - "enable_rbac_authorization": {"key": "enableRbacAuthorization", "type": "bool"}, - "create_mode": {"key": "createMode", "type": "str"}, - "enable_purge_protection": {"key": "enablePurgeProtection", "type": "bool"}, - "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint_connections": { - "key": "privateEndpointConnections", - "type": "[PrivateEndpointConnectionItem]", - }, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - tenant_id: str, - sku: "_models.Sku", - access_policies: Optional[list["_models.AccessPolicyEntry"]] = None, - vault_uri: Optional[str] = None, - enabled_for_deployment: bool = False, - enabled_for_disk_encryption: bool = False, - enabled_for_template_deployment: bool = False, - enable_soft_delete: bool = True, - soft_delete_retention_in_days: int = 90, - enable_rbac_authorization: bool = False, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - enable_purge_protection: Optional[bool] = None, - network_acls: Optional["_models.NetworkRuleSet"] = None, - provisioning_state: Optional[Union[str, "_models.VaultProvisioningState"]] = None, - public_network_access: str = "enabled", - **kwargs: Any - ) -> None: - """ - :keyword tenant_id: The Azure Active Directory tenant ID that should be used for authenticating - requests to the key vault. Required. - :paramtype tenant_id: str - :keyword sku: SKU details. Required. - :paramtype sku: ~azure.mgmt.keyvault.models.Sku - :keyword access_policies: An array of 0 to 1024 identities that have access to the key vault. - All identities in the array must use the same tenant ID as the key vault's tenant ID. When - ``createMode`` is set to ``recover``\\ , access policies are not required. Otherwise, access - policies are required. - :paramtype access_policies: list[~azure.mgmt.keyvault.models.AccessPolicyEntry] - :keyword vault_uri: The URI of the vault for performing operations on keys and secrets. - :paramtype vault_uri: str - :keyword enabled_for_deployment: Property to specify whether Azure Virtual Machines are - permitted to retrieve certificates stored as secrets from the key vault. - :paramtype enabled_for_deployment: bool - :keyword enabled_for_disk_encryption: Property to specify whether Azure Disk Encryption is - permitted to retrieve secrets from the vault and unwrap keys. - :paramtype enabled_for_disk_encryption: bool - :keyword enabled_for_template_deployment: Property to specify whether Azure Resource Manager is - permitted to retrieve secrets from the key vault. - :paramtype enabled_for_template_deployment: bool - :keyword enable_soft_delete: Property to specify whether the 'soft delete' functionality is - enabled for this key vault. If it's not set to any value(true or false) when creating new key - vault, it will be set to true by default. Once set to true, it cannot be reverted to false. - :paramtype enable_soft_delete: bool - :keyword soft_delete_retention_in_days: softDelete data retention days. It accepts >=7 and - <=90. - :paramtype soft_delete_retention_in_days: int - :keyword enable_rbac_authorization: Property that controls how data actions are authorized. - When true, the key vault will use Role Based Access Control (RBAC) for authorization of data - actions, and the access policies specified in vault properties will be ignored. When false, - the key vault will use the access policies specified in vault properties, and any policy stored - on Azure Resource Manager will be ignored. If null or not specified, the vault is created with - the default value of false. Note that management actions are always authorized with RBAC. - :paramtype enable_rbac_authorization: bool - :keyword create_mode: The vault's create mode to indicate whether the vault need to be - recovered or not. Known values are: "recover" and "default". - :paramtype create_mode: str or ~azure.mgmt.keyvault.models.CreateMode - :keyword enable_purge_protection: Property specifying whether protection against purge is - enabled for this vault. Setting this property to true activates protection against purge for - this vault and its content - only the Key Vault service may initiate a hard, irrecoverable - deletion. The setting is effective only if soft delete is also enabled. Enabling this - functionality is irreversible - that is, the property does not accept false as its value. - :paramtype enable_purge_protection: bool - :keyword network_acls: Rules governing the accessibility of the key vault from specific network - locations. - :paramtype network_acls: ~azure.mgmt.keyvault.models.NetworkRuleSet - :keyword provisioning_state: Provisioning state of the vault. Known values are: "Succeeded" and - "RegisteringDns". - :paramtype provisioning_state: str or ~azure.mgmt.keyvault.models.VaultProvisioningState - :keyword public_network_access: Property to specify whether the vault will accept traffic from - public internet. If set to 'disabled' all traffic except private endpoint traffic and that that - originates from trusted services will be blocked. This will override the set firewall rules, - meaning that even if the firewall rules are present we will not honor the rules. - :paramtype public_network_access: str - """ - super().__init__(**kwargs) - self.tenant_id = tenant_id - self.sku = sku - self.access_policies = access_policies - self.vault_uri = vault_uri - self.hsm_pool_resource_id: Optional[str] = None - self.enabled_for_deployment = enabled_for_deployment - self.enabled_for_disk_encryption = enabled_for_disk_encryption - self.enabled_for_template_deployment = enabled_for_template_deployment - self.enable_soft_delete = enable_soft_delete - self.soft_delete_retention_in_days = soft_delete_retention_in_days - self.enable_rbac_authorization = enable_rbac_authorization - self.create_mode = create_mode - self.enable_purge_protection = enable_purge_protection - self.network_acls = network_acls - self.provisioning_state = provisioning_state - self.private_endpoint_connections: Optional[list["_models.PrivateEndpointConnectionItem"]] = None - self.public_network_access = public_network_access - - -class VirtualNetworkRule(_serialization.Model): - """A rule governing the accessibility of a vault from a specific virtual network. - - All required parameters must be populated in order to send to server. - - :ivar id: Full resource id of a vnet subnet, such as - '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - Required. - :vartype id: str - :ivar ignore_missing_vnet_service_endpoint: Property to specify whether NRP will ignore the - check if parent subnet has serviceEndpoints configured. - :vartype ignore_missing_vnet_service_endpoint: bool - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - ignore_missing_vnet_service_endpoint: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Full resource id of a vnet subnet, such as - '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - Required. - :paramtype id: str - :keyword ignore_missing_vnet_service_endpoint: Property to specify whether NRP will ignore the - check if parent subnet has serviceEndpoints configured. - :paramtype ignore_missing_vnet_service_endpoint: bool - """ - super().__init__(**kwargs) - self.id = id - self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/models/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/__init__.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/__init__.py index 2c20c64a2fa5..599afc490f41 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/__init__.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,34 +12,34 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._keys_operations import KeysOperations # type: ignore -from ._managed_hsm_keys_operations import ManagedHsmKeysOperations # type: ignore -from ._vaults_operations import VaultsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._managed_hsms_operations import ManagedHsmsOperations # type: ignore -from ._mhsm_private_endpoint_connections_operations import MHSMPrivateEndpointConnectionsOperations # type: ignore -from ._mhsm_private_link_resources_operations import MHSMPrivateLinkResourcesOperations # type: ignore -from ._mhsm_regions_operations import MHSMRegionsOperations # type: ignore from ._operations import Operations # type: ignore -from ._secrets_operations import SecretsOperations # type: ignore +from ._operations import VaultsOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import ManagedHsmsOperations # type: ignore +from ._operations import SecretsOperations # type: ignore +from ._operations import KeysOperations # type: ignore +from ._operations import ManagedHsmKeysOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import MHSMPrivateLinkResourcesOperations # type: ignore +from ._operations import MHSMRegionsOperations # type: ignore +from ._operations import MHSMPrivateEndpointConnectionsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "KeysOperations", - "ManagedHsmKeysOperations", + "Operations", "VaultsOperations", "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "ManagedHsmsOperations", - "MHSMPrivateEndpointConnectionsOperations", + "SecretsOperations", + "KeysOperations", + "ManagedHsmKeysOperations", + "PrivateLinkResourcesOperations", "MHSMPrivateLinkResourcesOperations", "MHSMRegionsOperations", - "Operations", - "SecretsOperations", + "MHSMPrivateEndpointConnectionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_keys_operations.py deleted file mode 100644 index 4fb6595096c3..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_keys_operations.py +++ /dev/null @@ -1,662 +0,0 @@ -# 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, IO, Optional, TypeVar, Union, overload -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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_if_not_exist_request( - resource_group_name: str, vault_name: str, key_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", "2025-05-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.KeyVault/vaults/{vaultName}/keys/{keyName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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_get_request( - resource_group_name: str, vault_name: str, key_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - } - - _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_version_request( - resource_group_name: str, vault_name: str, key_name: str, key_version: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - "keyVersion": _SERIALIZER.url("key_version", key_version, "str", pattern=r"^[a-fA-F0-9]{32}$"), - } - - _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_list_versions_request( - resource_group_name: str, vault_name: str, key_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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 KeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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 create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: _models.KeyCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: 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: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_if_not_exist( - self, - resource_group_name: str, - vault_name: str, - key_name: str, - parameters: Union[_models.KeyCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Key: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault which contains the key to be created. Required. - :type vault_name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Is either a - KeyCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters or IO[bytes] - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "KeyCreateParameters") - - _request = build_create_if_not_exist_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any) -> _models.Key: - """Gets the current version of the specified key from the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key to be retrieved. Required. - :type vault_name: str - :param key_name: The name of the key to be retrieved. Required. - :type key_name: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> ItemPaged["_models.Key"]: - """Lists the keys in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the keys to be retrieved. Required. - :type vault_name: str - :return: An iterator like instance of either Key or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Key] - :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.KeyListResult] = 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("KeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_version( - self, resource_group_name: str, vault_name: str, key_name: str, key_version: str, **kwargs: Any - ) -> _models.Key: - """Gets the specified version of the specified key in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key version to be retrieved. - Required. - :type vault_name: str - :param key_name: The name of the key version to be retrieved. Required. - :type key_name: str - :param key_version: The version of the key to be retrieved. Required. - :type key_version: str - :return: Key or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Key - :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.Key] = kwargs.pop("cls", None) - - _request = build_get_version_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_name, - key_version=key_version, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Key", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_versions( - self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any - ) -> ItemPaged["_models.Key"]: - """Lists the versions of the specified key in the specified key vault. - - :param resource_group_name: The name of the resource group which contains the specified key - vault. Required. - :type resource_group_name: str - :param vault_name: The name of the vault which contains the key versions to be retrieved. - Required. - :type vault_name: str - :param key_name: The name of the key versions to be retrieved. Required. - :type key_name: str - :return: An iterator like instance of either Key or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Key] - :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.KeyListResult] = 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_versions_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - key_name=key_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("KeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsm_keys_operations.py deleted file mode 100644 index b10970805f4a..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsm_keys_operations.py +++ /dev/null @@ -1,686 +0,0 @@ -# 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, IO, Optional, TypeVar, Union, overload -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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_if_not_exist_request( - resource_group_name: str, name: str, key_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", "2025-05-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.KeyVault/managedHSMs/{name}/keys/{keyName}", - ) - 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 - ), - "name": _SERIALIZER.url( - "name", name, "str", max_length=24, min_length=3, pattern=r"^[A-Za-z]([A-Za-z0-9]|\-[A-Za-z0-9])+$" - ), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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_get_request( - resource_group_name: str, name: str, key_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}", - ) - 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 - ), - "name": _SERIALIZER.url( - "name", name, "str", max_length=24, min_length=3, pattern=r"^[A-Za-z]([A-Za-z0-9]|\-[A-Za-z0-9])+$" - ), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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_list_request(resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys", - ) - 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 - ), - "name": _SERIALIZER.url( - "name", name, "str", max_length=24, min_length=3, pattern=r"^[A-Za-z]([A-Za-z0-9]|\-[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_version_request( - resource_group_name: str, name: str, key_name: str, key_version: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion}", - ) - 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 - ), - "name": _SERIALIZER.url( - "name", name, "str", max_length=24, min_length=3, pattern=r"^[A-Za-z]([A-Za-z0-9]|\-[A-Za-z0-9])+$" - ), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - "keyVersion": _SERIALIZER.url("key_version", key_version, "str", pattern=r"^[a-fA-F0-9]{32}$"), - } - - _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_list_versions_request( - resource_group_name: str, name: str, key_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions", - ) - 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 - ), - "name": _SERIALIZER.url( - "name", name, "str", max_length=24, min_length=3, pattern=r"^[A-Za-z]([A-Za-z0-9]|\-[A-Za-z0-9])+$" - ), - "keyName": _SERIALIZER.url("key_name", key_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - } - - _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 ManagedHsmKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`managed_hsm_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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 create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: _models.ManagedHsmKeyCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Required. - :type parameters: 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: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_if_not_exist( - self, - resource_group_name: str, - name: str, - key_name: str, - parameters: Union[_models.ManagedHsmKeyCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedHsmKey: - """Creates the first version of a new key if it does not exist. If it already exists, then the - existing key is returned without any write operations being performed. This API does not create - subsequent versions, and does not update existing keys. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param parameters: The parameters used to create the specified key. Is either a - ManagedHsmKeyCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters or IO[bytes] - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsmKeyCreateParameters") - - _request = build_create_if_not_exist_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, name: str, key_name: str, **kwargs: Any) -> _models.ManagedHsmKey: - """Gets the current version of the specified key from the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, name: str, **kwargs: Any) -> ItemPaged["_models.ManagedHsmKey"]: - """Lists the keys in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :return: An iterator like instance of either ManagedHsmKey or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] - :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.ManagedHsmKeyListResult] = 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, - name=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("ManagedHsmKeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_version( - self, resource_group_name: str, name: str, key_name: str, key_version: str, **kwargs: Any - ) -> _models.ManagedHsmKey: - """Gets the specified version of the specified key in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :param key_version: The version of the key to be retrieved. Required. - :type key_version: str - :return: ManagedHsmKey or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey - :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.ManagedHsmKey] = kwargs.pop("cls", None) - - _request = build_get_version_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_name, - key_version=key_version, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedHsmKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_versions( - self, resource_group_name: str, name: str, key_name: str, **kwargs: Any - ) -> ItemPaged["_models.ManagedHsmKey"]: - """Lists the versions of the specified key in the specified managed HSM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param name: The name of the Managed HSM Pool within the specified resource group. Required. - :type name: str - :param key_name: The name of the key to be created. The value you provide may be copied - globally for the purpose of running the service. The value provided should not include - personally identifiable or sensitive information. Required. - :type key_name: str - :return: An iterator like instance of either ManagedHsmKey or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] - :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.ManagedHsmKeyListResult] = 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_versions_request( - resource_group_name=resource_group_name, - name=name, - key_name=key_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("ManagedHsmKeyListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsms_operations.py deleted file mode 100644 index 6c8abddbb30d..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_managed_hsms_operations.py +++ /dev/null @@ -1,1396 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# 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, IO, 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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, 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", "2025-05-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.KeyVault/managedHSMs/{name}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, 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", "2025-05-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.KeyVault/managedHSMs/{name}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request( - resource_group_name: str, subscription_id: str, *, top: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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_list_by_subscription_request( - subscription_id: str, *, top: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/managedHSMs") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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_list_deleted_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedManagedHSMs") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_deleted_request(name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name}", - ) - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_purge_deleted_request(name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name}/purge", - ) - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_mhsm_name_availability_request( # pylint: disable=name-too-long - 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", "2025-05-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.KeyVault/checkMhsmNameAvailability" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 ManagedHsmsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`managed_hsms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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") - - def _create_or_update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsm") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - name=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) - - _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 [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.ManagedHsmError, 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: _models.ManagedHsm, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm - :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 ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Required. - :type parameters: 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 ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Create or update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to create or update the managed HSM Pool. Is either a ManagedHsm - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or IO[bytes] - :return: An instance of LROPoller that returns either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedHsm] = 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._create_or_update_initial( - resource_group_name=resource_group_name, - name=name, - parameters=parameters, - 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): - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ManagedHsm].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedHsm]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedHsm") - - _request = build_update_request( - resource_group_name=resource_group_name, - name=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) - - _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 [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.ManagedHsmError, 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - name: str, - parameters: _models.ManagedHsm, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm - :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 ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Required. - :type parameters: 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 ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.ManagedHsm]: - """Update a managed HSM Pool in the specified subscription. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param parameters: Parameters to patch the managed HSM Pool. Is either a ManagedHsm type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or IO[bytes] - :return: An instance of LROPoller that returns either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedHsm] = 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._update_initial( - resource_group_name=resource_group_name, - name=name, - parameters=parameters, - 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): - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ManagedHsm].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedHsm]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, 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, - name=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 [200, 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.ManagedHsmError, 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")) - - 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, name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the specified managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: The name of the managed HSM Pool to delete. Required. - :type 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, - name=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, **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 - - @distributed_trace - def get(self, resource_group_name: str, name: str, **kwargs: Any) -> Optional[_models.ManagedHsm]: - """Gets the specified managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: The name of the managed HSM Pool. Required. - :type name: str - :return: ManagedHsm or None or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.ManagedHsm or None - :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[Optional[_models.ManagedHsm]] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ManagedHsm", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.ManagedHsm"]: - """The List operation gets information about the managed HSM Pools associated with the - subscription and within the specified resource group. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] - :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.ManagedHsmListResult] = 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_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=top, - 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("ManagedHsmListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.ManagedHsm"]: - """The List operation gets information about the managed HSM Pools associated with the - subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either ManagedHsm or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] - :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.ManagedHsmListResult] = 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, - top=top, - 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("ManagedHsmListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_deleted(self, **kwargs: Any) -> ItemPaged["_models.DeletedManagedHsm"]: - """The List operation gets information about the deleted managed HSMs associated with the - subscription. - - :return: An iterator like instance of either DeletedManagedHsm or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.DeletedManagedHsm] - :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.DeletedManagedHsmListResult] = 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_deleted_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("DeletedManagedHsmListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.DeletedManagedHsm: - """Gets the specified deleted managed HSM. - - :param name: The name of the deleted managed HSM. Required. - :type name: str - :param location: The location of the deleted managed HSM. Required. - :type location: str - :return: DeletedManagedHsm or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.DeletedManagedHsm - :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.DeletedManagedHsm] = kwargs.pop("cls", None) - - _request = build_get_deleted_request( - name=name, - location=location, - 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeletedManagedHsm", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _purge_deleted_initial(self, name: str, location: 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_purge_deleted_request( - name=name, - location=location, - 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]: - 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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_purge_deleted(self, name: str, location: str, **kwargs: Any) -> LROPoller[None]: - """Permanently deletes the specified managed HSM. - - :param name: The name of the soft-deleted managed HSM. Required. - :type name: str - :param location: The location of the soft-deleted managed HSM. Required. - :type location: 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._purge_deleted_initial( - name=name, - location=location, - 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, **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 check_mhsm_name_availability( - self, - mhsm_name: _models.CheckMhsmNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Required. - :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_mhsm_name_availability( - self, mhsm_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Required. - :type mhsm_name: 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: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_mhsm_name_availability( - self, mhsm_name: Union[_models.CheckMhsmNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.CheckMhsmNameAvailabilityResult: - """Checks that the managed hsm name is valid and is not already in use. - - :param mhsm_name: The name of the managed hsm. Is either a CheckMhsmNameAvailabilityParameters - type or a IO[bytes] type. Required. - :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters or IO[bytes] - :return: CheckMhsmNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult - :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.CheckMhsmNameAvailabilityResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(mhsm_name, (IOBase, bytes)): - _content = mhsm_name - else: - _json = self._serialize.body(mhsm_name, "CheckMhsmNameAvailabilityParameters") - - _request = build_check_mhsm_name_availability_request( - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckMhsmNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_endpoint_connections_operations.py deleted file mode 100644 index 9ddbd45d8f8e..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_endpoint_connections_operations.py +++ /dev/null @@ -1,616 +0,0 @@ -# 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, IO, 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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request( - resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request( - resource_group_name: str, 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", "2025-05-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.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class MHSMPrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`mhsm_private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> ItemPaged["_models.MHSMPrivateEndpointConnection"]: - """The List operation gets information about the private endpoint connections associated with the - managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: An iterator like instance of either MHSMPrivateEndpointConnection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :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.MHSMPrivateEndpointConnectionsListResult] = 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_resource_request( - resource_group_name=resource_group_name, - name=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("MHSMPrivateEndpointConnectionsListResult", 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.ManagedHsmError, 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, name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :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.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - name=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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: _models.MHSMPrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: 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: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, - resource_group_name: str, - name: str, - private_endpoint_connection_name: str, - properties: Union[_models.MHSMPrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.MHSMPrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Is either a - MHSMPrivateEndpointConnection type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection or IO[bytes] - :return: MHSMPrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection - :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.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "MHSMPrivateEndpointConnection") - - _request = build_put_request( - resource_group_name=resource_group_name, - name=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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, resource_group_name: str, 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, - name=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 [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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, name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[_models.MHSMPrivateEndpointConnection]: - """Deletes the specified private endpoint connection associated with the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the managed hsm pool. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either MHSMPrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] - :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.MHSMPrivateEndpointConnection] = 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, - name=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): - deserialized = self._deserialize("MHSMPrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.MHSMPrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.MHSMPrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_link_resources_operations.py deleted file mode 100644 index cbec1503185f..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_private_link_resources_operations.py +++ /dev/null @@ -1,144 +0,0 @@ -# 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, Optional, TypeVar - -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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_mhsm_resource_request( - resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateLinkResources", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MHSMPrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`mhsm_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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_mhsm_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> _models.MHSMPrivateLinkResourceListResult: - """Gets the private link resources supported for the managed hsm pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: MHSMPrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult - :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.MHSMPrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_mhsm_resource_request( - resource_group_name=resource_group_name, - name=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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MHSMPrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_regions_operations.py deleted file mode 100644 index 68c0ac233d7e..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_mhsm_regions_operations.py +++ /dev/null @@ -1,174 +0,0 @@ -# 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, 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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request( - resource_group_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/regions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MHSMRegionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`mhsm_regions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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_resource( - self, resource_group_name: str, name: str, **kwargs: Any - ) -> ItemPaged["_models.MHSMGeoReplicatedRegion"]: - """The List operation gets information about the regions associated with the managed HSM Pool. - - :param resource_group_name: Name of the resource group that contains the managed HSM pool. - Required. - :type resource_group_name: str - :param name: Name of the managed HSM Pool. Required. - :type name: str - :return: An iterator like instance of either MHSMGeoReplicatedRegion or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] - :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.MHSMRegionsListResult] = 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_resource_request( - resource_group_name=resource_group_name, - name=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("MHSMRegionsListResult", 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.ManagedHsmError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_operations.py index 5e3597b6259c..14fabbad83a0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_operations.py @@ -1,12 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -16,28 +19,34 @@ 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 KeyVaultManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -45,7 +54,1380 @@ def build_list_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.KeyVault/operations") + _url = "/providers/Microsoft.KeyVault/operations" + + # 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_vaults_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_create_or_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_delete_request( + resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_vaults_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, *, top: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, *, top: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/vaults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_update_access_policy_request( # pylint: disable=name-too-long + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/accessPolicies/{operationKind}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "operationKind": _SERIALIZER.url("operation_kind", operation_kind, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_get_deleted_request( + vault_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}" + path_format_arguments = { + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_purge_deleted_request( + vault_name: str, location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge" + path_format_arguments = { + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_vaults_list_deleted_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_vaults_list_request(subscription_id: str, *, top: Optional[int] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( + "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") + ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _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_vaults_check_name_availability_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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) + + +def build_private_endpoint_connections_get_request( # pylint: disable=name-too-long + 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_put_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_list_by_resource_request( # pylint: disable=name-too-long + 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_get_request( + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_update_request( + resource_group_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_delete_request( + resource_group_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_hsms_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, *, top: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, *, top: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/managedHSMs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_get_deleted_request( + name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_purge_deleted_request( + name: str, location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name}/purge" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_hsms_list_deleted_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedManagedHSMs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsms_check_mhsm_name_availability_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkMhsmNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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) + + +def build_secrets_get_request( + resource_group_name: str, vault_name: str, secret_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_create_or_update_request( + resource_group_name: str, vault_name: str, secret_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_update_request( + resource_group_name: str, vault_name: str, secret_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_list_request( + resource_group_name: str, vault_name: str, subscription_id: str, *, top: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_keys_get_request( + resource_group_name: str, vault_name: str, key_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_keys_create_if_not_exist_request( + resource_group_name: str, vault_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_keys_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_keys_get_version_request( + resource_group_name: str, vault_name: str, key_name: str, key_version: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + "keyVersion": _SERIALIZER.url("key_version", key_version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_keys_list_versions_request( + resource_group_name: str, vault_name: str, key_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsm_keys_get_request( + resource_group_name: str, name: str, key_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsm_keys_create_if_not_exist_request( # pylint: disable=name-too-long + resource_group_name: str, name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsm_keys_list_request( + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsm_keys_get_version_request( # pylint: disable=name-too-long + resource_group_name: str, name: str, key_name: str, key_version: 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions/{keyVersion}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + "keyVersion": _SERIALIZER.url("key_version", key_version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_hsm_keys_list_versions_request( # pylint: disable=name-too-long + resource_group_name: str, name: str, key_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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/keys/{keyName}/versions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_list_by_vault_request( # pylint: disable=name-too-long + 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_private_link_resources_list_by_mhsm_resource_request( # pylint: disable=name-too-long + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_regions_list_by_resource_request( # pylint: disable=name-too-long + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/regions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_private_endpoint_connections_get_request( # pylint: disable=name-too-long + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_private_endpoint_connections_put_request( # pylint: disable=name-too-long + resource_group_name: str, 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_mhsm_private_endpoint_connections_list_by_resource_request( # pylint: disable=name-too-long + resource_group_name: str, 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", "2025-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -63,10 +1445,5165 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = 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_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class VaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`vaults` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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.Vault: + """Gets the specified Azure key 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 name of the vault. Required. + :type vault_name: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Vault] = kwargs.pop("cls", None) + + _request = build_vaults_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Vault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: _models.VaultCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters + :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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: JSON + :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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Required. + :type parameters: 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 Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Vault]: + """Create or update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to create or update the vault. Is one of the following types: + VaultCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Vault. The Vault is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Vault] = 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._create_or_update_initial( + resource_group_name=resource_group_name, + vault_name=vault_name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Vault, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Vault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Vault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + parameters: _models.VaultPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Required. + :type parameters: 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: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + vault_name: str, + parameters: Union[_models.VaultPatchParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Vault: + """Update a key vault in the specified subscription. + + :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 name of the vault. Required. + :type vault_name: str + :param parameters: Parameters to patch the vault. Is one of the following types: + VaultPatchParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters or JSON or IO[bytes] + :return: Vault. The Vault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Vault + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Vault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Vault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> None: + """Deletes the specified Azure key 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 name of the vault. Required. + :type vault_name: str + :return: None + :rtype: None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_vaults_delete_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.Vault"]: + """The List operation gets information about the vaults associated with the subscription and + within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Vault + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Vault]] = 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_vaults_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Vault], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, *, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.Vault"]: + """The List operation gets information about the vaults associated with the subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Vault + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Vault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Vault]] = 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_vaults_list_by_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Vault], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: _models.VaultAccessPolicyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Required. + :type parameters: 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: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_access_policy( + self, + resource_group_name: str, + vault_name: str, + operation_kind: Union[str, _models.AccessPolicyUpdateKind], + parameters: Union[_models.VaultAccessPolicyParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VaultAccessPolicyParameters: + """Update access policies in a key vault in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: Name of the vault. Required. + :type vault_name: str + :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". + Required. + :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind + :param parameters: Access policy to merge into the vault. Is one of the following types: + VaultAccessPolicyParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters or JSON or IO[bytes] + :return: VaultAccessPolicyParameters. The VaultAccessPolicyParameters is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VaultAccessPolicyParameters] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_update_access_policy_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + operation_kind=operation_kind, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.VaultAccessPolicyParameters, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models.DeletedVault: + """Gets the deleted Azure key vault. + + :param vault_name: The name of the vault. Required. + :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedVault. The DeletedVault is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.DeletedVault + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedVault] = kwargs.pop("cls", None) + + _request = build_vaults_get_deleted_request( + vault_name=vault_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DeletedVault, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_deleted_initial(self, vault_name: str, location: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_vaults_purge_deleted_request( + vault_name=vault_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_purge_deleted(self, vault_name: str, location: str, **kwargs: Any) -> LROPoller[None]: + """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. + + :param vault_name: The name of the vault. Required. + :type vault_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._purge_deleted_initial( + vault_name=vault_name, + location=location, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> ItemPaged["_models.DeletedVault"]: + """Gets information about the deleted vaults in a subscription. + + :return: An iterator like instance of DeletedVault + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.DeletedVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedVault]] = 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_vaults_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DeletedVault], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.TrackedResource"]: + """The List operation gets information about the vaults associated with the subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of TrackedResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.TrackedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( + "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") + ) + api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) + cls: ClsType[List[_models.TrackedResource]] = 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_vaults_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.TrackedResource], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def check_name_availability( + self, + vault_name: _models.VaultCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, vault_name: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, vault_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Required. + :type vault_name: 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: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, vault_name: Union[_models.VaultCheckNameAvailabilityParameters, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the vault name is valid and is not already in use. + + :param vault_name: The name of the vault. Is one of the following types: + VaultCheckNameAvailabilityParameters, JSON, IO[bytes] Required. + :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters or JSON or + IO[bytes] + :return: CheckNameAvailabilityResult. The CheckNameAvailabilityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(vault_name, (IOBase, bytes)): + _content = vault_name + else: + _content = json.dumps(vault_name, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_vaults_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + """Gets the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or None. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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, 204]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: ~azure.mgmt.keyvault.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. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: 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. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + vault_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Is one of the following + types: PrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_put_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + 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[_models.PrivateEndpointConnection]: + """Deletes the specified private endpoint connection associated with the key 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 name of the vault. Required. + :type vault_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the key vault. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = 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, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """The List operation gets information about the private endpoint connections associated with 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 name of the vault. Required. + :type vault_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = 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_private_endpoint_connections_list_by_resource_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.PrivateEndpointConnection], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedHsmsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`managed_hsms` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, name: str, **kwargs: Any) -> Optional[_models.ManagedHsm]: + """Gets the specified managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: ManagedHsm or None. The ManagedHsm is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsm or None + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[_models.ManagedHsm]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_get_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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, 204]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsm, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_create_or_update_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: _models.ManagedHsm, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm + :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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: JSON + :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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Required. + :type parameters: 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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Create or update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to create or update the managed HSM Pool. Is one of the following + types: ManagedHsm, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsm] = 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._create_or_update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedHsm, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedHsm].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_update_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + name: str, + parameters: _models.ManagedHsm, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm + :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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: JSON + :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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Required. + :type parameters: 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 ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, name: str, parameters: Union[_models.ManagedHsm, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.ManagedHsm]: + """Update a managed HSM Pool in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param parameters: Parameters to patch the managed HSM Pool. Is one of the following types: + ManagedHsm, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsm or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedHsm. The ManagedHsm is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsm] = 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._update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedHsm, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedHsm].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_delete_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.ManagedHsmError, + 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.iter_bytes() + + 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, name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + name=name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.ManagedHsm"]: + """The List operation gets information about the managed HSM Pools associated with the + subscription and within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of ManagedHsm + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsm]] = 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_managed_hsms_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, *, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.ManagedHsm"]: + """The List operation gets information about the managed HSM Pools associated with the + subscription. + + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of ManagedHsm + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsm]] = 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_managed_hsms_list_by_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_deleted(self, name: str, location: str, **kwargs: Any) -> _models.DeletedManagedHsm: + """Gets the specified deleted managed HSM. + + :param name: The name of the deleted managed HSM. Required. + :type name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedManagedHsm. The DeletedManagedHsm is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.DeletedManagedHsm + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedManagedHsm] = kwargs.pop("cls", None) + + _request = build_managed_hsms_get_deleted_request( + name=name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DeletedManagedHsm, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_deleted_initial(self, name: str, location: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_hsms_purge_deleted_request( + name=name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_purge_deleted(self, name: str, location: str, **kwargs: Any) -> LROPoller[None]: + """Permanently deletes the specified managed HSM. + + :param name: The name of the deleted managed HSM. Required. + :type name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._purge_deleted_initial( + name=name, location=location, 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + @distributed_trace + def list_deleted(self, **kwargs: Any) -> ItemPaged["_models.DeletedManagedHsm"]: + """The List operation gets information about the deleted managed HSMs associated with the + subscription. + + :return: An iterator like instance of DeletedManagedHsm + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.DeletedManagedHsm] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedManagedHsm]] = 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_managed_hsms_list_deleted_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DeletedManagedHsm], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def check_mhsm_name_availability( + self, + mhsm_name: _models.CheckMhsmNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_mhsm_name_availability( + self, mhsm_name: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_mhsm_name_availability( + self, mhsm_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Required. + :type mhsm_name: 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: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_mhsm_name_availability( + self, mhsm_name: Union[_models.CheckMhsmNameAvailabilityParameters, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckMhsmNameAvailabilityResult: + """Checks that the managed hsm name is valid and is not already in use. + + :param mhsm_name: The request body. Is one of the following types: + CheckMhsmNameAvailabilityParameters, JSON, IO[bytes] Required. + :type mhsm_name: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityParameters or JSON or + IO[bytes] + :return: CheckMhsmNameAvailabilityResult. The CheckMhsmNameAvailabilityResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.CheckMhsmNameAvailabilityResult + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckMhsmNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(mhsm_name, (IOBase, bytes)): + _content = mhsm_name + else: + _content = json.dumps(mhsm_name, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsms_check_mhsm_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.CheckMhsmNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`secrets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, secret_name: str, **kwargs: Any) -> _models.Secret: + """Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. + Users should use the data-plane REST service for interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + _request = build_secrets_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: _models.SecretCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Required. + :type parameters: 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: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: Union[_models.SecretCreateOrUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Secret: + """Create or update a secret in a key vault in the specified subscription. NOTE: This API is + intended for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to create or update the secret. Is one of the following types: + SecretCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters or JSON or + IO[bytes] + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_create_or_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: _models.SecretPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Required. + :type parameters: 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: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + vault_name: str, + secret_name: str, + parameters: Union[_models.SecretPatchParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Secret: + """Update a secret in the specified subscription. NOTE: This API is intended for internal use in + ARM deployments. Users should use the data-plane REST service for interaction with vault + secrets. + + :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 name of the vault. Required. + :type vault_name: str + :param secret_name: The name of the secret. Required. + :type secret_name: str + :param parameters: Parameters to patch the secret. Is one of the following types: + SecretPatchParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters or JSON or IO[bytes] + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Secret + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_update_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, vault_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.Secret"]: + """The List operation gets information about the secrets in a vault. NOTE: This API is intended + for internal use in ARM deployments. Users should use the data-plane REST service for + interaction with vault secrets. + + :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 name of the vault. Required. + :type vault_name: str + :keyword top: Maximum number of results to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of Secret + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Secret]] = 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_secrets_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Secret], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class KeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, key_name: str, **kwargs: Any) -> _models.Key: + """Gets the current version of the specified key from the specified key 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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + _request = build_keys_get_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: _models.KeyCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: 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: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_if_not_exist( + self, + resource_group_name: str, + vault_name: str, + key_name: str, + parameters: Union[_models.KeyCreateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Key: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :param key_name: The name of the key to be retrieved. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Is one of the following + types: KeyCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.KeyCreateParameters or JSON or IO[bytes] + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_keys_create_if_not_exist_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> ItemPaged["_models.Key"]: + """Lists the keys in the specified key 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 name of the vault which contains the key to be retrieved. Required. + :type vault_name: str + :return: An iterator like instance of Key + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Key] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Key]] = 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_keys_list_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Key], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_version( + self, resource_group_name: str, vault_name: str, key_name: str, key_version: str, **kwargs: Any + ) -> _models.Key: + """Gets the specified version of the specified key in the specified key 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 name of the vault which contains the key version to be retrieved. + Required. + :type vault_name: str + :param key_name: The name of the key version to be retrieved. Required. + :type key_name: str + :param key_version: The version of the key to be retrieved. Required. + :type key_version: str + :return: Key. The Key is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.Key + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Key] = kwargs.pop("cls", None) + + _request = build_keys_get_version_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + key_version=key_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Key, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_versions( + self, resource_group_name: str, vault_name: str, key_name: str, **kwargs: Any + ) -> ItemPaged["_models.Key"]: + """Lists the keys in the specified key 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 name of the vault which contains the key version to be retrieved. + Required. + :type vault_name: str + :param key_name: The name of the key version to be retrieved. Required. + :type key_name: str + :return: An iterator like instance of Key + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Key] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Key]] = 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_keys_list_versions_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Key], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedHsmKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`managed_hsm_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, name: str, key_name: str, **kwargs: Any) -> _models.ManagedHsmKey: + """Gets the current version of the specified key from the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + _request = build_managed_hsm_keys_get_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: _models.ManagedHsmKeyCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Required. + :type parameters: 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: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_if_not_exist( + self, + resource_group_name: str, + name: str, + key_name: str, + parameters: Union[_models.ManagedHsmKeyCreateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedHsmKey: + """Creates the first version of a new key if it does not exist. If it already exists, then the + existing key is returned without any write operations being performed. This API does not create + subsequent versions, and does not update existing keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param parameters: The parameters used to create the specified key. Is one of the following + types: ManagedHsmKeyCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.keyvault.models.ManagedHsmKeyCreateParameters or JSON or + IO[bytes] + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_hsm_keys_create_if_not_exist_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, name: str, **kwargs: Any) -> ItemPaged["_models.ManagedHsmKey"]: + """Lists the keys in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :return: An iterator like instance of ManagedHsmKey + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsmKey]] = 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_managed_hsm_keys_list_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsmKey], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_version( + self, resource_group_name: str, name: str, key_name: str, key_version: str, **kwargs: Any + ) -> _models.ManagedHsmKey: + """Gets the specified version of the specified key in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :param key_version: The version of the key to be retrieved. Required. + :type key_version: str + :return: ManagedHsmKey. The ManagedHsmKey is compatible with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.ManagedHsmKey + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedHsmKey] = kwargs.pop("cls", None) + + _request = build_managed_hsm_keys_get_version_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + key_version=key_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.ManagedHsmKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_versions( + self, resource_group_name: str, name: str, key_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedHsmKey"]: + """Lists the keys in the specified managed HSM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the Managed HSM Pool within the specified resource group. Required. + :type name: str + :param key_name: The name of the key to be created. The value you provide may be copied + globally for the purpose of running the service. The value provided should not include + personally identifiable or sensitive information. Required. + :type key_name: str + :return: An iterator like instance of ManagedHsmKey + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.ManagedHsmKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedHsmKey]] = 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_managed_hsm_keys_list_versions_request( + resource_group_name=resource_group_name, + name=name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.ManagedHsmKey], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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_vault( + self, resource_group_name: str, vault_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources supported for the key 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 name of the vault. Required. + :type vault_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.PrivateLinkResourceListResult + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_link_resources_list_by_vault_request( + resource_group_name=resource_group_name, + vault_name=vault_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MHSMPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`mhsm_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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_mhsm_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> _models.MHSMPrivateLinkResourceListResult: + """Gets the private link resources supported for the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: MHSMPrivateLinkResourceListResult. The MHSMPrivateLinkResourceListResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateLinkResourceListResult + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_mhsm_private_link_resources_list_by_mhsm_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MHSMRegionsOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`mhsm_regions` attribute. + """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) @@ -76,18 +6613,24 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """Lists all of the available Key Vault Rest API operations. + def list_by_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> ItemPaged["_models.MHSMGeoReplicatedRegion"]: + """The List operation gets information about the regions associated with the managed HSM Pool. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Operation] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An iterator like instance of MHSMGeoReplicatedRegion + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.MHSMGeoReplicatedRegion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.MHSMGeoReplicatedRegion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -100,12 +6643,539 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_mhsm_regions_list_by_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.MHSMGeoReplicatedRegion], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class MHSMPrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s + :attr:`mhsm_private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: KeyVaultManagementClientConfiguration = 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, name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_mhsm_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: _models.MHSMPrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Required. + :type properties: 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: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + name: str, + private_endpoint_connection_name: str, + properties: Union[_models.MHSMPrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.MHSMPrivateEndpointConnection: + """Updates the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :param properties: The intended state of private endpoint connection. Is one of the following + types: MHSMPrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection or JSON or + IO[bytes] + :return: MHSMPrivateEndpointConnection. The MHSMPrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection + :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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MHSMPrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_mhsm_private_endpoint_connections_put_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.CloudError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_mhsm_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [200, 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 = _failsafe_deserialize( + _models.CloudError, + 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.iter_bytes() + + 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, name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.MHSMPrivateEndpointConnection]: + """Deletes the specified private endpoint connection associated with the managed hsm pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :param private_endpoint_connection_name: Name of the private endpoint connection associated + with the managed hsm pool. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns MHSMPrivateEndpointConnection. The + MHSMPrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MHSMPrivateEndpointConnection] = 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, + name=name, + private_endpoint_connection_name=private_endpoint_connection_name, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MHSMPrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.MHSMPrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MHSMPrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> ItemPaged["_models.MHSMPrivateEndpointConnection"]: + """The List operation gets information about the private endpoint connections associated with the + managed HSM Pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param name: The name of the managed HSM Pool. Required. + :type name: str + :return: An iterator like instance of MHSMPrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.MHSMPrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.MHSMPrivateEndpointConnection]] = 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_mhsm_private_endpoint_connections_list_by_resource_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -120,16 +7190,21 @@ def prepare_request(next_link=None): _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" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.MHSMPrivateEndpointConnection], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -142,7 +7217,11 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = _failsafe_deserialize( + _models.ManagedHsmError, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_patch.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_patch.py index 9bf5cc465316..87676c65a8f0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_patch.py +++ b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_patch.py @@ -1,118 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, List, Optional, Literal -import urllib.parse -from collections.abc import MutableMapping -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.rest import HttpRequest -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.mgmt.core.exceptions import ARMErrorFormat -from ._vaults_operations import VaultsOperations as _VaultsOperations, ClsType, build_list_request -from .. import models as _models - - -class VaultsOperations(_VaultsOperations): - @distributed_trace - def list(self, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.Resource"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Resource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.v2024_11_01.models.Resource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( - "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") - ) - api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) - cls: ClsType[_models.ResourceListResult] = 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( - subscription_id=self._config.subscription_id, - top=top, - filter=filter, - 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"] = 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("ResourceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -__all__: List[str] = ["VaultsOperations"] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index b204b2f9b9cd..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,622 +0,0 @@ -# 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, IO, 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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_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", "2025-05-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.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "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="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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - } - - _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 PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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, private_endpoint_connection_name: str, **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - """Gets the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or None or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or None - :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[Optional[_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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: ~azure.mgmt.keyvault.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.keyvault.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Required. - :type properties: 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.keyvault.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, - resource_group_name: str, - vault_name: str, - private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Updates the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :param properties: The intended state of private endpoint connection. Is either a - PrivateEndpointConnection type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.keyvault.models.PrivateEndpointConnection or IO[bytes] - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.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(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "PrivateEndpointConnection") - - _request = build_put_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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # 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 [200, 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - 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[_models.PrivateEndpointConnection]: - """Deletes the specified private endpoint connection associated with the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection associated - with the key vault. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.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.PrivateEndpointConnection] = 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): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_resource( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> ItemPaged["_models.PrivateEndpointConnection"]: - """The List operation gets information about the private endpoint connections associated with the - vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. 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.keyvault.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_by_resource_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_link_resources_operations.py deleted file mode 100644 index 05c487889953..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# 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, Optional, TypeVar - -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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_vault_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateLinkResources", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - } - - _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.keyvault.KeyVaultManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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_vault( - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources supported for the key vault. - - :param resource_group_name: Name of the resource group that contains the key vault. Required. - :type resource_group_name: str - :param vault_name: The name of the key vault. Required. - :type vault_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.PrivateLinkResourceListResult - :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_vault_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) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_secrets_operations.py deleted file mode 100644 index 5ec5d99951ba..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_secrets_operations.py +++ /dev/null @@ -1,639 +0,0 @@ -# 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, IO, Optional, TypeVar, Union, overload -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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, vault_name: str, secret_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", "2025-05-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.KeyVault/vaults/{vaultName}/secrets/{secretName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, vault_name: str, secret_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", "2025-05-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.KeyVault/vaults/{vaultName}/secrets/{secretName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str", pattern=r"^[a-zA-Z0-9-]{1,127}$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, vault_name: str, secret_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets/{secretName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, *, top: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/secrets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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 SecretsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`secrets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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 create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: _models.SecretCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Required. - :type parameters: 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: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: Union[_models.SecretCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - """Create or update a secret in a key vault in the specified subscription. NOTE: This API is - intended for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. The value you provide may be copied globally for the - purpose of running the service. The value provided should not include personally identifiable - or sensitive information. Required. - :type secret_name: str - :param parameters: Parameters to create or update the secret. Is either a - SecretCreateOrUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretCreateOrUpdateParameters or IO[bytes] - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SecretCreateOrUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", 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, - secret_name: str, - parameters: _models.SecretPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Required. - :type parameters: 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: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - vault_name: str, - secret_name: str, - parameters: Union[_models.SecretPatchParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - """Update a secret in the specified subscription. NOTE: This API is intended for internal use in - ARM deployments. Users should use the data-plane REST service for interaction with vault - secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param secret_name: Name of the secret. Required. - :type secret_name: str - :param parameters: Parameters to patch the secret. Is either a SecretPatchParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.SecretPatchParameters or IO[bytes] - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SecretPatchParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, vault_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: - """Gets the specified secret. NOTE: This API is intended for internal use in ARM deployments. - Users should use the data-plane REST service for interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param secret_name: The name of the secret. Required. - :type secret_name: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Secret - :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.Secret] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - secret_name=secret_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, vault_name: str, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.Secret"]: - """The List operation gets information about the secrets in a vault. NOTE: This API is intended - for internal use in ARM deployments. Users should use the data-plane REST service for - interaction with vault secrets. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Secret or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Secret] - :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.SecretListResult] = 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, - top=top, - 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("SecretListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_vaults_operations.py deleted file mode 100644 index 8ce68074f54f..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/azure/mgmt/keyvault/operations/_vaults_operations.py +++ /dev/null @@ -1,1568 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# 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, IO, Iterator, Literal, 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 KeyVaultManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_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", "2025-05-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.KeyVault/vaults/{vaultName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2025-05-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.KeyVault/vaults/{vaultName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_access_policy_request( - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - 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", "2025-05-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.KeyVault/vaults/{vaultName}/accessPolicies/{operationKind}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), - "operationKind": _SERIALIZER.url("operation_kind", operation_kind, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request( - resource_group_name: str, subscription_id: str, *, top: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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_list_by_subscription_request( - subscription_id: str, *, top: 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/vaults") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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_list_deleted_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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_deleted_request(vault_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}", - ) - path_format_arguments = { - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_purge_deleted_request(vault_name: str, 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", "2025-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge", - ) - path_format_arguments = { - "vaultName": _SERIALIZER.url("vault_name", vault_name, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( - "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") - ) - api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _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_check_name_availability_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", "2025-05-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.KeyVault/checkNameAvailability" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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 VaultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.keyvault.KeyVaultManagementClient`'s - :attr:`vaults` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: KeyVaultManagementClientConfiguration = 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") - - def _create_or_update_initial( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultCreateOrUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - vault_name=vault_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) - - _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 [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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: _models.VaultCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters - :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 Vault or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Required. - :type parameters: 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 Vault or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultCreateOrUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Vault]: - """Create or update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to create or update the vault. Is either a - VaultCreateOrUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultCreateOrUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Vault or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.keyvault.models.Vault] - :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)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Vault] = 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._create_or_update_initial( - resource_group_name=resource_group_name, - vault_name=vault_name, - parameters=parameters, - 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): - deserialized = self._deserialize("Vault", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Vault].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Vault]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @overload - def update( - self, - resource_group_name: str, - vault_name: str, - parameters: _models.VaultPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - vault_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Required. - :type parameters: 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: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - vault_name: str, - parameters: Union[_models.VaultPatchParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Vault: - """Update a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the server belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param parameters: Parameters to patch the vault. Is either a VaultPatchParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultPatchParameters or IO[bytes] - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :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.Vault] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultPatchParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - vault_name=vault_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - """Deletes the specified Azure key vault. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault to delete. Required. - :type vault_name: str - :return: None or the result of cls(response) - :rtype: None - :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[None] = kwargs.pop("cls", None) - - _request = build_delete_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) - - _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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.Vault: - """Gets the specified Azure key vault. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: The name of the vault. Required. - :type vault_name: str - :return: Vault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.Vault - :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.Vault] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Vault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: _models.VaultAccessPolicyParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Required. - :type parameters: 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: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_access_policy( - self, - resource_group_name: str, - vault_name: str, - operation_kind: Union[str, _models.AccessPolicyUpdateKind], - parameters: Union[_models.VaultAccessPolicyParameters, IO[bytes]], - **kwargs: Any - ) -> _models.VaultAccessPolicyParameters: - """Update access policies in a key vault in the specified subscription. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param vault_name: Name of the vault. Required. - :type vault_name: str - :param operation_kind: Name of the operation. Known values are: "add", "replace", and "remove". - Required. - :type operation_kind: str or ~azure.mgmt.keyvault.models.AccessPolicyUpdateKind - :param parameters: Access policy to merge into the vault. Is either a - VaultAccessPolicyParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters or IO[bytes] - :return: VaultAccessPolicyParameters or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.VaultAccessPolicyParameters - :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.VaultAccessPolicyParameters] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VaultAccessPolicyParameters") - - _request = build_update_access_policy_request( - resource_group_name=resource_group_name, - vault_name=vault_name, - operation_kind=operation_kind, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VaultAccessPolicyParameters", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.Vault"]: - """The List operation gets information about the vaults associated with the subscription and - within the specified resource group. - - :param resource_group_name: The name of the Resource Group to which the vault belongs. - Required. - :type resource_group_name: str - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Vault or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Vault] - :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.VaultListResult] = 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_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=top, - 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("VaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.Vault"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Vault or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Vault] - :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.VaultListResult] = 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, - top=top, - 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("VaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_deleted(self, **kwargs: Any) -> ItemPaged["_models.DeletedVault"]: - """Gets information about the deleted vaults in a subscription. - - :return: An iterator like instance of either DeletedVault or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.DeletedVault] - :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.DeletedVaultListResult] = 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_deleted_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("DeletedVaultListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_deleted(self, vault_name: str, location: str, **kwargs: Any) -> _models.DeletedVault: - """Gets the deleted Azure key vault. - - :param vault_name: The name of the vault. Required. - :type vault_name: str - :param location: The location of the deleted vault. Required. - :type location: str - :return: DeletedVault or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.DeletedVault - :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.DeletedVault] = kwargs.pop("cls", None) - - _request = build_get_deleted_request( - vault_name=vault_name, - location=location, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DeletedVault", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _purge_deleted_initial(self, vault_name: str, location: 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_purge_deleted_request( - vault_name=vault_name, - location=location, - 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 [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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_purge_deleted(self, vault_name: str, location: str, **kwargs: Any) -> LROPoller[None]: - """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. - - :param vault_name: The name of the soft-deleted vault. Required. - :type vault_name: str - :param location: The location of the soft-deleted vault. Required. - :type location: 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._purge_deleted_initial( - vault_name=vault_name, - location=location, - 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, **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 - - @distributed_trace - def list(self, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.Resource"]: - """The List operation gets information about the vaults associated with the subscription. - - :param top: Maximum number of results to return. Default value is None. - :type top: int - :return: An iterator like instance of either Resource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.keyvault.models.Resource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - filter: Literal["resourceType eq 'Microsoft.KeyVault/vaults'"] = kwargs.pop( - "filter", _params.pop("$filter", "resourceType eq 'Microsoft.KeyVault/vaults'") - ) - api_version: Literal["2015-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-11-01")) - cls: ClsType[_models.ResourceListResult] = 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( - subscription_id=self._config.subscription_id, - top=top, - filter=filter, - 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("ResourceListResult", 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def check_name_availability( - self, - vault_name: _models.VaultCheckNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Required. - :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, vault_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Required. - :type vault_name: 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: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, vault_name: Union[_models.VaultCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Checks that the vault name is valid and is not already in use. - - :param vault_name: The name of the vault. Is either a VaultCheckNameAvailabilityParameters type - or a IO[bytes] type. Required. - :type vault_name: ~azure.mgmt.keyvault.models.VaultCheckNameAvailabilityParameters or IO[bytes] - :return: CheckNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.keyvault.models.CheckNameAvailabilityResult - :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.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vault_name, (IOBase, bytes)): - _content = vault_name - else: - _json = self._serialize.body(vault_name, "VaultCheckNameAvailabilityParameters") - - _request = build_check_name_availability_request( - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py index 2fb4fcb81ec5..ccf51fe920ad 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/check_vault_name_availability.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.check_name_availability( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/checkVaultNameAvailability.json +# x-ms-original-file: 2025-05-01/checkVaultNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py index b26c4df5669a..6894818ce3d5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_key.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.keys.create_if_not_exist( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/createKey.json +# x-ms-original-file: 2025-05-01/createKey.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py index 14af53cd154d..802a8a807cb2 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_secret.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/createSecret.json +# x-ms-original-file: 2025-05-01/createSecret.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py index 69976ee5505e..801f1049efda 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.begin_create_or_update( @@ -92,6 +91,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/createVault.json +# x-ms-original-file: 2025-05-01/createVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py index 8bea06fd66a5..b5d866b4551b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/create_vault_with_network_acls.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.begin_create_or_update( @@ -58,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/createVaultWithNetworkAcls.json +# x-ms-original-file: 2025-05-01/createVaultWithNetworkAcls.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_private_endpoint_connection.py index db37d7f4e6a2..8f5d2f66f809 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.begin_delete( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/deletePrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/deletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_vault.py index 378949c2ee7c..67ac8768baa3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/delete_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.vaults.delete( @@ -37,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/deleteVault.json +# x-ms-original-file: 2025-05-01/deleteVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_get.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_get.py index 32b69d604ffb..b784591a5ff4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_get.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_get.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.get_deleted( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/DeletedManagedHsm_Get.json +# x-ms-original-file: 2025-05-01/DeletedManagedHsm_Get.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_list.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_list.py index 8c1fb22c7e1a..8009eec9dd70 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_list.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_list.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.list_deleted() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/DeletedManagedHsm_List.json +# x-ms-original-file: 2025-05-01/DeletedManagedHsm_List.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_purge.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_purge.py index ce5bf549164c..286795339e6a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_purge.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/deleted_managed_hsm_purge.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.managed_hsms.begin_purge_deleted( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/DeletedManagedHsm_Purge.json +# x-ms-original-file: 2025-05-01/DeletedManagedHsm_Purge.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_deleted_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_deleted_vault.py index 17f41aaf9461..efd912712fc0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_deleted_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_deleted_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.get_deleted( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getDeletedVault.json +# x-ms-original-file: 2025-05-01/getDeletedVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key.py index 994750cb1f71..1386d0fad34a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.keys.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getKey.json +# x-ms-original-file: 2025-05-01/getKey.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key_version.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key_version.py index c92869f1beed..1d29a96bdccc 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_key_version.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.keys.get_version( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getKeyVersion.json +# x-ms-original-file: 2025-05-01/getKeyVersion.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_private_endpoint_connection.py index f4338aa09fdf..892344f162ad 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getPrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/getPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_secret.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_secret.py index b30eb66b9cbe..5113cc9dd1c1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_secret.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_secret.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getSecret.json +# x-ms-original-file: 2025-05-01/getSecret.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_vault.py index a8ce83de3350..3bae8cba95b4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/get_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/getVault.json +# x-ms-original-file: 2025-05-01/getVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_deleted_vaults.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_deleted_vaults.py index dd309de17de2..b4d59fcec5a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_deleted_vaults.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_deleted_vaults.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.list_deleted() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listDeletedVaults.json +# x-ms-original-file: 2025-05-01/listDeletedVaults.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_key_versions.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_key_versions.py index 72b3aa1ab9ab..60a6edfa39e4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_key_versions.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_key_versions.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.keys.list_versions( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listKeyVersions.json +# x-ms-original-file: 2025-05-01/listKeyVersions.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_keys.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_keys.py index 59256be71fa1..d734c94fb0ce 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_keys.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_keys.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.keys.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listKeys.json +# x-ms-original-file: 2025-05-01/listKeys.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_operations.py index 848bafa2aec6..293031a36840 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_operations.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listOperations.json +# x-ms-original-file: 2025-05-01/listOperations.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_endpoint_connection.py index 752e9f13bcb2..02b54d00b8ea 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list_by_resource( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listPrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/listPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_link_resources.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_link_resources.py index 53aade441f2e..c6b9160a00d1 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_link_resources.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_private_link_resources.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.list_by_vault( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listPrivateLinkResources.json +# x-ms-original-file: 2025-05-01/listPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_secrets.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_secrets.py index 086357be2d99..8e320c192728 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_secrets.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_secrets.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listSecrets.json +# x-ms-original-file: 2025-05-01/listSecrets.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault.py index 9cc7bc7bb1c8..345456a1534a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listVault.json +# x-ms-original-file: 2025-05-01/listVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_resource_group.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_resource_group.py index d67f172bf3c9..00cfe4d46aae 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_resource_group.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_resource_group.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listVaultByResourceGroup.json +# x-ms-original-file: 2025-05-01/listVaultByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_subscription.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_subscription.py index 9c1e4bb956e0..a04cf28a81c8 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_subscription.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/list_vault_by_subscription.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.list_by_subscription() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/listVaultBySubscription.json +# x-ms-original-file: 2025-05-01/listVaultBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py index 3e4ebd3f5c4e..257cbca68c95 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_check_mhsm_name_availability.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.check_mhsm_name_availability( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_checkMhsmNameAvailability.json +# x-ms-original-file: 2025-05-01/ManagedHsm_checkMhsmNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py index ef6572624890..0d2425f0f03a 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_key.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsm_keys.create_if_not_exist( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/managedHsmCreateKey.json +# x-ms-original-file: 2025-05-01/managedHsmCreateKey.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py index 748f846d361b..1e6544dd59fc 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_create_or_update.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.begin_create_or_update( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_CreateOrUpdate.json +# x-ms-original-file: 2025-05-01/ManagedHsm_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete.py index 743fcd607d75..f766a3d8244f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.managed_hsms.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_Delete.json +# x-ms-original-file: 2025-05-01/ManagedHsm_Delete.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete_private_endpoint_connection.py index 5d51475a360d..d9cd3055d7aa 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_delete_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_private_endpoint_connections.begin_delete( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_deletePrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/ManagedHsm_deletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get.py index 59d99621bc3e..9658c5225550 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_Get.json +# x-ms-original-file: 2025-05-01/ManagedHsm_Get.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key.py index c07a56acd4cd..b5e6f725ff15 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsm_keys.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/managedHsmGetKey.json +# x-ms-original-file: 2025-05-01/managedHsmGetKey.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key_version.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key_version.py index 84a8ad294878..2af079d747bb 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key_version.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_key_version.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsm_keys.get_version( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/managedHsmGetKeyVersion.json +# x-ms-original-file: 2025-05-01/managedHsmGetKeyVersion.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_private_endpoint_connection.py index 82c1395bcfba..3383d75af164 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_get_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_private_endpoint_connections.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_getPrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/ManagedHsm_getPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_resource_group.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_resource_group.py index 91f3f7e44722..91b318b25cda 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_resource_group.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_resource_group.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_ListByResourceGroup.json +# x-ms-original-file: 2025-05-01/ManagedHsm_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_subscription.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_subscription.py index 9d930644eebc..9785286b2b5f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_subscription.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_by_subscription.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.list_by_subscription() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_ListBySubscription.json +# x-ms-original-file: 2025-05-01/ManagedHsm_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_key_versions.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_key_versions.py index e0eca8631d11..f7e52b5e1662 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_key_versions.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_key_versions.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsm_keys.list_versions( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/managedHsmListKeyVersions.json +# x-ms-original-file: 2025-05-01/managedHsmListKeyVersions.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_keys.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_keys.py index 6db3f07e8065..b84282b4eb1d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_keys.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_keys.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsm_keys.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/managedHsmListKeys.json +# x-ms-original-file: 2025-05-01/managedHsmListKeys.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_endpoint_connections_by_resource.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_endpoint_connections_by_resource.py index c91c1c4787a1..6038dade842f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_endpoint_connections_by_resource.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_endpoint_connections_by_resource.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_private_endpoint_connections.list_by_resource( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json +# x-ms-original-file: 2025-05-01/ManagedHsm_ListPrivateEndpointConnectionsByResource.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_link_resources.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_link_resources.py index 49f2c1b4dc06..fe031c16a1b0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_link_resources.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_private_link_resources.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_private_link_resources.list_by_mhsm_resource( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_listPrivateLinkResources.json +# x-ms-original-file: 2025-05-01/ManagedHsm_listPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_regions_by_resource.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_regions_by_resource.py index e1311ab7e2a9..90468041c126 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_regions_by_resource.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_list_regions_by_resource.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_regions.list_by_resource( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_ListRegionsByResource.json +# x-ms-original-file: 2025-05-01/ManagedHsm_ListRegionsByResource.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py index 139cf7a878f7..23ea08d072e4 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_put_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.mhsm_private_endpoint_connections.put( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_putPrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/ManagedHsm_putPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py index 9d05fecc6655..2b8531933174 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/managed_hsm_update.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_hsms.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/ManagedHsm_Update.json +# x-ms-original-file: 2025-05-01/ManagedHsm_Update.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/purge_deleted_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/purge_deleted_vault.py index 70b54c80f468..0bd986cf3a21 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/purge_deleted_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/purge_deleted_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.vaults.begin_purge_deleted( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/purgeDeletedVault.json +# x-ms-original-file: 2025-05-01/purgeDeletedVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py index 2cbb0f50eaee..d826d6677e9b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/put_private_endpoint_connection.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.put( @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/putPrivateEndpointConnection.json +# x-ms-original-file: 2025-05-01/putPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py index bb4ef7496b8b..28a27a33e661 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_access_policies_add.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.update_access_policy( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/updateAccessPoliciesAdd.json +# x-ms-original-file: 2025-05-01/updateAccessPoliciesAdd.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py index 7cf30d9a7206..575af3b9db53 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_secret.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/updateSecret.json +# x-ms-original-file: 2025-05-01/updateSecret.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py index babdc7c95645..984afd34bc0e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_samples/update_vault.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = KeyVaultManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.vaults.update( @@ -91,6 +90,6 @@ def main(): print(response) -# x-ms-original-file: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2025-05-01/examples/updateVault.json +# x-ms-original-file: 2025-05-01/updateVault.json if __name__ == "__main__": main() diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py index 924599a32089..fe9899369c6e 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py index 843dfb88555f..406f6731bf2f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestKeyVaultManagementKeysOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_keys_get(self, resource_group): + response = self.client.keys.get( + resource_group_name=resource_group.name, + vault_name="str", + key_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_keys_create_if_not_exist(self, resource_group): @@ -31,7 +43,7 @@ def test_keys_create_if_not_exist(self, resource_group): "created": 0, "enabled": bool, "exp": 0, - "exportable": False, + "exportable": bool, "nbf": 0, "recoveryLevel": "str", "updated": 0, @@ -42,10 +54,7 @@ def test_keys_create_if_not_exist(self, resource_group): "keyUri": "str", "keyUriWithVersion": "str", "kty": "str", - "release_policy": { - "contentType": "application/json; charset=utf-8", - "data": bytes("bytes", encoding="utf-8"), - }, + "release_policy": {"contentType": "str", "data": bytes("bytes", encoding="utf-8")}, "rotationPolicy": { "attributes": {"created": 0, "expiryTime": "str", "updated": 0}, "lifetimeActions": [ @@ -58,20 +67,6 @@ def test_keys_create_if_not_exist(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_keys_get(self, resource_group): - response = self.client.keys.get( - resource_group_name=resource_group.name, - vault_name="str", - key_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -83,7 +78,6 @@ def test_keys_list(self, resource_group): response = self.client.keys.list( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -97,7 +91,6 @@ def test_keys_get_version(self, resource_group): vault_name="str", key_name="str", key_version="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -110,7 +103,6 @@ def test_keys_list_versions(self, resource_group): resource_group_name=resource_group.name, vault_name="str", key_name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py index 124771f84a87..ebaa4ac63f99 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_keys_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestKeyVaultManagementKeysOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_keys_get(self, resource_group): + response = await self.client.keys.get( + resource_group_name=resource_group.name, + vault_name="str", + key_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_keys_create_if_not_exist(self, resource_group): @@ -32,7 +44,7 @@ async def test_keys_create_if_not_exist(self, resource_group): "created": 0, "enabled": bool, "exp": 0, - "exportable": False, + "exportable": bool, "nbf": 0, "recoveryLevel": "str", "updated": 0, @@ -43,10 +55,7 @@ async def test_keys_create_if_not_exist(self, resource_group): "keyUri": "str", "keyUriWithVersion": "str", "kty": "str", - "release_policy": { - "contentType": "application/json; charset=utf-8", - "data": bytes("bytes", encoding="utf-8"), - }, + "release_policy": {"contentType": "str", "data": bytes("bytes", encoding="utf-8")}, "rotationPolicy": { "attributes": {"created": 0, "expiryTime": "str", "updated": 0}, "lifetimeActions": [ @@ -59,20 +68,6 @@ async def test_keys_create_if_not_exist(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_keys_get(self, resource_group): - response = await self.client.keys.get( - resource_group_name=resource_group.name, - vault_name="str", - key_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -84,7 +79,6 @@ async def test_keys_list(self, resource_group): response = self.client.keys.list( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -98,7 +92,6 @@ async def test_keys_get_version(self, resource_group): vault_name="str", key_name="str", key_version="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -111,7 +104,6 @@ async def test_keys_list_versions(self, resource_group): resource_group_name=resource_group.name, vault_name="str", key_name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py index f10b7c5f5592..ade9859a68d0 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestKeyVaultManagementManagedHsmKeysOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_hsm_keys_get(self, resource_group): + response = self.client.managed_hsm_keys.get( + resource_group_name=resource_group.name, + name="str", + key_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_hsm_keys_create_if_not_exist(self, resource_group): @@ -42,10 +54,7 @@ def test_managed_hsm_keys_create_if_not_exist(self, resource_group): "keyUri": "str", "keyUriWithVersion": "str", "kty": "str", - "release_policy": { - "contentType": "application/json; charset=utf-8", - "data": bytes("bytes", encoding="utf-8"), - }, + "release_policy": {"contentType": "str", "data": bytes("bytes", encoding="utf-8")}, "rotationPolicy": { "attributes": {"created": 0, "expiryTime": "str", "updated": 0}, "lifetimeActions": [ @@ -58,20 +67,6 @@ def test_managed_hsm_keys_create_if_not_exist(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_hsm_keys_get(self, resource_group): - response = self.client.managed_hsm_keys.get( - resource_group_name=resource_group.name, - name="str", - key_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -83,7 +78,6 @@ def test_managed_hsm_keys_list(self, resource_group): response = self.client.managed_hsm_keys.list( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -97,7 +91,6 @@ def test_managed_hsm_keys_get_version(self, resource_group): name="str", key_name="str", key_version="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -110,7 +103,6 @@ def test_managed_hsm_keys_list_versions(self, resource_group): resource_group_name=resource_group.name, name="str", key_name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py index 4baa50468d13..3b23ed4e6dd3 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsm_keys_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestKeyVaultManagementManagedHsmKeysOperationsAsync(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_hsm_keys_get(self, resource_group): + response = await self.client.managed_hsm_keys.get( + resource_group_name=resource_group.name, + name="str", + key_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_hsm_keys_create_if_not_exist(self, resource_group): @@ -43,10 +55,7 @@ async def test_managed_hsm_keys_create_if_not_exist(self, resource_group): "keyUri": "str", "keyUriWithVersion": "str", "kty": "str", - "release_policy": { - "contentType": "application/json; charset=utf-8", - "data": bytes("bytes", encoding="utf-8"), - }, + "release_policy": {"contentType": "str", "data": bytes("bytes", encoding="utf-8")}, "rotationPolicy": { "attributes": {"created": 0, "expiryTime": "str", "updated": 0}, "lifetimeActions": [ @@ -59,20 +68,6 @@ async def test_managed_hsm_keys_create_if_not_exist(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_hsm_keys_get(self, resource_group): - response = await self.client.managed_hsm_keys.get( - resource_group_name=resource_group.name, - name="str", - key_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -84,7 +79,6 @@ async def test_managed_hsm_keys_list(self, resource_group): response = self.client.managed_hsm_keys.list( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -98,7 +92,6 @@ async def test_managed_hsm_keys_get_version(self, resource_group): name="str", key_name="str", key_version="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -111,7 +104,6 @@ async def test_managed_hsm_keys_list_versions(self, resource_group): resource_group_name=resource_group.name, name="str", key_name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py index 4499b606fc9a..aa3f6525fb9d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,17 @@ class TestKeyVaultManagementManagedHsmsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_hsms_get(self, resource_group): + response = self.client.managed_hsms.get( + resource_group_name=resource_group.name, + name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_hsms_begin_create_or_update(self, resource_group): @@ -36,8 +47,8 @@ def test_managed_hsms_begin_create_or_update(self, resource_group): "name": "str", "properties": { "createMode": "str", - "enablePurgeProtection": True, - "enableSoftDelete": True, + "enablePurgeProtection": bool, + "enableSoftDelete": bool, "hsmUri": "str", "initialAdminObjectIds": ["str"], "networkAcls": { @@ -51,25 +62,27 @@ def test_managed_hsms_begin_create_or_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "Enabled", + "publicNetworkAccess": "str", "regions": [{"isPrimary": bool, "name": "str", "provisioningState": "str"}], "scheduledPurgeDate": "2020-02-20 00:00:00", "securityDomainProperties": {"activationStatus": "str", "activationStatusMessage": "str"}, - "softDeleteRetentionInDays": 90, + "softDeleteRetentionInDays": 0, "statusMessage": "str", "tenantId": "str", }, - "sku": {"family": "B", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -81,7 +94,6 @@ def test_managed_hsms_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -105,8 +117,8 @@ def test_managed_hsms_begin_update(self, resource_group): "name": "str", "properties": { "createMode": "str", - "enablePurgeProtection": True, - "enableSoftDelete": True, + "enablePurgeProtection": bool, + "enableSoftDelete": bool, "hsmUri": "str", "initialAdminObjectIds": ["str"], "networkAcls": { @@ -120,25 +132,27 @@ def test_managed_hsms_begin_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "Enabled", + "publicNetworkAccess": "str", "regions": [{"isPrimary": bool, "name": "str", "provisioningState": "str"}], "scheduledPurgeDate": "2020-02-20 00:00:00", "securityDomainProperties": {"activationStatus": "str", "activationStatusMessage": "str"}, - "softDeleteRetentionInDays": 90, + "softDeleteRetentionInDays": 0, "statusMessage": "str", "tenantId": "str", }, - "sku": {"family": "B", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -150,7 +164,6 @@ def test_managed_hsms_begin_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -162,30 +175,16 @@ def test_managed_hsms_begin_delete(self, resource_group): response = self.client.managed_hsms.begin_delete( resource_group_name=resource_group.name, name="str", - api_version="2025-05-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_managed_hsms_get(self, resource_group): - response = self.client.managed_hsms.get( - resource_group_name=resource_group.name, - name="str", - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_hsms_list_by_resource_group(self, resource_group): response = self.client.managed_hsms.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -194,19 +193,7 @@ def test_managed_hsms_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_hsms_list_by_subscription(self, resource_group): - response = self.client.managed_hsms.list_by_subscription( - api_version="2025-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_hsms_list_deleted(self, resource_group): - response = self.client.managed_hsms.list_deleted( - api_version="2025-05-01", - ) + response = self.client.managed_hsms.list_by_subscription() result = [r for r in response] # please add some check logic here by yourself # ... @@ -217,7 +204,6 @@ def test_managed_hsms_get_deleted(self, resource_group): response = self.client.managed_hsms.get_deleted( name="str", location="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -229,18 +215,24 @@ def test_managed_hsms_begin_purge_deleted(self, resource_group): response = self.client.managed_hsms.begin_purge_deleted( name="str", location="str", - api_version="2025-05-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_managed_hsms_list_deleted(self, resource_group): + response = self.client.managed_hsms.list_deleted() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_hsms_check_mhsm_name_availability(self, resource_group): response = self.client.managed_hsms.check_mhsm_name_availability( mhsm_name={"name": "str"}, - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py index 806a4e1da9ca..2ea90eca4af9 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_managed_hsms_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,17 @@ class TestKeyVaultManagementManagedHsmsOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_hsms_get(self, resource_group): + response = await self.client.managed_hsms.get( + resource_group_name=resource_group.name, + name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_hsms_begin_create_or_update(self, resource_group): @@ -38,8 +49,8 @@ async def test_managed_hsms_begin_create_or_update(self, resource_group): "name": "str", "properties": { "createMode": "str", - "enablePurgeProtection": True, - "enableSoftDelete": True, + "enablePurgeProtection": bool, + "enableSoftDelete": bool, "hsmUri": "str", "initialAdminObjectIds": ["str"], "networkAcls": { @@ -53,25 +64,27 @@ async def test_managed_hsms_begin_create_or_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "Enabled", + "publicNetworkAccess": "str", "regions": [{"isPrimary": bool, "name": "str", "provisioningState": "str"}], "scheduledPurgeDate": "2020-02-20 00:00:00", "securityDomainProperties": {"activationStatus": "str", "activationStatusMessage": "str"}, - "softDeleteRetentionInDays": 90, + "softDeleteRetentionInDays": 0, "statusMessage": "str", "tenantId": "str", }, - "sku": {"family": "B", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -83,7 +96,6 @@ async def test_managed_hsms_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -109,8 +121,8 @@ async def test_managed_hsms_begin_update(self, resource_group): "name": "str", "properties": { "createMode": "str", - "enablePurgeProtection": True, - "enableSoftDelete": True, + "enablePurgeProtection": bool, + "enableSoftDelete": bool, "hsmUri": "str", "initialAdminObjectIds": ["str"], "networkAcls": { @@ -124,25 +136,27 @@ async def test_managed_hsms_begin_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "Enabled", + "publicNetworkAccess": "str", "regions": [{"isPrimary": bool, "name": "str", "provisioningState": "str"}], "scheduledPurgeDate": "2020-02-20 00:00:00", "securityDomainProperties": {"activationStatus": "str", "activationStatusMessage": "str"}, - "softDeleteRetentionInDays": 90, + "softDeleteRetentionInDays": 0, "statusMessage": "str", "tenantId": "str", }, - "sku": {"family": "B", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -154,7 +168,6 @@ async def test_managed_hsms_begin_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -168,31 +181,17 @@ async def test_managed_hsms_begin_delete(self, resource_group): await self.client.managed_hsms.begin_delete( resource_group_name=resource_group.name, name="str", - api_version="2025-05-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_managed_hsms_get(self, resource_group): - response = await self.client.managed_hsms.get( - resource_group_name=resource_group.name, - name="str", - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_hsms_list_by_resource_group(self, resource_group): response = self.client.managed_hsms.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -201,19 +200,7 @@ async def test_managed_hsms_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_hsms_list_by_subscription(self, resource_group): - response = self.client.managed_hsms.list_by_subscription( - api_version="2025-05-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_managed_hsms_list_deleted(self, resource_group): - response = self.client.managed_hsms.list_deleted( - api_version="2025-05-01", - ) + response = self.client.managed_hsms.list_by_subscription() result = [r async for r in response] # please add some check logic here by yourself # ... @@ -224,7 +211,6 @@ async def test_managed_hsms_get_deleted(self, resource_group): response = await self.client.managed_hsms.get_deleted( name="str", location="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -237,19 +223,25 @@ async def test_managed_hsms_begin_purge_deleted(self, resource_group): await self.client.managed_hsms.begin_purge_deleted( name="str", location="str", - api_version="2025-05-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_managed_hsms_list_deleted(self, resource_group): + response = self.client.managed_hsms.list_deleted() + 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_managed_hsms_check_mhsm_name_availability(self, resource_group): response = await self.client.managed_hsms.check_mhsm_name_availability( mhsm_name={"name": "str"}, - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py index 311b1790fc8a..42b7a8aa6399 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestKeyVaultManagementMHSMPrivateEndpointConnectionsOperations(AzureMgmtRe def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): - response = self.client.mhsm_private_endpoint_connections.list_by_resource( - resource_group_name=resource_group.name, - name="str", - api_version="2025-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_mhsm_private_endpoint_connections_get(self, resource_group): @@ -37,7 +25,6 @@ def test_mhsm_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -61,10 +48,16 @@ def test_mhsm_private_endpoint_connections_put(self, resource_group): }, "location": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "str", - "sku": {"family": "B", "name": "str"}, + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -76,7 +69,6 @@ def test_mhsm_private_endpoint_connections_put(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -89,8 +81,18 @@ def test_mhsm_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, name="str", private_endpoint_connection_name="str", - api_version="2025-05-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_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): + response = self.client.mhsm_private_endpoint_connections.list_by_resource( + resource_group_name=resource_group.name, + name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py index 9d2548be2aa6..f570c99b6fd6 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_endpoint_connections_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestKeyVaultManagementMHSMPrivateEndpointConnectionsOperationsAsync(AzureM def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): - response = self.client.mhsm_private_endpoint_connections.list_by_resource( - resource_group_name=resource_group.name, - name="str", - api_version="2025-05-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_mhsm_private_endpoint_connections_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_mhsm_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -62,10 +49,16 @@ async def test_mhsm_private_endpoint_connections_put(self, resource_group): }, "location": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "str", - "sku": {"family": "B", "name": "str"}, + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + }, + "sku": {"family": "str", "name": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -77,7 +70,6 @@ async def test_mhsm_private_endpoint_connections_put(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -91,9 +83,19 @@ async def test_mhsm_private_endpoint_connections_begin_delete(self, resource_gro resource_group_name=resource_group.name, name="str", private_endpoint_connection_name="str", - api_version="2025-05-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_mhsm_private_endpoint_connections_list_by_resource(self, resource_group): + response = self.client.mhsm_private_endpoint_connections.list_by_resource( + resource_group_name=resource_group.name, + name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py index e21728724d9f..ce82306a840f 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_mhsm_private_link_resources_list_by_mhsm_resource(self, resource_group) response = self.client.mhsm_private_link_resources.list_by_mhsm_resource( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py index b8067e7f9b1e..39701b7dad62 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_mhsm_private_link_resources_list_by_mhsm_resource(self, resource_ response = await self.client.mhsm_private_link_resources.list_by_mhsm_resource( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py index 49e6d1101826..5068c5e1c592 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_mhsm_regions_list_by_resource(self, resource_group): response = self.client.mhsm_regions.list_by_resource( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py index 79c1adee6b4b..a81233856c85 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_mhsm_regions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_mhsm_regions_list_by_resource(self, resource_group): response = self.client.mhsm_regions.list_by_resource( resource_group_name=resource_group.name, name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py index 5decaadda93e..a606e05f3e59 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,9 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2025-05-01", - ) + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py index 2c77a0610d5a..66dfea1e9385 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,9 +22,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2025-05-01", - ) + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py index 89c57d543e47..689c19afc291 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, vault_name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -43,13 +42,26 @@ def test_private_endpoint_connections_put(self, resource_group): "id": "str", "location": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "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", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -62,7 +74,6 @@ def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, vault_name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -74,7 +85,6 @@ def test_private_endpoint_connections_list_by_resource(self, resource_group): response = self.client.private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py index be2726e085f7..dc77fc741ce5 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_endpoint_connections_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, vault_name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -44,13 +43,26 @@ async def test_private_endpoint_connections_put(self, resource_group): "id": "str", "location": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "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", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -64,7 +76,6 @@ async def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, vault_name="str", private_endpoint_connection_name="str", - api_version="2025-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -77,7 +88,6 @@ async def test_private_endpoint_connections_list_by_resource(self, resource_grou response = self.client.private_endpoint_connections.list_by_resource( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py index ca77a57bcf30..8a0d0f919d85 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_private_link_resources_list_by_vault(self, resource_group): response = self.client.private_link_resources.list_by_vault( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py index 101add7c2a2f..0ed3e445cf0b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_private_link_resources_list_by_vault(self, resource_group): response = await self.client.private_link_resources.list_by_vault( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py index 672974e1d13d..76bf7223e328 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestKeyVaultManagementSecretsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secrets_get(self, resource_group): + response = self.client.secrets.get( + resource_group_name=resource_group.name, + vault_name="str", + secret_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_secrets_create_or_update(self, resource_group): @@ -41,7 +53,6 @@ def test_secrets_create_or_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -68,20 +79,6 @@ def test_secrets_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_secrets_get(self, resource_group): - response = self.client.secrets.get( - resource_group_name=resource_group.name, - vault_name="str", - secret_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -93,7 +90,6 @@ def test_secrets_list(self, resource_group): response = self.client.secrets.list( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py index b56870b3174c..53acabf58ae7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_secrets_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestKeyVaultManagementSecretsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secrets_get(self, resource_group): + response = await self.client.secrets.get( + resource_group_name=resource_group.name, + vault_name="str", + secret_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_secrets_create_or_update(self, resource_group): @@ -42,7 +54,6 @@ async def test_secrets_create_or_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -69,20 +80,6 @@ async def test_secrets_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_secrets_get(self, resource_group): - response = await self.client.secrets.get( - resource_group_name=resource_group.name, - vault_name="str", - secret_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -94,7 +91,6 @@ async def test_secrets_list(self, resource_group): response = self.client.secrets.list( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py index cb6da6d8c1c5..ee0fc69fa4b7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,17 @@ class TestKeyVaultManagementVaultsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vaults_get(self, resource_group): + response = self.client.vaults.get( + resource_group_name=resource_group.name, + vault_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_vaults_begin_create_or_update(self, resource_group): @@ -27,7 +38,7 @@ def test_vaults_begin_create_or_update(self, resource_group): parameters={ "location": "str", "properties": { - "sku": {"family": "A", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "tenantId": "str", "accessPolicies": [ { @@ -44,11 +55,11 @@ def test_vaults_begin_create_or_update(self, resource_group): ], "createMode": "str", "enablePurgeProtection": bool, - "enableRbacAuthorization": False, - "enableSoftDelete": True, - "enabledForDeployment": False, - "enabledForDiskEncryption": False, - "enabledForTemplateDeployment": False, + "enableRbacAuthorization": bool, + "enableSoftDelete": bool, + "enabledForDeployment": bool, + "enabledForDiskEncryption": bool, + "enabledForTemplateDeployment": bool, "hsmPoolResourceId": "str", "networkAcls": { "bypass": "str", @@ -60,23 +71,24 @@ def test_vaults_begin_create_or_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "enabled", - "softDeleteRetentionInDays": 90, + "publicNetworkAccess": "str", + "softDeleteRetentionInDays": 0, "vaultUri": "str", }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -117,13 +129,12 @@ def test_vaults_update(self, resource_group): "virtualNetworkRules": [{"id": "str", "ignoreMissingVnetServiceEndpoint": bool}], }, "publicNetworkAccess": "str", - "sku": {"family": "A", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "softDeleteRetentionInDays": 0, "tenantId": "str", }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -135,7 +146,6 @@ def test_vaults_delete(self, resource_group): response = self.client.vaults.delete( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -143,13 +153,19 @@ def test_vaults_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_vaults_get(self, resource_group): - response = self.client.vaults.get( + def test_vaults_list_by_resource_group(self, resource_group): + response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, - vault_name="str", - api_version="2025-05-01", ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vaults_list_by_subscription(self, resource_group): + response = self.client.vaults.list_by_subscription() + result = [r for r in response] # please add some check logic here by yourself # ... @@ -181,50 +197,17 @@ def test_vaults_update_access_policy(self, resource_group): "name": "str", "type": "str", }, - api_version="2025-05-01", ) # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_vaults_list_by_resource_group(self, resource_group): - response = self.client.vaults.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2025-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_vaults_list_by_subscription(self, resource_group): - response = self.client.vaults.list_by_subscription( - api_version="2025-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_vaults_list_deleted(self, resource_group): - response = self.client.vaults.list_deleted( - api_version="2025-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_vaults_get_deleted(self, resource_group): response = self.client.vaults.get_deleted( vault_name="str", location="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -236,12 +219,19 @@ def test_vaults_begin_purge_deleted(self, resource_group): response = self.client.vaults.begin_purge_deleted( vault_name="str", location="str", - api_version="2025-05-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_vaults_list_deleted(self, resource_group): + response = self.client.vaults.list_deleted() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_vaults_list(self, resource_group): @@ -258,7 +248,6 @@ def test_vaults_list(self, resource_group): def test_vaults_check_name_availability(self, resource_group): response = self.client.vaults.check_name_availability( vault_name={"name": "str", "type": "Microsoft.KeyVault/vaults"}, - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py index a156da32ec74..e7345489349d 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/generated_tests/test_key_vault_management_vaults_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,17 @@ class TestKeyVaultManagementVaultsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vaults_get(self, resource_group): + response = await self.client.vaults.get( + resource_group_name=resource_group.name, + vault_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_vaults_begin_create_or_update(self, resource_group): @@ -29,7 +40,7 @@ async def test_vaults_begin_create_or_update(self, resource_group): parameters={ "location": "str", "properties": { - "sku": {"family": "A", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "tenantId": "str", "accessPolicies": [ { @@ -46,11 +57,11 @@ async def test_vaults_begin_create_or_update(self, resource_group): ], "createMode": "str", "enablePurgeProtection": bool, - "enableRbacAuthorization": False, - "enableSoftDelete": True, - "enabledForDeployment": False, - "enabledForDiskEncryption": False, - "enabledForTemplateDeployment": False, + "enableRbacAuthorization": bool, + "enableSoftDelete": bool, + "enabledForDeployment": bool, + "enabledForDiskEncryption": bool, + "enabledForTemplateDeployment": bool, "hsmPoolResourceId": "str", "networkAcls": { "bypass": "str", @@ -62,23 +73,24 @@ async def test_vaults_begin_create_or_update(self, resource_group): { "etag": "str", "id": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", } ], "provisioningState": "str", - "publicNetworkAccess": "enabled", - "softDeleteRetentionInDays": 90, + "publicNetworkAccess": "str", + "softDeleteRetentionInDays": 0, "vaultUri": "str", }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -120,13 +132,12 @@ async def test_vaults_update(self, resource_group): "virtualNetworkRules": [{"id": "str", "ignoreMissingVnetServiceEndpoint": bool}], }, "publicNetworkAccess": "str", - "sku": {"family": "A", "name": "str"}, + "sku": {"family": "str", "name": "str"}, "softDeleteRetentionInDays": 0, "tenantId": "str", }, "tags": {"str": "str"}, }, - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -138,7 +149,6 @@ async def test_vaults_delete(self, resource_group): response = await self.client.vaults.delete( resource_group_name=resource_group.name, vault_name="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -146,13 +156,19 @@ async def test_vaults_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_vaults_get(self, resource_group): - response = await self.client.vaults.get( + async def test_vaults_list_by_resource_group(self, resource_group): + response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, - vault_name="str", - api_version="2025-05-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_vaults_list_by_subscription(self, resource_group): + response = self.client.vaults.list_by_subscription() + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -184,40 +200,8 @@ async def test_vaults_update_access_policy(self, resource_group): "name": "str", "type": "str", }, - api_version="2025-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_vaults_list_by_resource_group(self, resource_group): - response = self.client.vaults.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2025-05-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_vaults_list_by_subscription(self, resource_group): - response = self.client.vaults.list_by_subscription( - api_version="2025-05-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_vaults_list_deleted(self, resource_group): - response = self.client.vaults.list_deleted( - api_version="2025-05-01", - ) - result = [r async for r in response] # please add some check logic here by yourself # ... @@ -227,7 +211,6 @@ async def test_vaults_get_deleted(self, resource_group): response = await self.client.vaults.get_deleted( vault_name="str", location="str", - api_version="2025-05-01", ) # please add some check logic here by yourself @@ -240,13 +223,20 @@ async def test_vaults_begin_purge_deleted(self, resource_group): await self.client.vaults.begin_purge_deleted( vault_name="str", location="str", - api_version="2025-05-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_vaults_list_deleted(self, resource_group): + response = self.client.vaults.list_deleted() + 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_vaults_list(self, resource_group): @@ -263,7 +253,6 @@ async def test_vaults_list(self, resource_group): async def test_vaults_check_name_availability(self, resource_group): response = await self.client.vaults.check_name_availability( vault_name={"name": "str", "type": "Microsoft.KeyVault/vaults"}, - api_version="2025-05-01", ) # please add some check logic here by yourself diff --git a/sdk/keyvault/azure-mgmt-keyvault/pyproject.toml b/sdk/keyvault/azure-mgmt-keyvault/pyproject.toml index c1591da672f0..53df278bd915 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/pyproject.toml +++ b/sdk/keyvault/azure-mgmt-keyvault/pyproject.toml @@ -29,7 +29,7 @@ keywords = [ "azure sdk", ] dependencies = [ - "msrest>=0.7.1", + "isodate>=0.6.1", "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", ] @@ -54,8 +54,8 @@ content-type = "text/markdown" [tool.setuptools.packages.find] exclude = [ "tests*", - "samples*", "generated_tests*", + "samples*", "generated_samples*", "doc*", "azure", diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/disable_test_cli_mgmt_keyvault_async.py b/sdk/keyvault/azure-mgmt-keyvault/tests/disable_test_cli_mgmt_keyvault_async.py index 6df9ec1af5ad..265ce615e9b8 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/disable_test_cli_mgmt_keyvault_async.py +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/disable_test_cli_mgmt_keyvault_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_async_test.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_async_test.py index 53fc4097db51..7885b81ed2cd 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_async_test.py +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_async_test.py @@ -22,8 +22,6 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_list(self, resource_group): - response = self.client.operations.list( - api_version="2023-07-01", - ) + response = self.client.operations.list() result = [r async for r in response] assert result diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_test.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_test.py index 28526690f762..80303642c5a7 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_test.py +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_operations_test.py @@ -21,8 +21,6 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_list(self, resource_group): - response = self.client.operations.list( - api_version="2023-07-01", - ) + response = self.client.operations.list() result = [r for r in response] assert result diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_async_test.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_async_test.py index 14f7cc1c579e..cafaac22a35b 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_async_test.py +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_async_test.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest +import json from azure.mgmt.keyvault.aio import KeyVaultManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer @@ -24,7 +26,50 @@ def setup_method(self, method): async def test_list_by_resource_group(self, resource_group): response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2023-07-01", ) result = [r async for r in response] assert result == [] + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self): + response = self.client.vaults.list( + filter="resourceType eq 'Microsoft.KeyVault/vaults'", + ) + result = [r async for r in response] + assert result + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_customized_api_version(self): + # This API is legacy paging API that api-version of init request and next link must be "2015-11-01". + # Although this API violates ARM guidelines, we have to support it for backward compatibility. + # So After SDK generation, you need to customize 2 lines like https://github.com/Azure/azure-sdk-for-python/pull/43559/commits/6e09d1d513da26c55c7960442f0f20f5e59e149a. + # And the test is to verify the customization works. + call_count = 0 + inject_next_link = True + + def raw_request_hook(request): + # api-version in next link must be "2015-11-01" + assert ( + request.http_request.url.count("api-version=2015-11-01") == 1 + ), "api-version query parameter is missing or duplicated" + nonlocal call_count + call_count += 1 + + def raw_response_hook(response): + nonlocal inject_next_link + if inject_next_link: + content = response.http_response._content.decode("utf-8") + data = json.loads(content) + if "nextLink" not in data: + # make sure there is nextLink for testing + data["nextLink"] = response.http_request.url.replace("&api-version=2015-11-01", "") + new_content = json.dumps(data).encode("utf-8") + response.http_response._content = new_content + inject_next_link = False # only inject nextLink once + + response = self.client.vaults.list(raw_request_hook=raw_request_hook, raw_response_hook=raw_response_hook) + result = [r async for r in response] + assert result + assert call_count >= 2 # make sure paging happened diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_test.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_test.py index e7c2904b9bcf..1be04185f326 100644 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_test.py +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/test_key_vault_management_vaults_operations_test.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest +import json from azure.mgmt.keyvault import KeyVaultManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy @@ -23,7 +25,6 @@ def setup_method(self, method): def test_list_by_resource_group(self, resource_group): response = self.client.vaults.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2023-07-01", ) result = [r for r in response] assert result == [] @@ -32,7 +33,40 @@ def test_list_by_resource_group(self, resource_group): def test_list(self): response = self.client.vaults.list( filter="resourceType eq 'Microsoft.KeyVault/vaults'", - api_version="2015-11-01", ) result = [r for r in response] assert result + + @recorded_by_proxy + def test_list_customized_api_version(self): + # This API is legacy paging API that api-version of init request and next link must be "2015-11-01". + # Although this API violates ARM guidelines, we have to support it for backward compatibility. + # So After SDK generation, you need to customize 2 lines like https://github.com/Azure/azure-sdk-for-python/pull/43559/commits/6e09d1d513da26c55c7960442f0f20f5e59e149a. + # And the test is to verify the customization works. + call_count = 0 + inject_next_link = True + + def raw_request_hook(request): + # api-version in next link must be "2015-11-01" + assert ( + request.http_request.url.count("api-version=2015-11-01") == 1 + ), "api-version query parameter is missing or duplicated" + nonlocal call_count + call_count += 1 + + def raw_response_hook(response): + nonlocal inject_next_link + if inject_next_link: + content = response.http_response._content.decode("utf-8") + data = json.loads(content) + if "nextLink" not in data: + # make sure there is nextLink for testing + data["nextLink"] = response.http_request.url.replace("&api-version=2015-11-01", "") + new_content = json.dumps(data).encode("utf-8") + response.http_response._content = new_content + inject_next_link = False # only inject nextLink once + + response = self.client.vaults.list(raw_request_hook=raw_request_hook, raw_response_hook=raw_response_hook) + result = [r for r in response] + assert result + assert call_count >= 2 # make sure paging happened diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch.py deleted file mode 100644 index 31c1a17f57c8..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch.py +++ /dev/null @@ -1,30 +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.mgmt.keyvault import KeyVaultManagementClient -from devtools_testutils import AzureMgmtRecordedTestCase, recorded_by_proxy -from utils import all_api_versions -import pytest - - -@pytest.mark.live_test_only -class TestKeyVaultManagementPatch(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(KeyVaultManagementClient) - - @recorded_by_proxy - def test_list(self): - api_versions = all_api_versions() - assert api_versions - for api_version in api_versions: - # make sure the client uses api_version we set - self.client._get_api_version = lambda x: api_version - response = self.client.vaults.list( - filter="resourceType eq 'Microsoft.KeyVault/vaults'", - ) - result = [r for r in response] - assert result diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch_async.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch_async.py deleted file mode 100644 index c67bd984c6b0..000000000000 --- a/sdk/keyvault/azure-mgmt-keyvault/tests/test_patch_async.py +++ /dev/null @@ -1,34 +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. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.keyvault.aio import KeyVaultManagementClient -from devtools_testutils.aio import recorded_by_proxy_async -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from utils import all_api_versions - -AZURE_LOCATION = "eastus" - - -@pytest.mark.live_test_only -class TestKeyVaultManagementVaultsPatchAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(KeyVaultManagementClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_list(self): - api_versions = all_api_versions() - assert api_versions - for api_version in api_versions: - # make sure the client uses api_version we set - self.client._get_api_version = lambda x: api_version - response = self.client.vaults.list( - filter="resourceType eq 'Microsoft.KeyVault/vaults'", - ) - result = [r async for r in response] - assert result diff --git a/sdk/keyvault/azure-mgmt-keyvault/tests/test_unittest.py b/sdk/keyvault/azure-mgmt-keyvault/tests/test_unittest.py new file mode 100644 index 000000000000..38dd51c99310 --- /dev/null +++ b/sdk/keyvault/azure-mgmt-keyvault/tests/test_unittest.py @@ -0,0 +1,54 @@ +# 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.mgmt.keyvault.models import Key, KeyAttributes, KeyProperties, PrivateLinkResource +from azure.core.serialization import attribute_list + + +def test_model_initialization(): + key = Key(kty="EC", attributes=KeyAttributes(enabled=True), key_ops=["encrypt", "decrypt"]) + assert key.kty == "EC" + assert key.properties.kty == "EC" + assert key.attributes.enabled is True + assert key.properties.attributes.enabled is True + assert "encrypt" in key.key_ops + assert "decrypt" in key.key_ops + assert "encrypt" in key.properties.key_ops + assert "decrypt" in key.properties.key_ops + + +def test_model_attribute_list_for_compatibility(): + expected_attributes = sorted( + [ + "id", + "name", + "type", + "system_data", + "attributes", + "kty", + "key_ops", + "key_size", + "curve_name", + "key_uri", + "key_uri_with_version", + "rotation_policy", + "release_policy", + "location", + "tags", + ] + ) + assert expected_attributes == sorted(attribute_list(Key(properties=KeyProperties(kty="RSA")))) + assert expected_attributes == sorted(attribute_list(Key(kty="RSA"))) + assert expected_attributes == sorted(attribute_list(Key())) + + +def test_private_link_resource_initialization(): + plr = PrivateLinkResource( + group_id="vault", required_members=["member1", "member2"], required_zone_names=["zone1", "zone2"] + ) + assert plr.group_id == "vault" + assert plr.properties.group_id == "vault" diff --git a/sdk/keyvault/azure-mgmt-keyvault/tsp-location.yaml b/sdk/keyvault/azure-mgmt-keyvault/tsp-location.yaml new file mode 100644 index 000000000000..0a0b7250d8a9 --- /dev/null +++ b/sdk/keyvault/azure-mgmt-keyvault/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/keyvault/KeyVault.Management +commit: 74db5e79837425a7723e81bca0b7576ab725c186 +repo: Azure/azure-rest-api-specs +additionalDirectories: