diff --git a/src/cloudhsm/HISTORY.rst b/src/cloudhsm/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/cloudhsm/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/cloudhsm/README.md b/src/cloudhsm/README.md new file mode 100644 index 00000000000..5a969a2f460 --- /dev/null +++ b/src/cloudhsm/README.md @@ -0,0 +1,167 @@ +# Azure CLI Cloudhsm Extension # +This is an extension to Azure CLI to manage Cloudhsm resources. + +## Installation + +Install this extension using the CLI command: +```bash +az extension add --name cloudhsm +``` + +## Sample Usage + +### Prerequisites +- Azure subscription +- Resource group +- Storage account with blob container (for backup/restore operations) +- User-assigned managed identity (for backup/restore operations) + +### 1. Create a CloudHSM Cluster + +#### Basic CloudHSM creation: +```bash +az cloudhsm create \ + --resource-group myResourceGroup \ + --name myCloudHSM \ + --location eastus2 \ + --sku Standard_B1 \ + --tags Department=Security Environment=Production +``` + +#### CloudHSM with user-assigned managed identity: +```bash +az cloudhsm create \ + --resource-group myResourceGroup \ + --name myCloudHSM \ + --location eastus2 \ + --sku Standard_B1 \ + --domain-name-label-scope TenantReuse \ + --mi-user-assigned /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity \ + --tags Department=Security Environment=Production +``` + +#### Available SKUs: +- `Standard_B1` (default) + + +### 2. List CloudHSM Clusters + +#### List all CloudHSM clusters in subscription: +```bash +az cloudhsm list +``` + +#### List CloudHSM clusters in a specific resource group: +```bash +az cloudhsm list --resource-group myResourceGroup +``` + +### 3. Show CloudHSM Details + +```bash +az cloudhsm show \ + --resource-group myResourceGroup \ + --name myCloudHSM +``` + +### 4. Update CloudHSM + +```bash +az cloudhsm update \ + --resource-group myResourceGroup \ + --name myCloudHSM \ + --tags Department=Security Environment=Production Updated=true +``` + +### 5. Backup Operations + +#### Start a backup: +```bash +az cloudhsm backup start \ + --resource-group myResourceGroup \ + --cluster-name myCloudHSM \ + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" +``` + +#### Show backup status: +```bash +az cloudhsm backup show \ + --resource-group myResourceGroup \ + --cluster-name myCloudHSM \ + --job-id backup-job-id +``` + +### 6. Restore Operations + +#### Start a restore from backup: +```bash +az cloudhsm restore start \ + --resource-group myResourceGroup \ + --cluster-name myCloudHSM \ + --backup-id cloudhsm-0e35c989-c582-4b3c-958d-596e4c4fe133 \ + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" +``` + +#### Show restore status: +```bash +az cloudhsm restore show \ + --resource-group myResourceGroup \ + --cluster-name myCloudHSM \ + --job-id restore-job-id +``` + +### 7. Delete CloudHSM + +```bash +az cloudhsm delete \ + --resource-group myResourceGroup \ + --name myCloudHSM \ +``` + +## Common Scenarios + +### Scenario 1: Setup CloudHSM with Backup Strategy +```bash +# 1. Create CloudHSM +az cloudhsm create \ + --resource-group myResourceGroup \ + --name myCloudHSM \ + --location eastus2 \ + --sku Standard_B1 + +# 2. Start initial backup +az cloudhsm backup start \ + --resource-group myResourceGroup \ + --cluster-name myCloudHSM \ + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" +``` + +### Scenario 2: Disaster Recovery +```bash +# 1. Create new CloudHSM cluster +az cloudhsm create \ + --resource-group myDRResourceGroup \ + --name myDRCloudHSM \ + --location westus2 \ + --sku Standard_B1 + +# 2. Restore from backup +az cloudhsm restore start \ + --resource-group myDRResourceGroup \ + --cluster-name myDRCloudHSM \ + --backup-id your-backup-id \ + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" +``` + +## Best Practices + +1. **Regular backups** to protect against data loss +2. **Monitor operations** to track the status of long-running operations +3. **Tag resources** for better organization and cost management +4. **Store backups** in geo-redundant storage for disaster recovery + +## Additional Resources + +- [Azure CloudHSM Documentation](https://docs.microsoft.com/azure/cloud-hsm) +- [Azure CLI Documentation](https://docs.microsoft.com/cli/azure/) +- [Azure Storage Documentation](https://docs.microsoft.com/azure/storage/) \ No newline at end of file diff --git a/src/cloudhsm/azext_cloudhsm/__init__.py b/src/cloudhsm/azext_cloudhsm/__init__.py new file mode 100644 index 00000000000..3167d873dd1 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_cloudhsm._help import helps # pylint: disable=unused-import + + +class CloudhsmCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_cloudhsm.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_cloudhsm.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_cloudhsm._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = CloudhsmCommandsLoader diff --git a/src/cloudhsm/azext_cloudhsm/_help.py b/src/cloudhsm/azext_cloudhsm/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/cloudhsm/azext_cloudhsm/_params.py b/src/cloudhsm/azext_cloudhsm/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/cloudhsm/azext_cloudhsm/aaz/__init__.py b/src/cloudhsm/azext_cloudhsm/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/__init__.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__cmd_group.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__cmd_group.py new file mode 100644 index 00000000000..2bca925d6b4 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "cloudhsm", +) +class __CMDGroup(AAZCommandGroup): + """Manage Cloud Hsm Cluster + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__init__.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_create.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_create.py new file mode 100644 index 00000000000..353f718fb7b --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_create.py @@ -0,0 +1,487 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm create", +) +class Create(AAZCommand): + """Create a Cloud HSM + + :example: Create Cloud HSM with user assigned managed identity + az cloudhsm create --resource-group rgcloudhsm --name chsm1 --location eastus2 --sku Standard_B1 --tags Department=Accounting --domain-name-label-scope "TenantReuse" --mi-user-assigned /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgcloudhsm /providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}", "2025-03-31"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Body", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Body", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Identity" + + _args_schema = cls._args_schema + _args_schema.mi_user_assigned = AAZListArg( + options=["--mi-user-assigned"], + arg_group="Identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.domain_name_label_scope = AAZStrArg( + options=["--domain-label-scope", "--domain-name-label-scope"], + arg_group="Properties", + help="The Cloud HSM Cluster's auto-generated Domain Name Label Scope", + enum={"NoReuse": "NoReuse", "ResourceGroupReuse": "ResourceGroupReuse", "SubscriptionReuse": "SubscriptionReuse", "TenantReuse": "TenantReuse"}, + ) + + # define Arg Group "Sku" + + _args_schema = cls._args_schema + _args_schema.family = AAZStrArg( + options=["--family"], + arg_group="Sku", + help="Sku family of the Cloud HSM Cluster", + default="B", + enum={"B": "B"}, + ) + _args_schema.sku = AAZStrArg( + options=["--sku"], + arg_group="Sku", + help="Sku name of the Cloud HSM Cluster", + default="Standard_B1", + enum={"Standard B10": "Standard B10", "Standard_B1": "Standard_B1"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CloudHsmClustersCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClustersCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "original-uri"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "original-uri"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("sku", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}}) + + user_assigned = _builder.get(".identity.userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("autoGeneratedDomainNameLabelScope", AAZStrType, ".domain_name_label_scope") + + sku = _builder.get(".sku") + if sku is not None: + sku.set_prop("family", AAZStrType, ".family", typ_kwargs={"flags": {"required": True}}) + sku.set_prop("name", AAZStrType, ".sku", typ_kwargs={"flags": {"required": True}}) + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.sku = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _CreateHelper._build_schema_system_data_read(_schema_on_200_201.system_data) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.activation_state = AAZStrType( + serialized_name="activationState", + flags={"read_only": True}, + ) + properties.auto_generated_domain_name_label_scope = AAZStrType( + serialized_name="autoGeneratedDomainNameLabelScope", + ) + properties.hsms = AAZListType( + flags={"read_only": True}, + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.status_message = AAZStrType( + serialized_name="statusMessage", + flags={"read_only": True}, + ) + + hsms = cls._schema_on_200_201.properties.hsms + hsms.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.hsms.Element + _element.fqdn = AAZStrType() + _element.state = AAZStrType() + _element.state_message = AAZStrType( + serialized_name="stateMessage", + ) + + private_endpoint_connections = cls._schema_on_200_201.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.private_endpoint_connections.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _CreateHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200_201.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + sku = cls._schema_on_200_201.sku + sku.capacity = AAZIntType() + sku.family = AAZStrType( + flags={"required": True}, + ) + sku.name = AAZStrType( + flags={"required": True}, + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Create"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_delete.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_delete.py new file mode 100644 index 00000000000..b1419518c32 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_delete.py @@ -0,0 +1,168 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a Cloud HSM + + :example: Delete a Cloud HSM + az cloudhsm delete --resource-group rgcloudhsm --name chsm1 + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}", "2025-03-31"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CloudHsmClustersDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class CloudHsmClustersDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_list.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_list.py new file mode 100644 index 00000000000..9f31943d5d8 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_list.py @@ -0,0 +1,615 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm list", +) +class List(AAZCommand): + """List Cloud HSMs + + :example: Show all cloud HSMs in the selected subscription + az cloudhsm list + az cloudhsm list --subscription subId + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters", "2025-03-31"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters", "2025-03-31"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.CloudHsmClustersListBySubscription(ctx=self.ctx)() + if condition_1: + self.CloudHsmClustersListByResourceGroup(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class CloudHsmClustersListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.activation_state = AAZStrType( + serialized_name="activationState", + flags={"read_only": True}, + ) + properties.auto_generated_domain_name_label_scope = AAZStrType( + serialized_name="autoGeneratedDomainNameLabelScope", + ) + properties.hsms = AAZListType( + flags={"read_only": True}, + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.status_message = AAZStrType( + serialized_name="statusMessage", + flags={"read_only": True}, + ) + + hsms = cls._schema_on_200.value.Element.properties.hsms + hsms.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.hsms.Element + _element.fqdn = AAZStrType() + _element.state = AAZStrType() + _element.state_message = AAZStrType( + serialized_name="stateMessage", + ) + + private_endpoint_connections = cls._schema_on_200.value.Element.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + sku = cls._schema_on_200.value.Element.sku + sku.capacity = AAZIntType() + sku.family = AAZStrType( + flags={"required": True}, + ) + sku.name = AAZStrType( + flags={"required": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class CloudHsmClustersListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.sku = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.activation_state = AAZStrType( + serialized_name="activationState", + flags={"read_only": True}, + ) + properties.auto_generated_domain_name_label_scope = AAZStrType( + serialized_name="autoGeneratedDomainNameLabelScope", + ) + properties.hsms = AAZListType( + flags={"read_only": True}, + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.status_message = AAZStrType( + serialized_name="statusMessage", + flags={"read_only": True}, + ) + + hsms = cls._schema_on_200.value.Element.properties.hsms + hsms.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.hsms.Element + _element.fqdn = AAZStrType() + _element.state = AAZStrType() + _element.state_message = AAZStrType( + serialized_name="stateMessage", + ) + + private_endpoint_connections = cls._schema_on_200.value.Element.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ListHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.value.Element.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + sku = cls._schema_on_200.value.Element.sku + sku.capacity = AAZIntType() + sku.family = AAZStrType( + flags={"required": True}, + ) + sku.name = AAZStrType( + flags={"required": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["List"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_show.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_show.py new file mode 100644 index 00000000000..fbbc239a5a1 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_show.py @@ -0,0 +1,371 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm show", +) +class Show(AAZCommand): + """Show details of a Cloud HSM + + :example: Show details of a Cloud HSM. + az cloudhsm show --resource-group rgcloudhsm --name chsm1 + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}", "2025-03-31"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CloudHsmClustersGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClustersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ShowHelper._build_schema_system_data_read(_schema_on_200.system_data) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.activation_state = AAZStrType( + serialized_name="activationState", + flags={"read_only": True}, + ) + properties.auto_generated_domain_name_label_scope = AAZStrType( + serialized_name="autoGeneratedDomainNameLabelScope", + ) + properties.hsms = AAZListType( + flags={"read_only": True}, + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.status_message = AAZStrType( + serialized_name="statusMessage", + flags={"read_only": True}, + ) + + hsms = cls._schema_on_200.properties.hsms + hsms.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.hsms.Element + _element.fqdn = AAZStrType() + _element.state = AAZStrType() + _element.state_message = AAZStrType( + serialized_name="stateMessage", + ) + + private_endpoint_connections = cls._schema_on_200.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.private_endpoint_connections.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _ShowHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + sku = cls._schema_on_200.sku + sku.capacity = AAZIntType() + sku.family = AAZStrType( + flags={"required": True}, + ) + sku.name = AAZStrType( + flags={"required": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Show"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_update.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_update.py new file mode 100644 index 00000000000..e0ea13bbbc0 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/_update.py @@ -0,0 +1,440 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm update", +) +class Update(AAZCommand): + """Update the properties of a Cloud HSM + + :example: Update the properties of a Cloud HSM + az cloudhsm update --name chsm1 --resource-group myrg --tags Department=Accounting + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}", "2025-03-31"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Body", + help="The Cloud HSM Cluster's tags", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Identity" + + _args_schema = cls._args_schema + _args_schema.mi_user_assigned = AAZListArg( + options=["--mi-user-assigned"], + arg_group="Identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CloudHsmClustersUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClustersUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}}) + + user_assigned = _builder.get(".identity.userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.sku = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _UpdateHelper._build_schema_system_data_read(_schema_on_200.system_data) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.activation_state = AAZStrType( + serialized_name="activationState", + flags={"read_only": True}, + ) + properties.auto_generated_domain_name_label_scope = AAZStrType( + serialized_name="autoGeneratedDomainNameLabelScope", + ) + properties.hsms = AAZListType( + flags={"read_only": True}, + ) + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + properties.status_message = AAZStrType( + serialized_name="statusMessage", + flags={"read_only": True}, + ) + + hsms = cls._schema_on_200.properties.hsms + hsms.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.hsms.Element + _element.fqdn = AAZStrType() + _element.state = AAZStrType() + _element.state_message = AAZStrType( + serialized_name="stateMessage", + ) + + private_endpoint_connections = cls._schema_on_200.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.private_endpoint_connections.Element + _element.etag = AAZStrType() + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _UpdateHelper._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = cls._schema_on_200.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + sku = cls._schema_on_200.sku + sku.capacity = AAZIntType() + sku.family = AAZStrType( + flags={"required": True}, + ) + sku.name = AAZStrType( + flags={"required": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Update"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__cmd_group.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__cmd_group.py new file mode 100644 index 00000000000..1b2274bcfeb --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "cloudhsm backup", +) +class __CMDGroup(AAZCommandGroup): + """Manage Cloud HSM Backup + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__init__.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__init__.py new file mode 100644 index 00000000000..1a94969d1a6 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._show import * +from ._start import * diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_show.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_show.py new file mode 100644 index 00000000000..44ce23f2a6f --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_show.py @@ -0,0 +1,268 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +class Show(AAZCommand): + """Get the backup operation status of the specified Cloud HSM Cluster + + :example: Get Cloud HSM backup job status + az cloudhsm backup show --resource-group rgcloudhsm --cluster-name chsm1 --job-id 572a45927fc240e1ac075de27371680b + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}/backupoperationstatus/{}", "2025-03-31"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.job_id = AAZStrArg( + options=["--job-id"], + help="The id returned as part of the backup request", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CloudHsmClusterBackupStatusGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClusterBackupStatusGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [202]: + return self.on_202(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backupOperationStatus/{jobId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "jobId", self.ctx.args.job_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.properties + properties.azure_storage_blob_container_uri = AAZStrType( + serialized_name="azureStorageBlobContainerUri", + ) + properties.backup_id = AAZStrType( + serialized_name="backupId", + ) + properties.end_time = AAZStrType( + serialized_name="endTime", + nullable=True, + flags={"read_only": True}, + ) + properties.error = AAZObjectType() + _ShowHelper._build_schema_error_detail_read(properties.error) + properties.job_id = AAZStrType( + serialized_name="jobId", + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_details = AAZStrType( + serialized_name="statusDetails", + ) + + return cls._schema_on_200 + + def on_202(self, session): + pass + + +class _ShowHelper: + """Helper class for Show""" + + _schema_error_detail_read = None + + @classmethod + def _build_schema_error_detail_read(cls, _schema): + if cls._schema_error_detail_read is not None: + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + return + + cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType() + + error_detail_read = _schema_error_detail_read + error_detail_read.additional_info = AAZListType( + serialized_name="additionalInfo", + flags={"read_only": True}, + ) + error_detail_read.code = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.details = AAZListType( + flags={"read_only": True}, + ) + error_detail_read.message = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.target = AAZStrType( + flags={"read_only": True}, + ) + + additional_info = _schema_error_detail_read.additional_info + additional_info.Element = AAZObjectType() + + _element = _schema_error_detail_read.additional_info.Element + _element.info = AAZDictType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + info = _schema_error_detail_read.additional_info.Element.info + info.Element = AAZAnyType() + + details = _schema_error_detail_read.details + details.Element = AAZObjectType() + cls._build_schema_error_detail_read(details.Element) + + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + + +__all__ = ["Show"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_start.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_start.py new file mode 100644 index 00000000000..0954bf23059 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/backup/_start.py @@ -0,0 +1,296 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm backup start", +) +class Start(AAZCommand): + """Begin a backup of the Cloud HSM. + + :example: Start Cloud HSM Backup + az cloudhsm backup start --resource-group rgcloudhsm --cluster-name chsm1 --blob-container-uri "https://cli.blob.core.windows.net/testbackup" + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}/backup", "2025-03-31"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "BackupRequestProperties" + + _args_schema = cls._args_schema + _args_schema.blob_container_uri = AAZStrArg( + options=["--blob-container-uri"], + arg_group="BackupRequestProperties", + help="The Azure blob storage container Uri which contains the backup", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CloudHsmClustersBackup(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClustersBackup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backup", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"client_flatten": True}} + ) + _builder.set_prop("azureStorageBlobContainerUri", AAZStrType, ".blob_container_uri", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + + properties = cls._schema_on_200.properties + properties.azure_storage_blob_container_uri = AAZStrType( + serialized_name="azureStorageBlobContainerUri", + ) + properties.backup_id = AAZStrType( + serialized_name="backupId", + ) + properties.end_time = AAZStrType( + serialized_name="endTime", + nullable=True, + flags={"read_only": True}, + ) + properties.error = AAZObjectType() + _StartHelper._build_schema_error_detail_read(properties.error) + properties.job_id = AAZStrType( + serialized_name="jobId", + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_details = AAZStrType( + serialized_name="statusDetails", + ) + + return cls._schema_on_200 + + +class _StartHelper: + """Helper class for Start""" + + _schema_error_detail_read = None + + @classmethod + def _build_schema_error_detail_read(cls, _schema): + if cls._schema_error_detail_read is not None: + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + return + + cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType() + + error_detail_read = _schema_error_detail_read + error_detail_read.additional_info = AAZListType( + serialized_name="additionalInfo", + flags={"read_only": True}, + ) + error_detail_read.code = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.details = AAZListType( + flags={"read_only": True}, + ) + error_detail_read.message = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.target = AAZStrType( + flags={"read_only": True}, + ) + + additional_info = _schema_error_detail_read.additional_info + additional_info.Element = AAZObjectType() + + _element = _schema_error_detail_read.additional_info.Element + _element.info = AAZDictType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + info = _schema_error_detail_read.additional_info.Element.info + info.Element = AAZAnyType() + + details = _schema_error_detail_read.details + details.Element = AAZObjectType() + cls._build_schema_error_detail_read(details.Element) + + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + + +__all__ = ["Start"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__cmd_group.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__cmd_group.py new file mode 100644 index 00000000000..dd04ad7c716 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "cloudhsm restore", +) +class __CMDGroup(AAZCommandGroup): + """Restore a backup of a Cloud HSM + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__init__.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__init__.py new file mode 100644 index 00000000000..1a94969d1a6 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._show import * +from ._start import * diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_show.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_show.py new file mode 100644 index 00000000000..ef5b08bb980 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_show.py @@ -0,0 +1,260 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +class Show(AAZCommand): + """Get the restore operation status of the specified Cloud HSM Cluster + + :example: Get Cloud HSM restore job status + az cloudhsm restore show --resource-group rgcloudhsm --cluster-name chsm1 --job-id 572a45927fc240e1ac075de27371680b + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}/restoreoperationstatus/{}", "2025-03-31"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.job_id = AAZStrArg( + options=["--job-id"], + help="The id returned as part of the backup request", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.CloudHsmClusterRestoreStatusGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClusterRestoreStatusGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [202]: + return self.on_202(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restoreOperationStatus/{jobId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "jobId", self.ctx.args.job_id, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType() + + properties = cls._schema_on_200.properties + properties.end_time = AAZStrType( + serialized_name="endTime", + nullable=True, + flags={"read_only": True}, + ) + properties.error = AAZObjectType() + _ShowHelper._build_schema_error_detail_read(properties.error) + properties.job_id = AAZStrType( + serialized_name="jobId", + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_details = AAZStrType( + serialized_name="statusDetails", + ) + + return cls._schema_on_200 + + def on_202(self, session): + pass + + +class _ShowHelper: + """Helper class for Show""" + + _schema_error_detail_read = None + + @classmethod + def _build_schema_error_detail_read(cls, _schema): + if cls._schema_error_detail_read is not None: + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + return + + cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType() + + error_detail_read = _schema_error_detail_read + error_detail_read.additional_info = AAZListType( + serialized_name="additionalInfo", + flags={"read_only": True}, + ) + error_detail_read.code = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.details = AAZListType( + flags={"read_only": True}, + ) + error_detail_read.message = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.target = AAZStrType( + flags={"read_only": True}, + ) + + additional_info = _schema_error_detail_read.additional_info + additional_info.Element = AAZObjectType() + + _element = _schema_error_detail_read.additional_info.Element + _element.info = AAZDictType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + info = _schema_error_detail_read.additional_info.Element.info + info.Element = AAZAnyType() + + details = _schema_error_detail_read.details + details.Element = AAZObjectType() + cls._build_schema_error_detail_read(details.Element) + + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + + +__all__ = ["Show"] diff --git a/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_start.py b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_start.py new file mode 100644 index 00000000000..d7f596a49c9 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/restore/_start.py @@ -0,0 +1,296 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "cloudhsm restore start", +) +class Start(AAZCommand): + """Restore a backup of a Cloud HSM. + + :example: Start Cloud HSM Restore + az cloudhsm restore start --resource-group rgcloudhsm --cluster-name chsm1 --backup-id cloudhsm-eb0e0bf9-9d12-4201-b38c-567c8a452dd5-2025052912032456 --blob-container-uri https://myaccount.blob.core.windows.net/sascontainer/sasContainer + """ + + _aaz_info = { + "version": "2025-03-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hardwaresecuritymodules/cloudhsmclusters/{}/restore", "2025-03-31"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,23}$", + max_length=23, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "RestoreRequestProperties" + + _args_schema = cls._args_schema + _args_schema.blob_container_uri = AAZStrArg( + options=["--blob-container-uri"], + arg_group="RestoreRequestProperties", + help="The Azure blob storage container Uri which contains the backup", + required=True, + ) + _args_schema.backup_id = AAZStrArg( + options=["--backup-id"], + arg_group="RestoreRequestProperties", + help="An autogenerated unique string ID for labeling the backup. It contains both a UUID and a date timestamp.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.CloudHsmClustersRestore(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class CloudHsmClustersRestore(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restore", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "cloudHsmClusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-03-31", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("azureStorageBlobContainerUri", AAZStrType, ".blob_container_uri", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("backupId", AAZStrType, ".backup_id", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZObjectType() + + properties = cls._schema_on_200.properties + properties.end_time = AAZStrType( + serialized_name="endTime", + nullable=True, + flags={"read_only": True}, + ) + properties.error = AAZObjectType() + _StartHelper._build_schema_error_detail_read(properties.error) + properties.job_id = AAZStrType( + serialized_name="jobId", + ) + properties.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + properties.status = AAZStrType( + flags={"read_only": True}, + ) + properties.status_details = AAZStrType( + serialized_name="statusDetails", + ) + + return cls._schema_on_200 + + +class _StartHelper: + """Helper class for Start""" + + _schema_error_detail_read = None + + @classmethod + def _build_schema_error_detail_read(cls, _schema): + if cls._schema_error_detail_read is not None: + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + return + + cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType() + + error_detail_read = _schema_error_detail_read + error_detail_read.additional_info = AAZListType( + serialized_name="additionalInfo", + flags={"read_only": True}, + ) + error_detail_read.code = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.details = AAZListType( + flags={"read_only": True}, + ) + error_detail_read.message = AAZStrType( + flags={"read_only": True}, + ) + error_detail_read.target = AAZStrType( + flags={"read_only": True}, + ) + + additional_info = _schema_error_detail_read.additional_info + additional_info.Element = AAZObjectType() + + _element = _schema_error_detail_read.additional_info.Element + _element.info = AAZDictType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + info = _schema_error_detail_read.additional_info.Element.info + info.Element = AAZAnyType() + + details = _schema_error_detail_read.details + details.Element = AAZObjectType() + cls._build_schema_error_detail_read(details.Element) + + _schema.additional_info = cls._schema_error_detail_read.additional_info + _schema.code = cls._schema_error_detail_read.code + _schema.details = cls._schema_error_detail_read.details + _schema.message = cls._schema_error_detail_read.message + _schema.target = cls._schema_error_detail_read.target + + +__all__ = ["Start"] diff --git a/src/cloudhsm/azext_cloudhsm/azext_metadata.json b/src/cloudhsm/azext_cloudhsm/azext_metadata.json new file mode 100644 index 00000000000..e506328978c --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.70.0" +} \ No newline at end of file diff --git a/src/cloudhsm/azext_cloudhsm/commands.py b/src/cloudhsm/azext_cloudhsm/commands.py new file mode 100644 index 00000000000..c1b26e60dd3 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/commands.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + with self.command_group('cloudhsm'): + from .custom import CloudHsmCreate + self.command_table['cloudhsm create'] = CloudHsmCreate(loader=self) + from .custom import CloudHsmBackupStart + self.command_table['cloudhsm backup start'] = CloudHsmBackupStart(loader=self) diff --git a/src/cloudhsm/azext_cloudhsm/custom.py b/src/cloudhsm/azext_cloudhsm/custom.py new file mode 100644 index 00000000000..1f5b34b0d29 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/custom.py @@ -0,0 +1,39 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger +from .aaz.latest.cloudhsm._create import Create as _CloudHsmCreate +from .aaz.latest.cloudhsm.backup._start import Start as _CloudHsmBackupStart +from .aaz.latest.cloudhsm._list import List as _CloudHsmList + +logger = get_logger(__name__) + + +class CloudHsmCreate(_CloudHsmCreate): + @classmethod + # pylint: disable=protected-access + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.family._required = False + args_schema.family._registered = False + return args_schema + + def pre_operations(self): + args = self.ctx.args + args.family = "B" + + +class CloudHsmBackupStart(_CloudHsmBackupStart): + @classmethod + # pylint: disable=protected-access + def _build_arguments_schema(cls, *args, **kwargs): + args_schema_backup = super()._build_arguments_schema(*args, **kwargs) + args_schema_backup.blob_container_uri._required = True + return args_schema_backup diff --git a/src/cloudhsm/azext_cloudhsm/tests/__init__.py b/src/cloudhsm/azext_cloudhsm/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/cloudhsm/azext_cloudhsm/tests/latest/__init__.py b/src/cloudhsm/azext_cloudhsm/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_backup_restore.yaml b/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_backup_restore.yaml new file mode 100644 index 00000000000..18ab8e889fe --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_backup_restore.yaml @@ -0,0 +1,400 @@ +interactions: +- request: + body: '{"azureStorageBlobContainerUri": "https://clitestbackup.blob.core.windows.net/testbackup"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm backup start + Connection: + - keep-alive + Content-Length: + - '90' + Content-Type: + - application/json + ParameterSetName: + - --cluster-name --resource-group --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myhsm/backup?api-version=2025-03-31 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:36:45 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myhsm/backupOperationStatus/08d796457ad74ac6ab5e6cd5f174c5e3?api-version=2025-03-31&t=638854222059573337&c=MIIHhzCCBm-gAwIBAgITHgbGQ8iUUHaIEuL0_AAABsZDyDANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjUwNDE2MDYzMDI5WhcNMjUxMDEzMDYzMDI5WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALopjeABPIHVlbmyblq81grbzeudZmsoIRLfRTuwzpTkJxJawSpyHm_mPoZYvcbSUrkDKmrugxJjL_csgjpVCQyBuvwW1_IPiOq7BO-sz7JA3guM6GF_QasdShJtZS72qSq5X6yOyEF_Pd7OWpeExPPIQ0IJyerd0Z85589w1w9yS8mbsjcs_PDjtqSKr8uTrHX_FmwV5eKNckBpE_SPng9vxBzIqaFE5GyrLJPbMNrXtxo7sdZUNsWFYKWfbLNwUeeiZ_kYc22U-ELyPKA3NyS5ix8yS1l4gf3lJcVpZlv45oeONu2k-K9B9zXK1xUb595R9qKeWxyy6LFC_f2li_ECAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBSNrIXhp-22YSh2t6R5ZI2lOzW7gjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwIwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBACG4sIuYS__ZcEIxL7lGI4gWbCUox1lZgK7Irz_ISerpyasLIKA0keyfO12BHBGBgspW8EkNy_eUMIC3LL_gj2e35FcS3xSZQarNX4O0MfXYT9ewpbBiBN7N2O5UCVetzSkf_ufmZIwg0xFmAJWE2CRP7-nT4Cu_gvFaWN_jOU1ZNI6J6Ij4ex_QduewzlZK1KgGIuQEvvt8EAoR8dBHjwD9e8wWmXlllBAMDF9Fn-7CCcO9LFViByq7e3TiD-xGSeMvTO5glydvGtkUdMezHbLnK75xthbEARHNV0li-D6YSyKHcGumxOBvCy2gUPdWscyU2Ct5FDqy2rgSeB4luwo&s=YG7Zx4Svy-ZVMgblPfkhMHRG4S4j6x1G-k0klP9IflenmxD8YRBanG4QI2zQxZkZOGnHZ3CH6NthlAXmhMWps7g4Hgbx4bS8ypZNeLcdzJLq9_guGFubL7sNGx-mr3Deby1sXq5lhBNADfbecyWZr_raQI8qi7qk0uviq4fA67KskguESJLIIT2SJp7Xfv3Fp2bMYwGgovZJUsKsZ-VEpGqT9-wsuoAdnjDx9zEKEQ_d5CGo6bTUJENyC1vq5nSyFGOGynpYtgRJzyqm0bNkDnKygTyzSeY5bg5ux6RHycfqA3rervze_5eFBkixY7i9w5LaJySG3CnhR8WrpgLt_g&h=xThTjuyF804V00dXsLBkf2is6YdtikuRIA88T25z1EU + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/uksouth/33ffb55c-ff44-4408-86e2-6bf602d7795f + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 98230AE5261D4779897EE052D6FB3A69 Ref B: AMS231032608053 Ref C: 2025-06-13T14:36:45Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm backup start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myhsm/backupOperationStatus/08d796457ad74ac6ab5e6cd5f174c5e3?api-version=2025-03-31&t=638854222059573337&c=MIIHhzCCBm-gAwIBAgITHgbGQ8iUUHaIEuL0_AAABsZDyDANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjUwNDE2MDYzMDI5WhcNMjUxMDEzMDYzMDI5WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALopjeABPIHVlbmyblq81grbzeudZmsoIRLfRTuwzpTkJxJawSpyHm_mPoZYvcbSUrkDKmrugxJjL_csgjpVCQyBuvwW1_IPiOq7BO-sz7JA3guM6GF_QasdShJtZS72qSq5X6yOyEF_Pd7OWpeExPPIQ0IJyerd0Z85589w1w9yS8mbsjcs_PDjtqSKr8uTrHX_FmwV5eKNckBpE_SPng9vxBzIqaFE5GyrLJPbMNrXtxo7sdZUNsWFYKWfbLNwUeeiZ_kYc22U-ELyPKA3NyS5ix8yS1l4gf3lJcVpZlv45oeONu2k-K9B9zXK1xUb595R9qKeWxyy6LFC_f2li_ECAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBSNrIXhp-22YSh2t6R5ZI2lOzW7gjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwIwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBACG4sIuYS__ZcEIxL7lGI4gWbCUox1lZgK7Irz_ISerpyasLIKA0keyfO12BHBGBgspW8EkNy_eUMIC3LL_gj2e35FcS3xSZQarNX4O0MfXYT9ewpbBiBN7N2O5UCVetzSkf_ufmZIwg0xFmAJWE2CRP7-nT4Cu_gvFaWN_jOU1ZNI6J6Ij4ex_QduewzlZK1KgGIuQEvvt8EAoR8dBHjwD9e8wWmXlllBAMDF9Fn-7CCcO9LFViByq7e3TiD-xGSeMvTO5glydvGtkUdMezHbLnK75xthbEARHNV0li-D6YSyKHcGumxOBvCy2gUPdWscyU2Ct5FDqy2rgSeB4luwo&s=YG7Zx4Svy-ZVMgblPfkhMHRG4S4j6x1G-k0klP9IflenmxD8YRBanG4QI2zQxZkZOGnHZ3CH6NthlAXmhMWps7g4Hgbx4bS8ypZNeLcdzJLq9_guGFubL7sNGx-mr3Deby1sXq5lhBNADfbecyWZr_raQI8qi7qk0uviq4fA67KskguESJLIIT2SJp7Xfv3Fp2bMYwGgovZJUsKsZ-VEpGqT9-wsuoAdnjDx9zEKEQ_d5CGo6bTUJENyC1vq5nSyFGOGynpYtgRJzyqm0bNkDnKygTyzSeY5bg5ux6RHycfqA3rervze_5eFBkixY7i9w5LaJySG3CnhR8WrpgLt_g&h=xThTjuyF804V00dXsLBkf2is6YdtikuRIA88T25z1EU + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:36:45 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myhsm/backupOperationStatus/08d796457ad74ac6ab5e6cd5f174c5e3?api-version=2025-03-31 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/uksouth/f78df277-78b0-4b1b-ad80-cf74339f9fff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 755BA9B7C17E4BFA96E828F1C5BD073B Ref B: AMS231032608053 Ref C: 2025-06-13T14:36:46Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm backup start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myhsm/backupOperationStatus/08d796457ad74ac6ab5e6cd5f174c5e3?api-version=2025-03-31 + response: + body: + string: '{"properties":{"backupId":"cloudhsm-0e35c989-c582-4b3c-958d-596e4c4fe133-2025061314364592","azureStorageBlobContainerUri":"https://clitestbackup.blob.core.windows.net/testbackup","status":"Succeeded","statusDetails":"HSM + Backup Time: 6/13/2025 1:40:04 PM +00:00 UTC.","startTime":"2025-06-13T14:36:45Z","endTime":"2025-06-13T14:36:53Z","jobId":"08d796457ad74ac6ab5e6cd5f174c5e3"}}' + headers: + cache-control: + - no-cache + content-length: + - '380' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:37:15 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/uksouth/c29a8f0d-84bc-4de5-995d-822b313d58df + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: B4651FCA8B2D4308B0C97564B2AC620B Ref B: AMS231032608053 Ref C: 2025-06-13T14:37:16Z' + status: + code: 200 + message: OK +- request: + body: '{"azureStorageBlobContainerUri": "https://clitestbackup.blob.core.windows.net/testbackup", + "backupId": "cloudhsm-0e35c989-c582-4b3c-958d-596e4c4fe133-2025061314364592"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm restore start + Connection: + - keep-alive + Content-Length: + - '168' + Content-Type: + - application/json + ParameterSetName: + - --cluster-name --resource-group --backup-id --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restore?api-version=2025-03-31 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:37:16 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31&t=638854222372780323&c=MIIHhzCCBm-gAwIBAgITHgbJ9Ua_A-lev7JKtgAABsn1RjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjUwNDE4MDkyMDA4WhcNMjUxMDE1MDkyMDA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALkPaRzIM3wnlKPfixU4eDyLogL7ScK2nE0HcIj4EKMfVuYIdAcW6DLDMre-kKdC0PwaZsiJJ019xWw7cbzXHA_a_en4vGtDXOP6OTuIfN4GGwT2yVFehPnZ--1h1xCZY93rqHgcETDjwK14IocOdx7qxlURe9ou6ZJJUmS830n10a6342qQlcJHWpYQiZMvA-pawAwOrThsQWUDZz48IgcERJ0zwUi3RQ9QGzxj4GMeQ1LWWqFsIhCjAVAaykUcPRR8VGrEvhS9RA_FpH2RXIzjsK4BTgIstHEAWT64wsvWJGTgju31BHBw2hYbAssz7sFDekthcsBbhcIOYAvKM7UCAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBQJRqAaoeMfNAfqv1anLO8qFB0AkjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwIwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAIfqCntufZ0Jde3JzWkbc55XDCKhfzsiG0Vh7jBfSOufX__EHQyeuaGqwQ-Oh54is5fUNjtjE6kbAm9DPE-iKDm1p-sw2nE69t7JccENX0P8E86VWjLrHB82EQccPnLm_iV1RnXDxsRapWPS5r5KnZdAyBVtSzmuxDq7fTd_ltc9ZMLL_FBoD-Acz-tqfkq9R8CJTLmW0IuVgtj1tHvKDpdCYpRxZf2ghI92CqSMYgWEQYohLjKzYFTHi9ap5TDkIkc5j0Pl1gX8nmEzBX2fVtUnXSasjykHA0a42jpKOVQ7g5sWXVWwmePbx8wxnFd7tfjbDbBRgRiQPye9sg4atPU&s=lU7Ki1EvmcLjGjTwn6Ry67T1ucUlyqdsczgzbmfVR4ALGC36Cn2KYIonrOqgSuQmimz5GZA-bLJ9ea37AMfRpDv8h4sXBNPQFzqmUPc2sH8znUIwuXCbSdre2Pp_ZH00yiV-x9E5BWZvFdNSrL5jVDks5qQlB5N8RlzuVYzO9rSvbjHj0NIaHM3XvUiZ2tGV8Or13GvxUWiM-uP_aAA3hQiiPhPGP3UDC3rRD5jxVuZkw6Syub7TT2G9i80UMRvRWcnXNexrD7EB0yB5suupqLi7tydIztoznKk9D8ddkjekkKNq3WYOllPQB4YsLfWjyL72AZQpnsk7RCh3DVxQog&h=2I5MC694L915mxcXQYNXkpQtPNZ-nfHTxp3nyFVGHvw + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/ukwest/eea4d0e3-704f-4d99-8a6e-6b350adfbfae + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: AD7C2BB49C5C4B699975D6D23BA19946 Ref B: AMS231020512017 Ref C: 2025-06-13T14:37:16Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm restore start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --backup-id --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31&t=638854222372780323&c=MIIHhzCCBm-gAwIBAgITHgbJ9Ua_A-lev7JKtgAABsn1RjANBgkqhkiG9w0BAQsFADBEMRMwEQYKCZImiZPyLGQBGRYDR0JMMRMwEQYKCZImiZPyLGQBGRYDQU1FMRgwFgYDVQQDEw9BTUUgSW5mcmEgQ0EgMDYwHhcNMjUwNDE4MDkyMDA4WhcNMjUxMDE1MDkyMDA4WjBAMT4wPAYDVQQDEzVhc3luY29wZXJhdGlvbnNpZ25pbmdjZXJ0aWZpY2F0ZS5tYW5hZ2VtZW50LmF6dXJlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALkPaRzIM3wnlKPfixU4eDyLogL7ScK2nE0HcIj4EKMfVuYIdAcW6DLDMre-kKdC0PwaZsiJJ019xWw7cbzXHA_a_en4vGtDXOP6OTuIfN4GGwT2yVFehPnZ--1h1xCZY93rqHgcETDjwK14IocOdx7qxlURe9ou6ZJJUmS830n10a6342qQlcJHWpYQiZMvA-pawAwOrThsQWUDZz48IgcERJ0zwUi3RQ9QGzxj4GMeQ1LWWqFsIhCjAVAaykUcPRR8VGrEvhS9RA_FpH2RXIzjsK4BTgIstHEAWT64wsvWJGTgju31BHBw2hYbAssz7sFDekthcsBbhcIOYAvKM7UCAwEAAaOCBHQwggRwMCcGCSsGAQQBgjcVCgQaMBgwCgYIKwYBBQUHAwEwCgYIKwYBBQUHAwIwPQYJKwYBBAGCNxUHBDAwLgYmKwYBBAGCNxUIhpDjDYTVtHiE8Ys-hZvdFs6dEoFghfmRS4WsmTQCAWQCAQcwggHLBggrBgEFBQcBAQSCAb0wggG5MGMGCCsGAQUFBzAChldodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpaW5mcmEvQ2VydHMvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmwxLmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MFMGCCsGAQUFBzAChkdodHRwOi8vY3JsMi5hbWUuZ2JsL2FpYS9CTDJQS0lJTlRDQTAyLkFNRS5HQkxfQU1FJTIwSW5mcmElMjBDQSUyMDA2LmNydDBTBggrBgEFBQcwAoZHaHR0cDovL2NybDMuYW1lLmdibC9haWEvQkwyUEtJSU5UQ0EwMi5BTUUuR0JMX0FNRSUyMEluZnJhJTIwQ0ElMjAwNi5jcnQwUwYIKwYBBQUHMAKGR2h0dHA6Ly9jcmw0LmFtZS5nYmwvYWlhL0JMMlBLSUlOVENBMDIuQU1FLkdCTF9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3J0MB0GA1UdDgQWBBQJRqAaoeMfNAfqv1anLO8qFB0AkjAOBgNVHQ8BAf8EBAMCBaAwggEmBgNVHR8EggEdMIIBGTCCARWgggERoIIBDYY_aHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraWluZnJhL0NSTC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMS5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMi5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsMy5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JshjFodHRwOi8vY3JsNC5hbWUuZ2JsL2NybC9BTUUlMjBJbmZyYSUyMENBJTIwMDYuY3JsMIGdBgNVHSAEgZUwgZIwDAYKKwYBBAGCN3sBATBmBgorBgEEAYI3ewICMFgwVgYIKwYBBQUHAgIwSh5IADMAMwBlADAAMQA5ADIAMQAtADQAZAA2ADQALQA0AGYAOABjAC0AYQAwADUANQAtADUAYgBkAGEAZgBmAGQANQBlADMAMwBkMAwGCisGAQQBgjd7AwIwDAYKKwYBBAGCN3sEAjAfBgNVHSMEGDAWgBTxRmjG8cPwKy19i2rhsvm-NfzRQTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAIfqCntufZ0Jde3JzWkbc55XDCKhfzsiG0Vh7jBfSOufX__EHQyeuaGqwQ-Oh54is5fUNjtjE6kbAm9DPE-iKDm1p-sw2nE69t7JccENX0P8E86VWjLrHB82EQccPnLm_iV1RnXDxsRapWPS5r5KnZdAyBVtSzmuxDq7fTd_ltc9ZMLL_FBoD-Acz-tqfkq9R8CJTLmW0IuVgtj1tHvKDpdCYpRxZf2ghI92CqSMYgWEQYohLjKzYFTHi9ap5TDkIkc5j0Pl1gX8nmEzBX2fVtUnXSasjykHA0a42jpKOVQ7g5sWXVWwmePbx8wxnFd7tfjbDbBRgRiQPye9sg4atPU&s=lU7Ki1EvmcLjGjTwn6Ry67T1ucUlyqdsczgzbmfVR4ALGC36Cn2KYIonrOqgSuQmimz5GZA-bLJ9ea37AMfRpDv8h4sXBNPQFzqmUPc2sH8znUIwuXCbSdre2Pp_ZH00yiV-x9E5BWZvFdNSrL5jVDks5qQlB5N8RlzuVYzO9rSvbjHj0NIaHM3XvUiZ2tGV8Or13GvxUWiM-uP_aAA3hQiiPhPGP3UDC3rRD5jxVuZkw6Syub7TT2G9i80UMRvRWcnXNexrD7EB0yB5suupqLi7tydIztoznKk9D8ddkjekkKNq3WYOllPQB4YsLfWjyL72AZQpnsk7RCh3DVxQog&h=2I5MC694L915mxcXQYNXkpQtPNZ-nfHTxp3nyFVGHvw + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:37:16 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/ukwest/41d3a875-c2b2-4422-a117-cb0628a1b0ff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 1A8079ED71AC411387AB93A4420980F3 Ref B: AMS231020512017 Ref C: 2025-06-13T14:37:17Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm restore start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --backup-id --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:37:46 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/ukwest/c1f1a42a-635f-44a2-a240-cbcef0916251 + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: D8A59E5CD80344A79C876AA73C125757 Ref B: AMS231020512017 Ref C: 2025-06-13T14:37:47Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm restore start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --backup-id --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 13 Jun 2025 14:38:16 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/ukwest/341a7bc2-0500-445f-8752-70bac7776007 + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 3D59072B5F8648059E8040AF8D11DDD6 Ref B: AMS231020512017 Ref C: 2025-06-13T14:38:17Z' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm restore start + Connection: + - keep-alive + ParameterSetName: + - --cluster-name --resource-group --backup-id --blob-container-uri + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/myrestoredhsm/restoreOperationStatus/42262de4b9274eaba4f4caffca53a76c?api-version=2025-03-31 + response: + body: + string: '{"properties":{"status":"Succeeded","startTime":"2025-06-13T14:37:17Z","endTime":"2025-06-13T14:38:47.4153878Z","jobId":"42262de4b9274eaba4f4caffca53a76c"}}' + headers: + cache-control: + - no-cache + content-length: + - '156' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:38:47 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/ukwest/65564eba-00fb-4051-a5cc-36984fbbba54 + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: BEF046EFAAD24139AC23B917A7B731B1 Ref B: AMS231020512017 Ref C: 2025-06-13T14:38:47Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_create_list_and_get_cloudHsm.yaml b/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_create_list_and_get_cloudHsm.yaml new file mode 100644 index 00000000000..7c97e38577d --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/tests/latest/recordings/test_create_list_and_get_cloudHsm.yaml @@ -0,0 +1,304 @@ +interactions: +- request: + body: '{"identity": {"userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity": + {}}, "type": "UserAssigned"}, "location": "ukwest", "properties": {"autoGeneratedDomainNameLabelScope": + "TenantReuse"}, "sku": {"family": "B", "name": "Standard_B1"}, "tags": {"UseMockHfc": + "True", "MockHfcDelayInMs": "1"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm create + Connection: + - keep-alive + Content-Length: + - '420' + Content-Type: + - application/json + ParameterSetName: + - --name --resource-group --location --tags --domain-name-label-scope --mi-user-assigned + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002?api-version=2025-03-31 + response: + body: + string: '{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Provisioning","statusMessage":null,"autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotDefined","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"UseMockHfc":"True","MockHfcDelayInMs":"1"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:36:47.2482008Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1054' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:36:48 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/uksouth/a6f2e6e0-be53-4c0e-a922-d24878486bcf + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 12A4E1BE851841DF8EBF08669DB86553 Ref B: AMS231022012023 Ref C: 2025-06-13T14:36:46Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --location --tags --domain-name-label-scope --mi-user-assigned + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002?api-version=2025-03-31 + response: + body: + string: '{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Provisioning","statusMessage":null,"autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotDefined","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"UseMockHfc":"True","MockHfcDelayInMs":"1"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:36:47.2482008Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1054' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:36:48 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: BF0DF38C3C704BB4A60CC0925038C0FD Ref B: AMS231022012023 Ref C: 2025-06-13T14:36:49Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --location --tags --domain-name-label-scope --mi-user-assigned + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002?api-version=2025-03-31 + response: + body: + string: '{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Succeeded","statusMessage":"HSM + cluster provisioning successful.","autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotActivated","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"UseMockHfc":"True","MockHfcDelayInMs":"1"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:36:47.2482008Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1087' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:37:18 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: E675D5BD44394FF8A3BF070CFB044549 Ref B: AMS231022012023 Ref C: 2025-06-13T14:37:19Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm list + Connection: + - keep-alive + ParameterSetName: + - --resource-group + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters?api-version=2025-03-31 + response: + body: + string: '{"value":[{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Succeeded","statusMessage":"HSM + cluster provisioning successful.","autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotActivated","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"UseMockHfc":"True","MockHfcDelayInMs":"1"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:36:47.2482008Z"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '1099' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:37:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - 97ca5622-d914-42f1-ba5c-2d14ac0fe372 + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 02142FCE3F534D5E9A1CE3426474CB5C Ref B: AMS231032608051 Ref C: 2025-06-13T14:37:20Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm show + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002?api-version=2025-03-31 + response: + body: + string: '{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Succeeded","statusMessage":"HSM + cluster provisioning successful.","autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotActivated","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"UseMockHfc":"True","MockHfcDelayInMs":"1"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:36:47.2482008Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1087' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:37:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 8774E6AF78F94287970700921F8FB4CD Ref B: AMS231020512035 Ref C: 2025-06-13T14:37:20Z' + status: + code: 200 + message: OK +- request: + body: '{"tags": {"UseMockHfc": "true", "MockHfcDelayInMs": "1", "UpdatedResource": + "yes"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - cloudhsm update + Connection: + - keep-alive + Content-Length: + - '83' + Content-Type: + - application/json + ParameterSetName: + - --name --resource-group --tags + User-Agent: + - AZURECLI/2.74.0 azsdk-python-core/1.31.0 Python/3.12.10 (Linux-6.8.0-1027-azure-x86_64-with-glibc2.36) + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002?api-version=2025-03-31 + response: + body: + string: '{"name":"cli000002","type":"Microsoft.HardwareSecurityModules/cloudHsmClusters","location":"ukwest","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli000001/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cli000002","sku":{"family":"B","name":"Standard_B1"},"properties":{"provisioningState":"Succeeded","statusMessage":"HSM + cluster provisioning successful.","autoGeneratedDomainNameLabelScope":"TenantReuse","activationState":"NotActivated","hsms":[],"privateEndpointConnections":[],"publicNetworkAccess":"Disabled"},"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity":{"principalId":null,"clientId":null}}},"tags":{"MockHfcDelayInMs":"1","UpdatedResource":"yes","UseMockHfc":"True"},"systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-06-13T14:36:47.2482008Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-06-13T14:37:21.364448Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '1110' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 13 Jun 2025 14:37:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=8a7348a2-6b25-4382-8b23-151e1a3ae586/uksouth/d534f548-fe03-47cf-9fb4-79973719c2ef + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 2C153BD5CCCC44AD860D6A6AD3AACD4B Ref B: AMS231020614051 Ref C: 2025-06-13T14:37:20Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/cloudhsm/azext_cloudhsm/tests/latest/test_cloudhsm.py b/src/cloudhsm/azext_cloudhsm/tests/latest/test_cloudhsm.py new file mode 100644 index 00000000000..d96100ffd29 --- /dev/null +++ b/src/cloudhsm/azext_cloudhsm/tests/latest/test_cloudhsm.py @@ -0,0 +1,79 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from builtins import len, print +from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer +import operator as op + +class CloudhsmScenario(ScenarioTest): + # TODO: add tests here + @ResourceGroupPreparer(name_prefix='cli', location='ukwest', parameter_name = 'group_name') + def test_create_list_and_get_cloudHsm(self, group_name): + chsm_name = self.create_random_name(prefix='cli', length=8) + self.kwargs.update({ + "chsm_name":chsm_name, + "gr_name": group_name + }) + + #Create + cloud_hsm = self.cmd('az cloudhsm create --name {chsm_name} --resource-group {gr_name} --location ukwest --tags UseMockHfc=True MockHfcDelayInMs=1 --domain-name-label-scope "TenantReuse" --mi-user-assigned /subscriptions/75e96d09-a291-40e1-a5e6-cda78233d867/resourceGroups/cli-test/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cli-test-identity').get_output_in_json() + assert cloud_hsm['name'] == chsm_name + assert cloud_hsm['location'] == "ukwest" + assert cloud_hsm['provisioningState'] == "Succeeded" + assert cloud_hsm['sku']['name'] == "Standard_B1" + assert len(cloud_hsm['tags']) ==2 + + #List --resource-group + cloud_hsm = self.cmd('az cloudhsm list --resource-group {gr_name}').get_output_in_json() + assert cloud_hsm[0]['name'] == chsm_name + assert cloud_hsm[0]['location'] == "ukwest" + assert cloud_hsm[0]['provisioningState'] == "Succeeded" + assert cloud_hsm[0]['sku']['name'] == "Standard_B1" + assert len(cloud_hsm[0]['tags']) ==2 + + #List -- cannot be tested because we have multiple resources in the sub and cannot acticipate the result. + # cloud_hsm = self.cmd('az cloudhsm list').get_output_in_json() + # print('emmeleia', cloud_hsm) + # assert cloud_hsm[0]['name'] == chsm_name + # assert cloud_hsm[0]['location'] == "ukwest" + # assert cloud_hsm[0]['provisioningState'] == "Succeeded" + # assert cloud_hsm[0]['sku']['name'] == "Standard_B1" + # assert len(cloud_hsm[0]['tags']) ==2 + + #Show --name --resource_group + cloud_hsm = self.cmd('az cloudhsm show --name {chsm_name} --resource-group {gr_name}').get_output_in_json() + assert cloud_hsm['name'] == chsm_name + assert cloud_hsm['location'] == "ukwest" + assert cloud_hsm['provisioningState'] == "Succeeded" + assert cloud_hsm['sku']['name'] == "Standard_B1" + assert len(cloud_hsm['tags']) ==2 + + #Update --tags + cloud_hsm = self.cmd('az cloudhsm update --name {chsm_name} --resource-group {gr_name} --tags UseMockHfc=true MockHfcDelayInMs=1 UpdatedResource=yes').get_output_in_json() + assert cloud_hsm['name'] == chsm_name + assert cloud_hsm['location'] == "ukwest" + assert cloud_hsm['provisioningState'] == "Succeeded" + assert cloud_hsm['sku']['name'] == "Standard_B1" + assert len(cloud_hsm['tags']) ==3 + + def test_backup_restore(self): + #Backup + # We cannot do it on a random generated chsm becuase the device must be activate before we can run this command + # Will run this tests locally, generate the recordings and comment out the test case. + cloud_hsm_backup = self.cmd('az cloudhsm backup start --cluster-name myhsm --resource-group cli-test --blob-container-uri https://clitestbackup.blob.core.windows.net/testbackup ').get_output_in_json() + + + assert op.contains(cloud_hsm_backup['backupId'], "cloudhsm-") + assert cloud_hsm_backup['jobId'] != "" + assert cloud_hsm_backup['status'] == "Succeeded" + backup_id = cloud_hsm_backup['backupId'] + + self.kwargs.update({ + "backup_id":backup_id, + }) + + cloud_hsm_restore = self.cmd('az cloudhsm restore start --cluster-name myrestoredhsm --resource-group cli-test --backup-id {backup_id} --blob-container-uri https://clitestbackup.blob.core.windows.net/testbackup').get_output_in_json() diff --git a/src/cloudhsm/setup.cfg b/src/cloudhsm/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/cloudhsm/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/cloudhsm/setup.py b/src/cloudhsm/setup.py new file mode 100644 index 00000000000..29ae11af313 --- /dev/null +++ b/src/cloudhsm/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='cloudhsm', + version=VERSION, + description='Microsoft Azure Command-Line Tools Cloudhsm Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/cloudhsm', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_cloudhsm': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +) diff --git a/src/service_name.json b/src/service_name.json index 05f6ff64d62..53bbd03ac49 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -99,6 +99,11 @@ "AzureServiceName": "Cloud Services (extended support)", "URL": "https://learn.microsoft.com/azure/cloud-services-extended-support" }, + { + "Command": "az cloudhsm", + "AzureServiceName": "Azure Cloud HSM", + "URL": "https://learn.microsoft.com/en-us/azure/cloud-hsm" + }, { "Command": "az communication", "AzureServiceName": "Communication Services",