From fd0a2c76f40b0e4c6c6acde4c0a3dcecef148fb6 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 1 Aug 2025 10:11:43 +1000 Subject: [PATCH 01/24] new resource azurerm_cloud_hardware_security_module_cluster --- internal/provider/services.go | 1 + internal/services/hsm/client/client.go | 13 +- ...rdware_security_module_cluster_resource.go | 466 ++++++++++++++++++ ...e_security_module_cluster_resource_test.go | 330 +++++++++++++ .../cloud_hsm_cluster_state_poller.go | 73 +++ internal/services/hsm/registration.go | 13 + ...ud_hardware_security_module_name_valite.go | 29 ++ .../2025-03-31/cloudhsmclusters/README.md | 234 +++++++++ .../2025-03-31/cloudhsmclusters/client.go | 26 + .../2025-03-31/cloudhsmclusters/constants.go | 424 ++++++++++++++++ .../id_backupoperationstatus.go | 139 ++++++ .../cloudhsmclusters/id_cloudhsmcluster.go | 130 +++++ .../id_restoreoperationstatus.go | 139 ++++++ .../cloudhsmclusters/method_backup.go | 75 +++ .../method_cloudhsmclusterbackupstatusget.go | 54 ++ ...ivatelinkresourceslistbycloudhsmcluster.go | 105 ++++ .../method_cloudhsmclusterrestorestatusget.go | 54 ++ .../cloudhsmclusters/method_createorupdate.go | 75 +++ .../cloudhsmclusters/method_delete.go | 70 +++ .../2025-03-31/cloudhsmclusters/method_get.go | 53 ++ .../method_listbyresourcegroup.go | 106 ++++ .../method_listbysubscription.go | 106 ++++ .../cloudhsmclusters/method_restore.go | 75 +++ .../cloudhsmclusters/method_update.go | 75 +++ .../method_validatebackupproperties.go | 75 +++ .../method_validaterestoreproperties.go | 75 +++ ...model_backuprestorebaseresultproperties.go | 43 ++ ...odel_backuprestorerequestbaseproperties.go | 9 + .../cloudhsmclusters/model_backupresult.go | 8 + .../model_backupresultproperties.go | 45 ++ .../cloudhsmclusters/model_cloudhsmcluster.go | 21 + .../model_cloudhsmclusterpatchparameters.go | 13 + .../model_cloudhsmclusterproperties.go | 14 + .../model_cloudhsmclustersku.go | 10 + .../model_cloudhsmproperties.go | 10 + .../model_erroradditionalinfo.go | 9 + .../cloudhsmclusters/model_errordetail.go | 12 + .../cloudhsmclusters/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 17 + ...del_privateendpointconnectionproperties.go | 11 + .../model_privatelinkresource.go | 16 + .../model_privatelinkresourceproperties.go | 10 + ...model_privatelinkserviceconnectionstate.go | 10 + .../model_restorerequestproperties.go | 10 + .../cloudhsmclusters/model_restoreresult.go | 8 + .../2025-03-31/cloudhsmclusters/predicates.go | 55 +++ .../2025-03-31/cloudhsmclusters/version.go | 10 + vendor/modules.txt | 1 + ...ware_security_module_cluster.html.markdown | 129 +++++ 49 files changed, 3492 insertions(+), 2 deletions(-) create mode 100644 internal/services/hsm/cloud_hardware_security_module_cluster_resource.go create mode 100644 internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go create mode 100644 internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go create mode 100644 internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_backupoperationstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_cloudhsmcluster.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_restoreoperationstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_backup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterbackupstatusget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterrestorestatusget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbysubscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_restore.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validatebackupproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validaterestoreproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorebaseresultproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorerequestbaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresultproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmcluster.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterpatchparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclustersku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_erroradditionalinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_errordetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnection.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnectionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresourceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkserviceconnectionstate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restorerequestproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restoreresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/version.go create mode 100644 website/docs/r/cloud_hardware_security_module_cluster.html.markdown diff --git a/internal/provider/services.go b/internal/provider/services.go index 142d47c2f0e5..efb5d48023d8 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -181,6 +181,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { fluidrelay.Registration{}, graphservices.Registration{}, hybridcompute.Registration{}, + hsm.Registration{}, iotcentral.Registration{}, iothub.Registration{}, keyvault.Registration{}, diff --git a/internal/services/hsm/client/client.go b/internal/services/hsm/client/client.go index 823894019048..d20b4d56682e 100644 --- a/internal/services/hsm/client/client.go +++ b/internal/services/hsm/client/client.go @@ -7,14 +7,22 @@ import ( "fmt" "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2021-11-30/dedicatedhsms" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - DedicatedHsmClient *dedicatedhsms.DedicatedHsmsClient + CloudHsmClustersClient *cloudhsmclusters.CloudHsmClustersClient + DedicatedHsmClient *dedicatedhsms.DedicatedHsmsClient } func NewClient(o *common.ClientOptions) (*Client, error) { + cloudHsmClustersClient, err := cloudhsmclusters.NewCloudHsmClustersClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building CloudHsmClusters client: %+v", err) + } + o.Configure(cloudHsmClustersClient.Client, o.Authorizers.ResourceManager) + dedicatedHsmClient, err := dedicatedhsms.NewDedicatedHsmsClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building DedicatedHsms client: %+v", err) @@ -22,6 +30,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { o.Configure(dedicatedHsmClient.Client, o.Authorizers.ResourceManager) return &Client{ - DedicatedHsmClient: dedicatedHsmClient, + CloudHsmClustersClient: cloudHsmClustersClient, + DedicatedHsmClient: dedicatedHsmClient, }, nil } diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go new file mode 100644 index 000000000000..9ae246fee658 --- /dev/null +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -0,0 +1,466 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package hsm + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/hsm/custompollers" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/hsm/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +// Resource Model +type CloudHardwareSecurityModuleClusterModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Identity []identity.ModelUserAssigned `tfschema:"identity"` + AutoGeneratedDomainNameLabelScope string `tfschema:"auto_generated_domain_name_label_scope"` + Tags map[string]interface{} `tfschema:"tags"` + + // Computed + ActivationState string `tfschema:"activation_state"` + Hsms []CloudHsmPropertiesModel `tfschema:"hsms"` + PrivateEndpointConnections []PrivateEndpointConnectionModel `tfschema:"private_endpoint_connections"` + StatusMessage string `tfschema:"status_message"` +} + +type CloudHsmPropertiesModel struct { + Fqdn string `tfschema:"fqdn"` + State string `tfschema:"state"` + StateMessage string `tfschema:"state_message"` +} + +type PrivateEndpointConnectionModel struct { + Id string `tfschema:"id"` + Name string `tfschema:"name"` + Type string `tfschema:"type"` + GroupIds []string `tfschema:"group_ids"` + PrivateEndpoint []PrivateEndpointModel `tfschema:"private_endpoint"` + PrivateLinkServiceConnectionState []PrivateLinkServiceConnectionStateModel `tfschema:"private_link_service_connection_state"` +} + +type PrivateEndpointModel struct { + Id string `tfschema:"id"` +} + +type PrivateLinkServiceConnectionStateModel struct { + Status string `tfschema:"status"` + Description string `tfschema:"description"` + ActionsRequired string `tfschema:"actions_required"` +} + +var _ sdk.ResourceWithUpdate = CloudHardwareSecurityModuleClusterResource{} + +type CloudHardwareSecurityModuleClusterResource struct{} + +func (CloudHardwareSecurityModuleClusterResource) ResourceType() string { + return "azurerm_cloud_hardware_security_module_cluster" +} + +func (CloudHardwareSecurityModuleClusterResource) ModelObject() interface{} { + return &CloudHardwareSecurityModuleClusterModel{} +} + +func (CloudHardwareSecurityModuleClusterResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return cloudhsmclusters.ValidateCloudHsmClusterID +} + +func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.ValidateCloudHsmClusterName, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + // only user assigned identity is supported even though the swagger shows system assigned identity + "identity": commonschema.UserAssignedIdentityOptional(), + + "auto_generated_domain_name_label_scope": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(cloudhsmclusters.AutoGeneratedDomainNameLabelScopeTenantReuse), + ValidateFunc: validation.StringInSlice(cloudhsmclusters.PossibleValuesForAutoGeneratedDomainNameLabelScope(), false), + }, + + "tags": commonschema.Tags(), + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "activation_state": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "hsms": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "fqdn": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "state": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "state_message": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "private_endpoint_connections": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "group_ids": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + "private_endpoint": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + "private_link_service_connection_state": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "status": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "description": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "actions_required": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + + "status_message": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.HSM.CloudHsmClustersClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var model CloudHardwareSecurityModuleClusterModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + id := cloudhsmclusters.NewCloudHsmClusterID(subscriptionId, model.ResourceGroupName, model.Name) + + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + parameters := cloudhsmclusters.CloudHsmCluster{ + Location: location.Normalize(model.Location), + Tags: tags.Expand(model.Tags), + Sku: &cloudhsmclusters.CloudHsmClusterSku{ + Name: cloudhsmclusters.CloudHsmClusterSkuNameStandardBOne, + Family: cloudhsmclusters.CloudHsmClusterSkuFamilyB, + // Capacity is left unset + }, + } + + if len(model.Identity) > 0 { + expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + // Convert to LegacySystemAndUserAssignedMap since the SDK uses the legacy type + legacyIdentity := &identity.LegacySystemAndUserAssignedMap{ + Type: identity.TypeUserAssigned, + IdentityIds: expandedIdentity.IdentityIds, + } + parameters.Identity = legacyIdentity + } + + if model.AutoGeneratedDomainNameLabelScope != "" { + parameters.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ + AutoGeneratedDomainNameLabelScope: pointer.To(cloudhsmclusters.AutoGeneratedDomainNameLabelScope(model.AutoGeneratedDomainNameLabelScope)), + } + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.HSM.CloudHsmClustersClient + + id, err := cloudhsmclusters.ParseCloudHsmClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + model := CloudHardwareSecurityModuleClusterModel{ + Name: id.CloudHsmClusterName, + ResourceGroupName: id.ResourceGroupName, + } + + if m := resp.Model; m != nil { + model.Location = location.Normalize(m.Location) + model.Tags = tags.Flatten(m.Tags) + + if m.Identity != nil { + // only User Assigned Identity is supported + flattenedIdentity, err := identity.FlattenUserAssignedMapToModel(&identity.UserAssignedMap{ + Type: m.Identity.Type, + IdentityIds: m.Identity.IdentityIds, + }) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + model.Identity = *flattenedIdentity + } + + if props := m.Properties; props != nil { + if props.ActivationState != nil { + model.ActivationState = string(*props.ActivationState) + } + + if props.AutoGeneratedDomainNameLabelScope != nil { + model.AutoGeneratedDomainNameLabelScope = string(*props.AutoGeneratedDomainNameLabelScope) + } + + if props.StatusMessage != nil { + model.StatusMessage = *props.StatusMessage + } + + if props.Hsms != nil { + hsms := make([]CloudHsmPropertiesModel, 0) + for _, hsm := range *props.Hsms { + hsmModel := CloudHsmPropertiesModel{} + if hsm.Fqdn != nil { + hsmModel.Fqdn = *hsm.Fqdn + } + if hsm.State != nil { + hsmModel.State = string(*hsm.State) + } + if hsm.StateMessage != nil { + hsmModel.StateMessage = *hsm.StateMessage + } + hsms = append(hsms, hsmModel) + } + model.Hsms = hsms + } + + if props.PrivateEndpointConnections != nil { + model.PrivateEndpointConnections = flattenPrivateEndpointConnections(props.PrivateEndpointConnections) + } + } + } + + return metadata.Encode(&model) + }, + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.HSM.CloudHsmClustersClient + + id, err := cloudhsmclusters.ParseCloudHsmClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model CloudHardwareSecurityModuleClusterModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + update := cloudhsmclusters.CloudHsmClusterPatchParameters{} + + if metadata.ResourceData.HasChange("identity") { + expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + // Convert to LegacySystemAndUserAssignedMap since the SDK uses the legacy type + legacyIdentity := &identity.LegacySystemAndUserAssignedMap{ + Type: identity.TypeUserAssigned, + IdentityIds: expandedIdentity.IdentityIds, + } + update.Identity = legacyIdentity + } + + if metadata.ResourceData.HasChange("tags") { + update.Tags = tags.Expand(model.Tags) + } + + // Initiate the update operation + err = client.UpdateThenPoll(ctx, *id, update) + if err != nil { + return fmt.Errorf("initiating update for %s: %+v", *id, err) + } + + // Use custom poller to wait for provisioning to complete + // https://github.com/Azure/azure-rest-api-specs/issues/36393 + poller := custompollers.NewCloudHsmClusterStatePoller(client, *id) + pollerType := pollers.NewPoller(poller, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := pollerType.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for update of %s to complete: %+v", *id, err) + } + + return nil + }, + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.HSM.CloudHsmClustersClient + + id, err := cloudhsmclusters.ParseCloudHsmClusterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func flattenPrivateEndpointConnections(connections *[]cloudhsmclusters.PrivateEndpointConnection) []PrivateEndpointConnectionModel { + if connections == nil { + return []PrivateEndpointConnectionModel{} + } + + result := make([]PrivateEndpointConnectionModel, 0) + for _, conn := range *connections { + connModel := PrivateEndpointConnectionModel{} + if conn.Id != nil { + connModel.Id = *conn.Id + } + if conn.Name != nil { + connModel.Name = *conn.Name + } + if conn.Type != nil { + connModel.Type = *conn.Type + } + if conn.Properties != nil { + if conn.Properties.GroupIds != nil { + connModel.GroupIds = *conn.Properties.GroupIds + } + if conn.Properties.PrivateEndpoint != nil { + connModel.PrivateEndpoint = []PrivateEndpointModel{ + { + Id: pointer.From(conn.Properties.PrivateEndpoint.Id), + }, + } + } + if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { + connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ + { + Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), + Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), + ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), + }, + } + } + } + result = append(result, connModel) + } + return result +} diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go new file mode 100644 index 000000000000..fe0fe16aee63 --- /dev/null +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -0,0 +1,330 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package hsm_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type CloudHardwareSecurityModuleClusterResource struct{} + +func TestAccCloudHardwareSecurityModuleCluster_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + // t.Skip(r.basic(data)) + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccCloudHardwareSecurityModuleCluster_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccCloudHardwareSecurityModuleCluster_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("auto_generated_domain_name_label_scope").HasValue("TenantReuse"), + check.That(data.ResourceName).Key("identity.0.type").HasValue("UserAssigned"), + check.That(data.ResourceName).Key("tags.environment").HasValue("test"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccCloudHardwareSecurityModuleCluster_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("tags.environment").HasValue("updated"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccCloudHardwareSecurityModuleCluster_userAssignedIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.userAssignedIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("identity.0.type").HasValue("UserAssigned"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccCloudHardwareSecurityModuleCluster_privateEndpoint(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") + r := CloudHardwareSecurityModuleClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.privateEndpoint(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("private_endpoint_connections.#").Exists(), + ), + }, + data.ImportStep(), + { + // need another apply to read the private endpoint connection + Config: r.privateEndpoint(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("private_endpoint_connections.#").Exists(), + check.That(data.ResourceName).Key("private_endpoint_connections.0.id").Exists(), + check.That(data.ResourceName).Key("private_endpoint_connections.0.name").Exists(), + check.That(data.ResourceName).Key("private_endpoint_connections.0.type").Exists(), + check.That(data.ResourceName).Key("private_endpoint_connections.0.group_ids.#").HasValue("1"), + check.That(data.ResourceName).Key("private_endpoint_connections.0.private_endpoint.0.id").Exists(), + check.That(data.ResourceName).Key("private_endpoint_connections.0.private_link_service_connection_state.0.status").Exists(), + ), + }, + }) +} + +func (CloudHardwareSecurityModuleClusterResource) Exists(ctx context.Context, clientsProvider *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := cloudhsmclusters.ParseCloudHsmClusterID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clientsProvider.HSM.CloudHsmClustersClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + + return utils.Bool(resp.Model != nil), nil +} + +func (r CloudHardwareSecurityModuleClusterResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_cloud_hardware_security_module_cluster" "import" { + name = azurerm_cloud_hardware_security_module_cluster.test.name + resource_group_name = azurerm_cloud_hardware_security_module_cluster.test.resource_group_name + location = azurerm_cloud_hardware_security_module_cluster.test.location +} +`, r.basic(data)) +} + +func (CloudHardwareSecurityModuleClusterResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-cloudhsm-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r CloudHardwareSecurityModuleClusterResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + +} +`, r.template(data), data.RandomString) +} + +func (r CloudHardwareSecurityModuleClusterResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestuai-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } + + auto_generated_domain_name_label_scope = "TenantReuse" + + tags = { + environment = "test" + purpose = "acceptance-testing" + } +} +`, r.template(data), data.RandomString, data.RandomString) +} + +func (r CloudHardwareSecurityModuleClusterResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestuai-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } + + tags = { + environment = "updated" + purpose = "acceptance-testing" + } +} +`, r.template(data), data.RandomString) +} + +func (r CloudHardwareSecurityModuleClusterResource) userAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestuai-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } + +} +`, r.template(data), data.RandomString, data.RandomString) +} + +func (r CloudHardwareSecurityModuleClusterResource) privateEndpoint(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_virtual_network" "test" { + name = "acctest-vnet-%s" + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_subnet" "test" { + name = "acctest-subnet-%s" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.1.0/24"] +} + +resource "azurerm_user_assigned_identity" "test" { + name = "acctesthsm-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } + + auto_generated_domain_name_label_scope = "TenantReuse" + + tags = { + environment = "test" + purpose = "private-endpoint-testing" + } +} + +resource "azurerm_private_endpoint" "test" { + name = "acctest-pe-%s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + subnet_id = azurerm_subnet.test.id + + private_service_connection { + name = "acctest-psc-%s" + private_connection_resource_id = azurerm_cloud_hardware_security_module_cluster.test.id + is_manual_connection = false + subresource_names = ["cloudHsm"] + } +} +`, r.template(data), data.RandomString, data.RandomString, data.RandomString, data.RandomString, data.RandomString, data.RandomString) +} diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go new file mode 100644 index 000000000000..52ee0cfdc5e8 --- /dev/null +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -0,0 +1,73 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package custompollers + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = &CloudHsmClusterStatePoller{} + +// CloudHsmClusterStatePoller polls until the Cloud HSM cluster has finished provisioning +type CloudHsmClusterStatePoller struct { + client *cloudhsmclusters.CloudHsmClustersClient + clusterId cloudhsmclusters.CloudHsmClusterId +} + +func NewCloudHsmClusterStatePoller(hsmClient *cloudhsmclusters.CloudHsmClustersClient, clusterId cloudhsmclusters.CloudHsmClusterId) *CloudHsmClusterStatePoller { + return &CloudHsmClusterStatePoller{ + client: hsmClient, + clusterId: clusterId, + } +} + +func (p *CloudHsmClusterStatePoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + resp, err := p.client.Get(ctx, p.clusterId) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", p.clusterId, err) + } + + statusMessage := "" + if model := resp.Model; model != nil && model.Properties != nil && model.Properties.StatusMessage != nil { + statusMessage = strings.ToLower(strings.TrimSpace(*model.Properties.StatusMessage)) + } + + // Check if provisioning is successful + // HSM cluster update successful or HSM cluster provisioning successful + if statusMessage == "" || strings.Contains(statusMessage, "success") { + return &pollers.PollResult{ + HttpResponse: &client.Response{ + Response: resp.HttpResponse, + }, + Status: pollers.PollingStatusSucceeded, + }, nil + } + + // Check for failure states + if strings.Contains(statusMessage, "failed") || strings.Contains(statusMessage, "error") { + return nil, pollers.PollingFailedError{ + HttpResponse: &client.Response{ + Response: resp.HttpResponse, + }, + Message: fmt.Sprintf("Cloud HSM cluster provisioning failed with status: %s", pointer.From(resp.Model.Properties.StatusMessage)), + } + } + + // If we get here, provisioning is still in progress + return &pollers.PollResult{ + HttpResponse: &client.Response{ + Response: resp.HttpResponse, + }, + PollInterval: 30 * time.Second, + Status: pollers.PollingStatusInProgress, + }, nil +} diff --git a/internal/services/hsm/registration.go b/internal/services/hsm/registration.go index 7ad28a4bb00c..6e2e62bc6eda 100644 --- a/internal/services/hsm/registration.go +++ b/internal/services/hsm/registration.go @@ -11,6 +11,7 @@ import ( type Registration struct{} var _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} +var _ sdk.TypedServiceRegistration = Registration{} func (r Registration) AssociatedGitHubLabel() string { return "service/hsm" @@ -39,3 +40,15 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { "azurerm_dedicated_hardware_security_module": resourceDedicatedHardwareSecurityModule(), } } + +// Resources returns the typed Resources supported by this Service +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + CloudHardwareSecurityModuleClusterResource{}, + } +} + +// DataSources implements sdk.TypedServiceRegistration. +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go b/internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go new file mode 100644 index 000000000000..996b0405321e --- /dev/null +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go @@ -0,0 +1,29 @@ +package validate + +import ( + "fmt" + "regexp" +) + +func ValidateCloudHsmClusterName(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected type of %s to be string", k)) + return + } + + // A Cloud HSM name must be between 3-23 alphanumeric characters. + // The name must begin with a letter or digit, end with a letter or digit, + // and not contain consecutive hyphens + if !regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9-]{1,21}[a-zA-Z0-9]$`).MatchString(v) { + errors = append(errors, fmt.Errorf("%q must be between 3 and 23 alphanumeric characters. It must begin with a letter or digit, end with a letter or digit", k)) + return + } + + // No consecutive hyphens + if regexp.MustCompile("(--)").MatchString(v) { + errors = append(errors, fmt.Errorf("%q must not contain any consecutive hyphens", k)) + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/README.md new file mode 100644 index 000000000000..4453342aee37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/README.md @@ -0,0 +1,234 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters` Documentation + +The `cloudhsmclusters` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" +``` + + +### Client Initialization + +```go +client := cloudhsmclusters.NewCloudHsmClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHsmClustersClient.Backup` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.BackupRestoreRequestBaseProperties{ + // ... +} + + +if err := client.BackupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.CloudHsmClusterBackupStatusGet` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewBackupOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + +read, err := client.CloudHsmClusterBackupStatusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CloudHsmClustersClient.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +// alternatively `client.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx, id)` can be used to do batched pagination +items, err := client.CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudHsmClustersClient.CloudHsmClusterRestoreStatusGet` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewRestoreOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + +read, err := client.CloudHsmClusterRestoreStatusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CloudHsmClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.CloudHsmCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.Delete` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.Get` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CloudHsmClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudHsmClustersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudHsmClustersClient.Restore` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.RestoreRequestProperties{ + // ... +} + + +if err := client.RestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.Update` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.CloudHsmClusterPatchParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.ValidateBackupProperties` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.BackupRestoreRequestBaseProperties{ + // ... +} + + +if err := client.ValidateBackupPropertiesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudHsmClustersClient.ValidateRestoreProperties` + +```go +ctx := context.TODO() +id := cloudhsmclusters.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusters.RestoreRequestProperties{ + // ... +} + + +if err := client.ValidateRestorePropertiesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/client.go new file mode 100644 index 000000000000..0435d10d3111 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersClient struct { + Client *resourcemanager.Client +} + +func NewCloudHsmClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHsmClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHsmClustersClient: %+v", err) + } + + return &CloudHsmClustersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/constants.go new file mode 100644 index 000000000000..821c085e24b3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/constants.go @@ -0,0 +1,424 @@ +package cloudhsmclusters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_backupoperationstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_backupoperationstatus.go new file mode 100644 index 000000000000..ae9fc51ef0cd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_backupoperationstatus.go @@ -0,0 +1,139 @@ +package cloudhsmclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupOperationStatusId{}) +} + +var _ resourceids.ResourceId = &BackupOperationStatusId{} + +// BackupOperationStatusId is a struct representing the Resource ID for a Backup Operation Status +type BackupOperationStatusId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + JobId string +} + +// NewBackupOperationStatusID returns a new BackupOperationStatusId struct +func NewBackupOperationStatusID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, jobId string) BackupOperationStatusId { + return BackupOperationStatusId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + JobId: jobId, + } +} + +// ParseBackupOperationStatusID parses 'input' into a BackupOperationStatusId +func ParseBackupOperationStatusID(input string) (*BackupOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupOperationStatusId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupOperationStatusIDInsensitively parses 'input' case-insensitively into a BackupOperationStatusId +// note: this method should only be used for API response data and not user input +func ParseBackupOperationStatusIDInsensitively(input string) (*BackupOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupOperationStatusId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupOperationStatusId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.JobId, ok = input.Parsed["jobId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobId", input) + } + + return nil +} + +// ValidateBackupOperationStatusID checks that 'input' can be parsed as a Backup Operation Status ID +func ValidateBackupOperationStatusID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupOperationStatusID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Operation Status ID +func (id BackupOperationStatusId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/backupOperationStatus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.JobId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Operation Status ID +func (id BackupOperationStatusId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticBackupOperationStatus", "backupOperationStatus", "backupOperationStatus"), + resourceids.UserSpecifiedSegment("jobId", "jobId"), + } +} + +// String returns a human-readable description of this Backup Operation Status ID +func (id BackupOperationStatusId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Job: %q", id.JobId), + } + return fmt.Sprintf("Backup Operation Status (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_cloudhsmcluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_cloudhsmcluster.go new file mode 100644 index 000000000000..83b2659f7be6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_restoreoperationstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_restoreoperationstatus.go new file mode 100644 index 000000000000..122adad89dfe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/id_restoreoperationstatus.go @@ -0,0 +1,139 @@ +package cloudhsmclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RestoreOperationStatusId{}) +} + +var _ resourceids.ResourceId = &RestoreOperationStatusId{} + +// RestoreOperationStatusId is a struct representing the Resource ID for a Restore Operation Status +type RestoreOperationStatusId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + JobId string +} + +// NewRestoreOperationStatusID returns a new RestoreOperationStatusId struct +func NewRestoreOperationStatusID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, jobId string) RestoreOperationStatusId { + return RestoreOperationStatusId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + JobId: jobId, + } +} + +// ParseRestoreOperationStatusID parses 'input' into a RestoreOperationStatusId +func ParseRestoreOperationStatusID(input string) (*RestoreOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestoreOperationStatusId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestoreOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRestoreOperationStatusIDInsensitively parses 'input' case-insensitively into a RestoreOperationStatusId +// note: this method should only be used for API response data and not user input +func ParseRestoreOperationStatusIDInsensitively(input string) (*RestoreOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestoreOperationStatusId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestoreOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RestoreOperationStatusId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.JobId, ok = input.Parsed["jobId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobId", input) + } + + return nil +} + +// ValidateRestoreOperationStatusID checks that 'input' can be parsed as a Restore Operation Status ID +func ValidateRestoreOperationStatusID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRestoreOperationStatusID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Restore Operation Status ID +func (id RestoreOperationStatusId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/restoreOperationStatus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.JobId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Restore Operation Status ID +func (id RestoreOperationStatusId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticRestoreOperationStatus", "restoreOperationStatus", "restoreOperationStatus"), + resourceids.UserSpecifiedSegment("jobId", "jobId"), + } +} + +// String returns a human-readable description of this Restore Operation Status ID +func (id RestoreOperationStatusId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Job: %q", id.JobId), + } + return fmt.Sprintf("Restore Operation Status (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_backup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_backup.go new file mode 100644 index 000000000000..9fa9429654cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_backup.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// Backup ... +func (c CloudHsmClustersClient) Backup(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BackupThenPoll performs Backup then polls until it's completed +func (c CloudHsmClustersClient) BackupThenPoll(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) error { + result, err := c.Backup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Backup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Backup: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterbackupstatusget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterbackupstatusget.go new file mode 100644 index 000000000000..4a419e2dde30 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterbackupstatusget.go @@ -0,0 +1,54 @@ +package cloudhsmclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterBackupStatusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// CloudHsmClusterBackupStatusGet ... +func (c CloudHsmClustersClient) CloudHsmClusterBackupStatusGet(ctx context.Context, id BackupOperationStatusId) (result CloudHsmClusterBackupStatusGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go new file mode 100644 index 000000000000..b7bf777bc155 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go @@ -0,0 +1,105 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster ... +func (c CloudHsmClustersClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx context.Context, id CloudHsmClusterId) (result CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager{}, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete retrieves all the results into a single object +func (c CloudHsmClustersClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete(ctx context.Context, id CloudHsmClusterId) (CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult, error) { + return c.CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHsmClustersClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate(ctx context.Context, id CloudHsmClusterId, predicate PrivateLinkResourceOperationPredicate) (result CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterrestorestatusget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterrestorestatusget.go new file mode 100644 index 000000000000..53a5ef3e3247 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_cloudhsmclusterrestorestatusget.go @@ -0,0 +1,54 @@ +package cloudhsmclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterRestoreStatusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// CloudHsmClusterRestoreStatusGet ... +func (c CloudHsmClustersClient) CloudHsmClusterRestoreStatusGet(ctx context.Context, id RestoreOperationStatusId) (result CloudHsmClusterRestoreStatusGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_createorupdate.go new file mode 100644 index 000000000000..c6c3878b47e6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_createorupdate.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// CreateOrUpdate ... +func (c CloudHsmClustersClient) CreateOrUpdate(ctx context.Context, id CloudHsmClusterId, input CloudHsmCluster) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c CloudHsmClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id CloudHsmClusterId, input CloudHsmCluster) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_delete.go new file mode 100644 index 000000000000..15733035fe58 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_delete.go @@ -0,0 +1,70 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CloudHsmClustersClient) Delete(ctx context.Context, id CloudHsmClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CloudHsmClustersClient) DeleteThenPoll(ctx context.Context, id CloudHsmClusterId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_get.go new file mode 100644 index 000000000000..272aa20218fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_get.go @@ -0,0 +1,53 @@ +package cloudhsmclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// Get ... +func (c CloudHsmClustersClient) Get(ctx context.Context, id CloudHsmClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CloudHsmCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbyresourcegroup.go new file mode 100644 index 000000000000..fb8b890cf8c2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudHsmCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudHsmCluster +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CloudHsmClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CloudHsmCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CloudHsmClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CloudHsmClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHsmClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CloudHsmClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]CloudHsmCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbysubscription.go new file mode 100644 index 000000000000..573f7937f66d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_listbysubscription.go @@ -0,0 +1,106 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudHsmCluster +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudHsmCluster +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c CloudHsmClustersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CloudHsmCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c CloudHsmClustersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, CloudHsmClusterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHsmClustersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CloudHsmClusterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]CloudHsmCluster, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_restore.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_restore.go new file mode 100644 index 000000000000..f45edcbb7f6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_restore.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// Restore ... +func (c CloudHsmClustersClient) Restore(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c CloudHsmClustersClient) RestoreThenPoll(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_update.go new file mode 100644 index 000000000000..7d02f94c97aa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_update.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// Update ... +func (c CloudHsmClustersClient) Update(ctx context.Context, id CloudHsmClusterId, input CloudHsmClusterPatchParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c CloudHsmClustersClient) UpdateThenPoll(ctx context.Context, id CloudHsmClusterId, input CloudHsmClusterPatchParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validatebackupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validatebackupproperties.go new file mode 100644 index 000000000000..86392a12a366 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validatebackupproperties.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateBackupPropertiesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// ValidateBackupProperties ... +func (c CloudHsmClustersClient) ValidateBackupProperties(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) (result ValidateBackupPropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateBackupProperties", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ValidateBackupPropertiesThenPoll performs ValidateBackupProperties then polls until it's completed +func (c CloudHsmClustersClient) ValidateBackupPropertiesThenPoll(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) error { + result, err := c.ValidateBackupProperties(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackupProperties: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackupProperties: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validaterestoreproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validaterestoreproperties.go new file mode 100644 index 000000000000..627867e55bd0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/method_validaterestoreproperties.go @@ -0,0 +1,75 @@ +package cloudhsmclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateRestorePropertiesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// ValidateRestoreProperties ... +func (c CloudHsmClustersClient) ValidateRestoreProperties(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) (result ValidateRestorePropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateRestoreProperties", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ValidateRestorePropertiesThenPoll performs ValidateRestoreProperties then polls until it's completed +func (c CloudHsmClustersClient) ValidateRestorePropertiesThenPoll(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) error { + result, err := c.ValidateRestoreProperties(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateRestoreProperties: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateRestoreProperties: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorebaseresultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorebaseresultproperties.go new file mode 100644 index 000000000000..3c573c1680e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorebaseresultproperties.go @@ -0,0 +1,43 @@ +package cloudhsmclusters + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreBaseResultProperties struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupRestoreBaseResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupRestoreBaseResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorerequestbaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorerequestbaseproperties.go new file mode 100644 index 000000000000..2c0e6a1f254c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backuprestorerequestbaseproperties.go @@ -0,0 +1,9 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreRequestBaseProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + Token *string `json:"token,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresult.go new file mode 100644 index 000000000000..49fdd006410c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresult.go @@ -0,0 +1,8 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResult struct { + Properties *BackupResultProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresultproperties.go new file mode 100644 index 000000000000..6d619955298b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_backupresultproperties.go @@ -0,0 +1,45 @@ +package cloudhsmclusters + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResultProperties struct { + AzureStorageBlobContainerUri *string `json:"azureStorageBlobContainerUri,omitempty"` + BackupId *string `json:"backupId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmcluster.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmcluster.go new file mode 100644 index 000000000000..22cf389a0b53 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterpatchparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterpatchparameters.go new file mode 100644 index 000000000000..4f6cbf40f620 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterpatchparameters.go @@ -0,0 +1,13 @@ +package cloudhsmclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPatchParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterproperties.go new file mode 100644 index 000000000000..34986d27562d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclustersku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclustersku.go new file mode 100644 index 000000000000..f5f53c4ed1ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmproperties.go new file mode 100644 index 000000000000..893ce4f54ad2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_erroradditionalinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_erroradditionalinfo.go new file mode 100644 index 000000000000..8abf291c49c6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_errordetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_errordetail.go new file mode 100644 index 000000000000..c4196ab4ae01 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_errordetail.go @@ -0,0 +1,12 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpoint.go new file mode 100644 index 000000000000..94157cac15e4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnection.go new file mode 100644 index 000000000000..8b3b8b5aee9d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..db2f0d28d4f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresource.go new file mode 100644 index 000000000000..deccae05ef9b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package cloudhsmclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresourceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresourceproperties.go new file mode 100644 index 000000000000..aaeba0b6db94 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkserviceconnectionstate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..46d52857f952 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restorerequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restorerequestproperties.go new file mode 100644 index 000000000000..d40e83eefd5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restorerequestproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + BackupId string `json:"backupId"` + Token *string `json:"token,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restoreresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restoreresult.go new file mode 100644 index 000000000000..3d05a252a391 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/model_restoreresult.go @@ -0,0 +1,8 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreResult struct { + Properties *BackupRestoreBaseResultProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/predicates.go new file mode 100644 index 000000000000..3395a1624696 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/predicates.go @@ -0,0 +1,55 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudHsmClusterOperationPredicate) Matches(input CloudHsmCluster) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/version.go new file mode 100644 index 000000000000..833019301bce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusters/2025-03-31" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 61d2848b4c27..1d17e46fa315 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -583,6 +583,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/graphservices/2023-04-13 github.com/hashicorp/go-azure-sdk/resource-manager/graphservices/2023-04-13/graphservicesprods github.com/hashicorp/go-azure-sdk/resource-manager/guestconfiguration/2020-06-25/guestconfigurationassignments github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2021-11-30/dedicatedhsms +github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters github.com/hashicorp/go-azure-sdk/resource-manager/hdinsight/2021-06-01 github.com/hashicorp/go-azure-sdk/resource-manager/hdinsight/2021-06-01/applications github.com/hashicorp/go-azure-sdk/resource-manager/hdinsight/2021-06-01/clusters diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown new file mode 100644 index 000000000000..292ed7822369 --- /dev/null +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -0,0 +1,129 @@ +--- +subcategory: "Hardware Security Module" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_cloud_hardware_security_module_cluster" +description: |- + Manages a Cloud Hardware Security Module Cluster. +--- + +# azurerm_cloud_hardware_security_module_cluster + +Manages a Cloud Hardware Security Module Cluster. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_cloud_hardware_security_module_cluster" "example" { + name = "example-cloudhsm-cluster" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + + tags = { + environment = "example" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Cloud Hardware Security Module Cluster. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Cloud Hardware Security Module Cluster should exist. Changing this forces a new resource to be created. + +* `location` - (Required) The Azure Region where the Cloud Hardware Security Module Cluster should exist. Changing this forces a new resource to be created. + +--- + +* `identity` - (Optional) An `identity` block as defined below. + +* `auto_generated_domain_name_label_scope` - (Optional) Specifies the scope for auto-generated domain name labels. Possible values are `TenantReuse`, `SubscriptionReuse`, `ResourceGroupReuse`, and `NoReuse`. Defaults to `NoReuse`. Changing this forces a new resource to be created. + +* `tags` - (Optional) A mapping of tags to assign to the Cloud Hardware Security Module Cluster. + +--- + +An `identity` block supports the following: + +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Cloud Hardware Security Module Cluster. The only supported value is `UserAssigned`. + +* `identity_ids` - (Required) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Cloud Hardware Security Module Cluster. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Cloud Hardware Security Module Cluster. + +* `activation_state` - The activation state of the Cloud Hardware Security Module Cluster. + +* `status_message` - The status message of the Cloud Hardware Security Module Cluster. + +* `hsms` - A list of `hsms` blocks as defined below. + +* `private_endpoint_connections` - A list of `private_endpoint_connections` blocks as defined below. + +--- + +A `hsms` block exports the following: + +* `fqdn` - The fully qualified domain name of the HSM instance. + +* `state` - The state of the HSM instance. + +* `state_message` - The state message of the HSM instance. + +--- + +A `private_endpoint_connections` block exports the following: + +* `id` - The ID of the private endpoint connection. + +* `name` - The name of the private endpoint connection. + +* `type` - The type of the private endpoint connection. + +* `group_ids` - A list of group IDs for the private endpoint connection. + +* `private_endpoint` - A `private_endpoint` block as defined below. + +* `private_link_service_connection_state` - A `private_link_service_connection_state` block as defined below. + +--- + +A `private_endpoint` block exports the following: + +* `id` - The ID of the private endpoint. + +--- + +A `private_link_service_connection_state` block exports the following: + +* `status` - The status of the private link service connection. + +* `description` - The description of the private link service connection state. + +* `actions_required` - The actions required for the private link service connection. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 60 minutes) Used when creating the Cloud Hardware Security Module Cluster. +* `read` - (Defaults to 5 minutes) Used when retrieving the Cloud Hardware Security Module Cluster. +* `update` - (Defaults to 60 minutes) Used when updating the Cloud Hardware Security Module Cluster. +* `delete` - (Defaults to 60 minutes) Used when deleting the Cloud Hardware Security Module Cluster. + +## Import + +Cloud Hardware Security Module Clusters can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_cloud_hardware_security_module_cluster.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cluster1 +``` From 0542fbdfdfd7b4779ec3da2802ede26a3fec1abb Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 1 Aug 2025 16:49:32 +1000 Subject: [PATCH 02/24] fmt --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 2 +- .../hsm/custompollers/cloud_hsm_cluster_state_poller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 9ae246fee658..a980b087b02d 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -99,7 +99,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*plug "auto_generated_domain_name_label_scope": { Type: pluginsdk.TypeString, Optional: true, - ForceNew: true, + ForceNew: true, Default: string(cloudhsmclusters.AutoGeneratedDomainNameLabelScopeTenantReuse), ValidateFunc: validation.StringInSlice(cloudhsmclusters.PossibleValuesForAutoGeneratedDomainNameLabelScope(), false), }, diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go index 52ee0cfdc5e8..36cae32ed137 100644 --- a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -48,7 +48,7 @@ func (p *CloudHsmClusterStatePoller) Poll(ctx context.Context) (*pollers.PollRes HttpResponse: &client.Response{ Response: resp.HttpResponse, }, - Status: pollers.PollingStatusSucceeded, + Status: pollers.PollingStatusSucceeded, }, nil } From d0a408152fc3218efe26e836ef232b7dbbadd278 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 1 Aug 2025 16:59:27 +1000 Subject: [PATCH 03/24] update labeler --- .github/labeler-issue-triage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 9a48ccaf3c45..9ca93aff7fe7 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -171,7 +171,7 @@ service/healthcare: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_healthcare_((.|\n)*)###' service/hsm: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_dedicated_hardware_security_module((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(cloud_hardware_security_module_cluster|dedicated_hardware_security_module)((.|\n)*)###' service/hybrid-compute: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(arc_machine\W+|arc_machine_extension\W+|arc_private_link_scope\W+)((.|\n)*)###' From b9a08c4dc2ae316eb461405103b6c38b327ec68d Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 1 Aug 2025 17:08:50 +1000 Subject: [PATCH 04/24] lint fix --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 4 ++-- internal/services/hsm/registration.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index a980b087b02d..551eb6482bd5 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -327,10 +327,10 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { hsmModel.Fqdn = *hsm.Fqdn } if hsm.State != nil { - hsmModel.State = string(*hsm.State) + hsmModel.State = pointer.From(hsm.State) } if hsm.StateMessage != nil { - hsmModel.StateMessage = *hsm.StateMessage + hsmModel.StateMessage = pointer.From(hsm.StateMessage) } hsms = append(hsms, hsmModel) } diff --git a/internal/services/hsm/registration.go b/internal/services/hsm/registration.go index 6e2e62bc6eda..52581122a30d 100644 --- a/internal/services/hsm/registration.go +++ b/internal/services/hsm/registration.go @@ -10,8 +10,10 @@ import ( type Registration struct{} -var _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} -var _ sdk.TypedServiceRegistration = Registration{} +var ( + _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} + _ sdk.TypedServiceRegistration = Registration{} +) func (r Registration) AssociatedGitHubLabel() string { return "service/hsm" From cc56791b34761d849238aa1d5dbdaefdb14702a6 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 5 Aug 2025 14:09:40 +1000 Subject: [PATCH 05/24] code format and clean --- ...rdware_security_module_cluster_resource.go | 26 ++-- ...e_security_module_cluster_resource_test.go | 4 +- .../custompollers/cloud_hsm_cluster_poller.go | 0 ...=> cloud_hardware_security_module_name.go} | 0 ...loud_hardware_security_module_name_test.go | 115 ++++++++++++++++++ 5 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go rename internal/services/hsm/validate/{cloud_hardware_security_module_name_valite.go => cloud_hardware_security_module_name.go} (100%) create mode 100644 internal/services/hsm/validate/cloud_hardware_security_module_name_test.go diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 551eb6482bd5..462c5861af2e 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" - "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -30,7 +29,7 @@ type CloudHardwareSecurityModuleClusterModel struct { Location string `tfschema:"location"` Identity []identity.ModelUserAssigned `tfschema:"identity"` AutoGeneratedDomainNameLabelScope string `tfschema:"auto_generated_domain_name_label_scope"` - Tags map[string]interface{} `tfschema:"tags"` + Tags map[string]string `tfschema:"tags"` // Computed ActivationState string `tfschema:"activation_state"` @@ -93,9 +92,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*plug "location": commonschema.Location(), - // only user assigned identity is supported even though the swagger shows system assigned identity - "identity": commonschema.UserAssignedIdentityOptional(), - "auto_generated_domain_name_label_scope": { Type: pluginsdk.TypeString, Optional: true, @@ -104,6 +100,9 @@ func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*plug ValidateFunc: validation.StringInSlice(cloudhsmclusters.PossibleValuesForAutoGeneratedDomainNameLabelScope(), false), }, + // only user assigned identity is supported even though the swagger shows system assigned identity + "identity": commonschema.UserAssignedIdentityOptional(), + "tags": commonschema.Tags(), } } @@ -228,11 +227,14 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { parameters := cloudhsmclusters.CloudHsmCluster{ Location: location.Normalize(model.Location), - Tags: tags.Expand(model.Tags), + Tags: pointer.To(model.Tags), Sku: &cloudhsmclusters.CloudHsmClusterSku{ Name: cloudhsmclusters.CloudHsmClusterSkuNameStandardBOne, Family: cloudhsmclusters.CloudHsmClusterSkuFamilyB, - // Capacity is left unset + // Capacity is intentionally left unset as the API does not support it + }, + Properties: &cloudhsmclusters.CloudHsmClusterProperties{ + AutoGeneratedDomainNameLabelScope: pointer.To(cloudhsmclusters.AutoGeneratedDomainNameLabelScope(model.AutoGeneratedDomainNameLabelScope)), }, } @@ -249,12 +251,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { parameters.Identity = legacyIdentity } - if model.AutoGeneratedDomainNameLabelScope != "" { - parameters.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ - AutoGeneratedDomainNameLabelScope: pointer.To(cloudhsmclusters.AutoGeneratedDomainNameLabelScope(model.AutoGeneratedDomainNameLabelScope)), - } - } - if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -292,7 +288,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { if m := resp.Model; m != nil { model.Location = location.Normalize(m.Location) - model.Tags = tags.Flatten(m.Tags) + model.Tags = pointer.From(m.Tags) if m.Identity != nil { // only User Assigned Identity is supported @@ -380,7 +376,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } if metadata.ResourceData.HasChange("tags") { - update.Tags = tags.Expand(model.Tags) + update.Tags = pointer.To(model.Tags) } // Initiate the update operation diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index fe0fe16aee63..5c957e221a02 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -8,12 +8,12 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusters" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CloudHardwareSecurityModuleClusterResource struct{} @@ -148,7 +148,7 @@ func (CloudHardwareSecurityModuleClusterResource) Exists(ctx context.Context, cl return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.Model != nil), nil + return pointer.To(resp.Model != nil), nil } func (r CloudHardwareSecurityModuleClusterResource) requiresImport(data acceptance.TestData) string { diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go b/internal/services/hsm/validate/cloud_hardware_security_module_name.go similarity index 100% rename from internal/services/hsm/validate/cloud_hardware_security_module_name_valite.go rename to internal/services/hsm/validate/cloud_hardware_security_module_name.go diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go b/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go new file mode 100644 index 000000000000..1e3067d4be09 --- /dev/null +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go @@ -0,0 +1,115 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package validate + +import ( + "strings" + "testing" +) + +func TestValidateCloudHsmClusterName(t *testing.T) { + testCases := []struct { + Input string + Expected bool + }{ + { + // Valid: 3 characters, alphanumeric + Input: "abc", + Expected: true, + }, + { + // Valid: 23 characters, alphanumeric + Input: strings.Repeat("a", 23), + Expected: true, + }, + { + // Valid: with hyphens + Input: "hello-world", + Expected: true, + }, + { + // Valid: starts with digit + Input: "1hello-world", + Expected: true, + }, + { + // Valid: ends with digit + Input: "hello-world9", + Expected: true, + }, + { + // Valid: contains digits and hyphens + Input: "test1-cluster2", + Expected: true, + }, + { + // Invalid: too short (2 characters) + Input: "ab", + Expected: false, + }, + { + // Invalid: too long (24 characters) + Input: strings.Repeat("a", 24), + Expected: false, + }, + { + // Invalid: starts with hyphen + Input: "-hello-world", + Expected: false, + }, + { + // Invalid: ends with hyphen + Input: "hello-world-", + Expected: false, + }, + { + // Invalid: consecutive hyphens + Input: "hello--world", + Expected: false, + }, + { + // Invalid: multiple consecutive hyphens + Input: "hello---world", + Expected: false, + }, + { + // Invalid: contains special characters + Input: "hello_world", + Expected: false, + }, + { + // Invalid: contains spaces + Input: "hello world", + Expected: false, + }, + { + // Invalid: contains uppercase (should be case-insensitive, but let's test) + Input: "Hello-World", + Expected: true, + }, + { + // Invalid: only hyphens + Input: "---", + Expected: false, + }, + { + // Valid: minimum length with hyphen + Input: "a-b", + Expected: true, + }, + { + // Valid: maximum length with hyphens + Input: "a" + strings.Repeat("-b", 10) + "c", + Expected: true, + }, + } + + for _, v := range testCases { + _, errors := ValidateCloudHsmClusterName(v.Input, "name") + result := len(errors) == 0 + if result != v.Expected { + t.Fatalf("Expected the result to be %t for input %q but got %t (and %d errors)", v.Expected, v.Input, result, len(errors)) + } + } +} From ee178c631211f3f8f0b8e7fb89758bf6ed42ac33 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 5 Aug 2025 14:18:28 +1000 Subject: [PATCH 06/24] remove unused empty file --- internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_poller.go deleted file mode 100644 index e69de29bb2d1..000000000000 From 34c9801b0bdf29317c7a081a3fc53fea9ec0531e Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 5 Aug 2025 15:02:08 +1000 Subject: [PATCH 07/24] update document timeouts --- .../r/cloud_hardware_security_module_cluster.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index 292ed7822369..74c22a6e036d 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -115,10 +115,10 @@ A `private_link_service_connection_state` block exports the following: The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: -* `create` - (Defaults to 60 minutes) Used when creating the Cloud Hardware Security Module Cluster. +* `create` - (Defaults to 1 hour) Used when creating the Cloud Hardware Security Module Cluster. * `read` - (Defaults to 5 minutes) Used when retrieving the Cloud Hardware Security Module Cluster. -* `update` - (Defaults to 60 minutes) Used when updating the Cloud Hardware Security Module Cluster. -* `delete` - (Defaults to 60 minutes) Used when deleting the Cloud Hardware Security Module Cluster. +* `update` - (Defaults to 1 hour) Used when updating the Cloud Hardware Security Module Cluster. +* `delete` - (Defaults to 30 minutes) Used when deleting the Cloud Hardware Security Module Cluster. ## Import From 101207a364674c6d3f4fb116df611b6baec47f92 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 5 Aug 2025 15:18:07 +1000 Subject: [PATCH 08/24] add generated document api provider --- .../r/cloud_hardware_security_module_cluster.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index 74c22a6e036d..ba5a1cb3cacb 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -127,3 +127,9 @@ Cloud Hardware Security Module Clusters can be imported using the `resource id`, ```shell terraform import azurerm_cloud_hardware_security_module_cluster.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cluster1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.HardwareSecurityModules` - 2025-03-31 From 715401668f89aaeffb16491de71f8c045c337511 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 29 Aug 2025 14:52:44 +1000 Subject: [PATCH 09/24] update code style --- ...rdware_security_module_cluster_resource.go | 101 +++++++----------- 1 file changed, 41 insertions(+), 60 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 462c5861af2e..bfcbf107684c 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -303,30 +303,17 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { } if props := m.Properties; props != nil { - if props.ActivationState != nil { - model.ActivationState = string(*props.ActivationState) - } - - if props.AutoGeneratedDomainNameLabelScope != nil { - model.AutoGeneratedDomainNameLabelScope = string(*props.AutoGeneratedDomainNameLabelScope) - } - - if props.StatusMessage != nil { - model.StatusMessage = *props.StatusMessage - } + model.ActivationState = string(pointer.From(props.ActivationState)) + model.AutoGeneratedDomainNameLabelScope = string(pointer.From(props.AutoGeneratedDomainNameLabelScope)) + model.StatusMessage = pointer.From(props.StatusMessage) if props.Hsms != nil { hsms := make([]CloudHsmPropertiesModel, 0) for _, hsm := range *props.Hsms { - hsmModel := CloudHsmPropertiesModel{} - if hsm.Fqdn != nil { - hsmModel.Fqdn = *hsm.Fqdn - } - if hsm.State != nil { - hsmModel.State = pointer.From(hsm.State) - } - if hsm.StateMessage != nil { - hsmModel.StateMessage = pointer.From(hsm.StateMessage) + hsmModel := CloudHsmPropertiesModel{ + Fqdn: pointer.From(hsm.Fqdn), + State: pointer.From(hsm.State), + StateMessage: pointer.From(hsm.StateMessage), } hsms = append(hsms, hsmModel) } @@ -419,44 +406,38 @@ func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { } func flattenPrivateEndpointConnections(connections *[]cloudhsmclusters.PrivateEndpointConnection) []PrivateEndpointConnectionModel { - if connections == nil { - return []PrivateEndpointConnectionModel{} - } - - result := make([]PrivateEndpointConnectionModel, 0) - for _, conn := range *connections { - connModel := PrivateEndpointConnectionModel{} - if conn.Id != nil { - connModel.Id = *conn.Id - } - if conn.Name != nil { - connModel.Name = *conn.Name - } - if conn.Type != nil { - connModel.Type = *conn.Type - } - if conn.Properties != nil { - if conn.Properties.GroupIds != nil { - connModel.GroupIds = *conn.Properties.GroupIds - } - if conn.Properties.PrivateEndpoint != nil { - connModel.PrivateEndpoint = []PrivateEndpointModel{ - { - Id: pointer.From(conn.Properties.PrivateEndpoint.Id), - }, - } - } - if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { - connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ - { - Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), - Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), - ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), - }, - } - } - } - result = append(result, connModel) - } - return result + if connections == nil { + return []PrivateEndpointConnectionModel{} + } + + result := make([]PrivateEndpointConnectionModel, 0) + for _, conn := range *connections { + connModel := PrivateEndpointConnectionModel{ + Id: pointer.From(conn.Id), + Name: pointer.From(conn.Name), + Type: pointer.From(conn.Type), + } + + if conn.Properties != nil { + connModel.GroupIds = pointer.From(conn.Properties.GroupIds) + if conn.Properties.PrivateEndpoint != nil { + connModel.PrivateEndpoint = []PrivateEndpointModel{ + { + Id: pointer.From(conn.Properties.PrivateEndpoint.Id), + }, + } + } + if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { + connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ + { + Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), + Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), + ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), + }, + } + } + } + result = append(result, connModel) + } + return result } From f912f50f01da0a9781d53d808300f85a166f2c1c Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Wed, 24 Sep 2025 17:13:42 +1000 Subject: [PATCH 10/24] fix fmt --- ...rdware_security_module_cluster_resource.go | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index bfcbf107684c..6c8b1f66c1e6 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -311,8 +311,8 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { hsms := make([]CloudHsmPropertiesModel, 0) for _, hsm := range *props.Hsms { hsmModel := CloudHsmPropertiesModel{ - Fqdn: pointer.From(hsm.Fqdn), - State: pointer.From(hsm.State), + Fqdn: pointer.From(hsm.Fqdn), + State: pointer.From(hsm.State), StateMessage: pointer.From(hsm.StateMessage), } hsms = append(hsms, hsmModel) @@ -406,38 +406,38 @@ func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { } func flattenPrivateEndpointConnections(connections *[]cloudhsmclusters.PrivateEndpointConnection) []PrivateEndpointConnectionModel { - if connections == nil { - return []PrivateEndpointConnectionModel{} - } - - result := make([]PrivateEndpointConnectionModel, 0) - for _, conn := range *connections { - connModel := PrivateEndpointConnectionModel{ - Id: pointer.From(conn.Id), - Name: pointer.From(conn.Name), - Type: pointer.From(conn.Type), - } - - if conn.Properties != nil { - connModel.GroupIds = pointer.From(conn.Properties.GroupIds) - if conn.Properties.PrivateEndpoint != nil { - connModel.PrivateEndpoint = []PrivateEndpointModel{ - { - Id: pointer.From(conn.Properties.PrivateEndpoint.Id), - }, - } - } - if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { - connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ - { - Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), - Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), - ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), - }, - } - } - } - result = append(result, connModel) - } - return result + if connections == nil { + return []PrivateEndpointConnectionModel{} + } + + result := make([]PrivateEndpointConnectionModel, 0) + for _, conn := range *connections { + connModel := PrivateEndpointConnectionModel{ + Id: pointer.From(conn.Id), + Name: pointer.From(conn.Name), + Type: pointer.From(conn.Type), + } + + if conn.Properties != nil { + connModel.GroupIds = pointer.From(conn.Properties.GroupIds) + if conn.Properties.PrivateEndpoint != nil { + connModel.PrivateEndpoint = []PrivateEndpointModel{ + { + Id: pointer.From(conn.Properties.PrivateEndpoint.Id), + }, + } + } + if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { + connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ + { + Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), + Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), + ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), + }, + } + } + } + result = append(result, connModel) + } + return result } From 9addc5780012730b3b5e1dd354d6b388f9baddbe Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 26 Sep 2025 14:52:50 +1000 Subject: [PATCH 11/24] move provider block to each testcase --- ...e_security_module_cluster_resource_test.go | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index 5c957e221a02..d6195893c6ed 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -165,10 +165,6 @@ resource "azurerm_cloud_hardware_security_module_cluster" "import" { func (CloudHardwareSecurityModuleClusterResource) template(data acceptance.TestData) string { return fmt.Sprintf(` -provider "azurerm" { - features {} -} - resource "azurerm_resource_group" "test" { name = "acctestRG-cloudhsm-%d" location = "%s" @@ -178,6 +174,10 @@ resource "azurerm_resource_group" "test" { func (r CloudHardwareSecurityModuleClusterResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s resource "azurerm_cloud_hardware_security_module_cluster" "test" { @@ -191,6 +191,10 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { func (r CloudHardwareSecurityModuleClusterResource) complete(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s resource "azurerm_user_assigned_identity" "test" { @@ -221,6 +225,10 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { func (r CloudHardwareSecurityModuleClusterResource) update(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %[1]s resource "azurerm_user_assigned_identity" "test" { @@ -249,6 +257,10 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { func (r CloudHardwareSecurityModuleClusterResource) userAssignedIdentity(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s resource "azurerm_user_assigned_identity" "test" { @@ -273,6 +285,10 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { func (r CloudHardwareSecurityModuleClusterResource) privateEndpoint(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + %s resource "azurerm_virtual_network" "test" { From 0d1fd9dee97a86443fb469a138ffb98854a2c870 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 29 Sep 2025 16:28:08 +1000 Subject: [PATCH 12/24] update identity logic and doc --- ...rdware_security_module_cluster_resource.go | 38 +++++++++++++-- ...e_security_module_cluster_resource_test.go | 47 +++++++++++++++++++ ...ware_security_module_cluster.html.markdown | 2 +- 3 files changed, 82 insertions(+), 5 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 6c8b1f66c1e6..7faa04140270 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -227,7 +227,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { parameters := cloudhsmclusters.CloudHsmCluster{ Location: location.Normalize(model.Location), - Tags: pointer.To(model.Tags), Sku: &cloudhsmclusters.CloudHsmClusterSku{ Name: cloudhsmclusters.CloudHsmClusterSkuNameStandardBOne, Family: cloudhsmclusters.CloudHsmClusterSkuFamilyB, @@ -238,6 +237,11 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { }, } + if len(model.Tags) > 0 { + // can't set null to tags, api will reject + parameters.Tags = pointer.To(model.Tags) + } + if len(model.Identity) > 0 { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) if err != nil { @@ -348,28 +352,54 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } update := cloudhsmclusters.CloudHsmClusterPatchParameters{} + exists, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + if exists.Model == nil { + return fmt.Errorf("got nil model for HSM Cluster %s", *id) + } if metadata.ResourceData.HasChange("identity") { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) if err != nil { return fmt.Errorf("expanding `identity`: %+v", err) } + + // below logic needs go-azure-helpers with https://github.com/hashicorp/go-azure-helpers/pull/259 + // if currentIdentity := exists.Model.Identity; currentIdentity != nil { + // // mark identity should be delete as null + // for id := range currentIdentity.IdentityIds { + // if _, ok := expandedIdentity.IdentityIds[id]; !ok { + // expandedIdentity.IdentityIds[id] = identity.NullUserAssignedIdentityDetails + // } + // } + // } + // Convert to LegacySystemAndUserAssignedMap since the SDK uses the legacy type legacyIdentity := &identity.LegacySystemAndUserAssignedMap{ - Type: identity.TypeUserAssigned, + Type: expandedIdentity.Type, IdentityIds: expandedIdentity.IdentityIds, } update.Identity = legacyIdentity + // always set the tags or API will remove the tags + update.Tags = exists.Model.Tags } + // the `tags` field should always be set or it will be removed by the API if metadata.ResourceData.HasChange("tags") { - update.Tags = pointer.To(model.Tags) + if model.Tags == nil { + update.Tags = pointer.To(map[string]string{}) + } else { + update.Tags = pointer.To(model.Tags) + } } // Initiate the update operation err = client.UpdateThenPoll(ctx, *id, update) if err != nil { - return fmt.Errorf("initiating update for %s: %+v", *id, err) + return fmt.Errorf("updating for %s: %+v", *id, err) } // Use custom poller to wait for provisioning to complete diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index d6195893c6ed..999edeffce53 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -71,6 +71,7 @@ func TestAccCloudHardwareSecurityModuleCluster_complete(t *testing.T) { func TestAccCloudHardwareSecurityModuleCluster_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") r := CloudHardwareSecurityModuleClusterResource{} + t.Skip(r.update(data)) data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -88,6 +89,20 @@ func TestAccCloudHardwareSecurityModuleCluster_update(t *testing.T) { ), }, data.ImportStep(), + { + Config: r.updateIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), }) } @@ -255,6 +270,38 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { `, r.template(data), data.RandomString) } +func (r CloudHardwareSecurityModuleClusterResource) updateIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_user_assigned_identity" "test2" { + name = "acctestuai2-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_cloud_hardware_security_module_cluster" "test" { + name = "acctest-hsm-%[2]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test2.id] + } + + tags = { + environment = "updated" + purpose = "acceptance-testing" + } +} +`, r.template(data), data.RandomString) +} + func (r CloudHardwareSecurityModuleClusterResource) userAssignedIdentity(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index ba5a1cb3cacb..b41e0cb0d042 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -43,7 +43,7 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. -* `auto_generated_domain_name_label_scope` - (Optional) Specifies the scope for auto-generated domain name labels. Possible values are `TenantReuse`, `SubscriptionReuse`, `ResourceGroupReuse`, and `NoReuse`. Defaults to `NoReuse`. Changing this forces a new resource to be created. +* `auto_generated_domain_name_label_scope` - (Optional) Specifies the scope for auto-generated domain name labels. Possible values are `TenantReuse`, `SubscriptionReuse`, `ResourceGroupReuse`, and `NoReuse`. Defaults to `TenantReuse`. Changing this forces a new resource to be created. * `tags` - (Optional) A mapping of tags to assign to the Cloud Hardware Security Module Cluster. From ba0c4d51bb2cfa467dea78a03fcb8d7c8e0c7549 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 27 Oct 2025 16:25:53 +1100 Subject: [PATCH 13/24] use createorupdate instead of update, add retry for delete in operation conflict --- ...rdware_security_module_cluster_resource.go | 48 ++++++++++++------- ...e_security_module_cluster_resource_test.go | 2 - 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 7faa04140270..5ef2334c634e 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -351,7 +351,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - update := cloudhsmclusters.CloudHsmClusterPatchParameters{} exists, err := client.Get(ctx, *id) if err != nil { return fmt.Errorf("retrieving %s: %+v", *id, err) @@ -361,43 +360,38 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { return fmt.Errorf("got nil model for HSM Cluster %s", *id) } + cluster := *exists.Model + cluster.SystemData = nil + cluster.Id = nil + cluster.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ + AutoGeneratedDomainNameLabelScope: cluster.Properties.AutoGeneratedDomainNameLabelScope, + } + if metadata.ResourceData.HasChange("identity") { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) if err != nil { return fmt.Errorf("expanding `identity`: %+v", err) } - // below logic needs go-azure-helpers with https://github.com/hashicorp/go-azure-helpers/pull/259 - // if currentIdentity := exists.Model.Identity; currentIdentity != nil { - // // mark identity should be delete as null - // for id := range currentIdentity.IdentityIds { - // if _, ok := expandedIdentity.IdentityIds[id]; !ok { - // expandedIdentity.IdentityIds[id] = identity.NullUserAssignedIdentityDetails - // } - // } - // } - // Convert to LegacySystemAndUserAssignedMap since the SDK uses the legacy type legacyIdentity := &identity.LegacySystemAndUserAssignedMap{ Type: expandedIdentity.Type, IdentityIds: expandedIdentity.IdentityIds, } - update.Identity = legacyIdentity - // always set the tags or API will remove the tags - update.Tags = exists.Model.Tags + cluster.Identity = legacyIdentity } // the `tags` field should always be set or it will be removed by the API if metadata.ResourceData.HasChange("tags") { if model.Tags == nil { - update.Tags = pointer.To(map[string]string{}) + cluster.Tags = pointer.To(map[string]string{}) } else { - update.Tags = pointer.To(model.Tags) + cluster.Tags = pointer.To(model.Tags) } } // Initiate the update operation - err = client.UpdateThenPoll(ctx, *id, update) + err = client.CreateOrUpdateThenPoll(ctx, *id, cluster) if err != nil { return fmt.Errorf("updating for %s: %+v", *id, err) } @@ -426,7 +420,25 @@ func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { return err } - if err := client.DeleteThenPoll(ctx, *id); err != nil { + // the deletion of Cloud HSM may return 409 if the linked Private Endpoint is deleted recently + deadline, ok := ctx.Deadline() + if !ok { + return fmt.Errorf("expected context to have deadline") + } + + if err = pluginsdk.Retry(time.Until(deadline), func() *pluginsdk.RetryError { + resp, err := client.Delete(ctx, *id) + if err != nil { + if response.WasConflict(resp.HttpResponse) { + return pluginsdk.RetryableError(err) + } + return pluginsdk.NonRetryableError(err) + } + if err := resp.Poller.PollUntilDone(ctx); err != nil { + return pluginsdk.NonRetryableError(err) + } + return nil + }); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index 999edeffce53..5697355936a1 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -22,7 +22,6 @@ func TestAccCloudHardwareSecurityModuleCluster_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") r := CloudHardwareSecurityModuleClusterResource{} - // t.Skip(r.basic(data)) data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), @@ -71,7 +70,6 @@ func TestAccCloudHardwareSecurityModuleCluster_complete(t *testing.T) { func TestAccCloudHardwareSecurityModuleCluster_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cloud_hardware_security_module_cluster", "test") r := CloudHardwareSecurityModuleClusterResource{} - t.Skip(r.update(data)) data.ResourceTest(t, r, []acceptance.TestStep{ { From 517d3880cb3ebc1804729c2151dc4f9fc0e62f1a Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 1 Dec 2025 10:11:06 +1100 Subject: [PATCH 14/24] code/doc format update --- ...rdware_security_module_cluster_resource.go | 19 ++++++++++--------- .../cloud_hsm_cluster_state_poller.go | 4 ++-- ...ware_security_module_cluster.html.markdown | 10 +++++----- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 5ef2334c634e..d7c14754cbc8 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -5,6 +5,7 @@ package hsm import ( "context" + "errors" "fmt" "time" @@ -233,7 +234,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { // Capacity is intentionally left unset as the API does not support it }, Properties: &cloudhsmclusters.CloudHsmClusterProperties{ - AutoGeneratedDomainNameLabelScope: pointer.To(cloudhsmclusters.AutoGeneratedDomainNameLabelScope(model.AutoGeneratedDomainNameLabelScope)), + AutoGeneratedDomainNameLabelScope: pointer.ToEnum[cloudhsmclusters.AutoGeneratedDomainNameLabelScope](model.AutoGeneratedDomainNameLabelScope), }, } @@ -357,15 +358,15 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } if exists.Model == nil { - return fmt.Errorf("got nil model for HSM Cluster %s", *id) + return fmt.Errorf("retrieving %s: `model` was nil", id) } cluster := *exists.Model - cluster.SystemData = nil - cluster.Id = nil - cluster.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ - AutoGeneratedDomainNameLabelScope: cluster.Properties.AutoGeneratedDomainNameLabelScope, - } + // cluster.SystemData = nil + // cluster.Id = nil + // cluster.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ + // AutoGeneratedDomainNameLabelScope: cluster.Properties.AutoGeneratedDomainNameLabelScope, + // } if metadata.ResourceData.HasChange("identity") { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) @@ -393,7 +394,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { // Initiate the update operation err = client.CreateOrUpdateThenPoll(ctx, *id, cluster) if err != nil { - return fmt.Errorf("updating for %s: %+v", *id, err) + return fmt.Errorf("updating %s: %+v", id, err) } // Use custom poller to wait for provisioning to complete @@ -423,7 +424,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { // the deletion of Cloud HSM may return 409 if the linked Private Endpoint is deleted recently deadline, ok := ctx.Deadline() if !ok { - return fmt.Errorf("expected context to have deadline") + return errors.New("internal-error: context had no deadline") } if err = pluginsdk.Retry(time.Until(deadline), func() *pluginsdk.RetryError { diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go index 36cae32ed137..af3eaab7c7dd 100644 --- a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -37,8 +37,8 @@ func (p *CloudHsmClusterStatePoller) Poll(ctx context.Context) (*pollers.PollRes } statusMessage := "" - if model := resp.Model; model != nil && model.Properties != nil && model.Properties.StatusMessage != nil { - statusMessage = strings.ToLower(strings.TrimSpace(*model.Properties.StatusMessage)) + if model := resp.Model; model != nil && model.Properties != nil { + statusMessage = strings.ToLower(strings.TrimSpace(pointer.From(model.Properties.StatusMessage))) } // Check if provisioning is successful diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index b41e0cb0d042..500db32be154 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -87,14 +87,14 @@ A `private_endpoint_connections` block exports the following: * `name` - The name of the private endpoint connection. -* `type` - The type of the private endpoint connection. - * `group_ids` - A list of group IDs for the private endpoint connection. * `private_endpoint` - A `private_endpoint` block as defined below. * `private_link_service_connection_state` - A `private_link_service_connection_state` block as defined below. +* `type` - The type of the private endpoint connection. + --- A `private_endpoint` block exports the following: @@ -105,15 +105,15 @@ A `private_endpoint` block exports the following: A `private_link_service_connection_state` block exports the following: -* `status` - The status of the private link service connection. +* `actions_required` - The actions required for the private link service connection. * `description` - The description of the private link service connection state. -* `actions_required` - The actions required for the private link service connection. +* `status` - The status of the private link service connection. ## Timeouts -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: +The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `create` - (Defaults to 1 hour) Used when creating the Cloud Hardware Security Module Cluster. * `read` - (Defaults to 5 minutes) Used when retrieving the Cloud Hardware Security Module Cluster. From bc73649f356e3a4f464a660d01fbef03c8e8e676 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 1 Dec 2025 10:47:46 +1100 Subject: [PATCH 15/24] code format --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index d7c14754cbc8..a6cd40e637de 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -362,11 +362,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } cluster := *exists.Model - // cluster.SystemData = nil - // cluster.Id = nil - // cluster.Properties = &cloudhsmclusters.CloudHsmClusterProperties{ - // AutoGeneratedDomainNameLabelScope: cluster.Properties.AutoGeneratedDomainNameLabelScope, - // } if metadata.ResourceData.HasChange("identity") { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) From d11c2ccf45a7ccf5437969b13efd7fd377b30b7b Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 1 Dec 2025 11:02:43 +1100 Subject: [PATCH 16/24] doc format --- .../r/cloud_hardware_security_module_cluster.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index 500db32be154..7069356365cb 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -63,12 +63,12 @@ In addition to the Arguments listed above - the following Attributes are exporte * `activation_state` - The activation state of the Cloud Hardware Security Module Cluster. -* `status_message` - The status message of the Cloud Hardware Security Module Cluster. - * `hsms` - A list of `hsms` blocks as defined below. * `private_endpoint_connections` - A list of `private_endpoint_connections` blocks as defined below. +* `status_message` - The status message of the Cloud Hardware Security Module Cluster. + --- A `hsms` block exports the following: From 2eca996f629db1354f2016632ae07948858ee1a4 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 1 Dec 2025 14:52:04 +1100 Subject: [PATCH 17/24] fix update request body --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index a6cd40e637de..1a31e615aa12 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -362,6 +362,8 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } cluster := *exists.Model + // systemData has to be nil for update operations or the API will reject the request + cluster.SystemData = nil if metadata.ResourceData.HasChange("identity") { expandedIdentity, err := identity.ExpandUserAssignedMapFromModel(model.Identity) From 3a1fad44fa3ffcc08ae1fbd3ab17ecac6f67298f Mon Sep 17 00:00:00 2001 From: Xu Wu Date: Tue, 9 Dec 2025 14:27:43 +1100 Subject: [PATCH 18/24] Apply suggestions from code review Co-authored-by: Zhenhua Hu --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 2 +- .../hsm/cloud_hardware_security_module_cluster_resource_test.go | 2 +- .../hsm/custompollers/cloud_hsm_cluster_state_poller.go | 2 +- .../hsm/validate/cloud_hardware_security_module_name_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 1a31e615aa12..f139a976ea85 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package hsm diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index 5697355936a1..4db52d0523a1 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package hsm_test diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go index af3eaab7c7dd..b50153456027 100644 --- a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package custompollers diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go b/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go index 1e3067d4be09..dff11639c322 100644 --- a/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package validate From cf4634d53bd3cca4d10eb4b22dfd71406609773c Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 9 Dec 2025 14:28:40 +1100 Subject: [PATCH 19/24] update copyright --- .../hsm/validate/cloud_hardware_security_module_name.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name.go b/internal/services/hsm/validate/cloud_hardware_security_module_name.go index 996b0405321e..5ecb952f18ed 100644 --- a/internal/services/hsm/validate/cloud_hardware_security_module_name.go +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name.go @@ -1,3 +1,6 @@ +// Copyright IBM Corp. 2014, 2025 +// SPDX-License-Identifier: MPL-2.0 + package validate import ( From 16c76b310d739264292bf8243c4ab80828dacb03 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 15 Dec 2025 15:58:57 +1100 Subject: [PATCH 20/24] code format and remove unnecessary attributes --- ...rdware_security_module_cluster_resource.go | 130 +----------------- ...e_security_module_cluster_resource_test.go | 22 --- .../cloud_hsm_cluster_state_poller.go | 1 + .../cloud_hardware_security_module_name.go | 3 +- 4 files changed, 9 insertions(+), 147 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index f139a976ea85..8ed920b0cced 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -33,10 +33,9 @@ type CloudHardwareSecurityModuleClusterModel struct { Tags map[string]string `tfschema:"tags"` // Computed - ActivationState string `tfschema:"activation_state"` - Hsms []CloudHsmPropertiesModel `tfschema:"hsms"` - PrivateEndpointConnections []PrivateEndpointConnectionModel `tfschema:"private_endpoint_connections"` - StatusMessage string `tfschema:"status_message"` + ActivationState string `tfschema:"activation_state"` + Hsms []CloudHsmPropertiesModel `tfschema:"hsms"` + StatusMessage string `tfschema:"status_message"` } type CloudHsmPropertiesModel struct { @@ -45,25 +44,6 @@ type CloudHsmPropertiesModel struct { StateMessage string `tfschema:"state_message"` } -type PrivateEndpointConnectionModel struct { - Id string `tfschema:"id"` - Name string `tfschema:"name"` - Type string `tfschema:"type"` - GroupIds []string `tfschema:"group_ids"` - PrivateEndpoint []PrivateEndpointModel `tfschema:"private_endpoint"` - PrivateLinkServiceConnectionState []PrivateLinkServiceConnectionStateModel `tfschema:"private_link_service_connection_state"` -} - -type PrivateEndpointModel struct { - Id string `tfschema:"id"` -} - -type PrivateLinkServiceConnectionStateModel struct { - Status string `tfschema:"status"` - Description string `tfschema:"description"` - ActionsRequired string `tfschema:"actions_required"` -} - var _ sdk.ResourceWithUpdate = CloudHardwareSecurityModuleClusterResource{} type CloudHardwareSecurityModuleClusterResource struct{} @@ -136,66 +116,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*plu }, }, - "private_endpoint_connections": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "name": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "type": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "group_ids": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - }, - }, - "private_endpoint": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, - }, - }, - "private_link_service_connection_state": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "status": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "description": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "actions_required": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, - }, - }, - }, - }, - }, - "status_message": { Type: pluginsdk.TypeString, Computed: true, @@ -325,9 +245,9 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { model.Hsms = hsms } - if props.PrivateEndpointConnections != nil { - model.PrivateEndpointConnections = flattenPrivateEndpointConnections(props.PrivateEndpointConnections) - } + // if props.PrivateEndpointConnections != nil { + // model.PrivateEndpointConnections = flattenPrivateEndpointConnections(props.PrivateEndpointConnections) + // } } } @@ -395,7 +315,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Update() sdk.ResourceFunc { } // Use custom poller to wait for provisioning to complete - // https://github.com/Azure/azure-rest-api-specs/issues/36393 poller := custompollers.NewCloudHsmClusterStatePoller(client, *id) pollerType := pollers.NewPoller(poller, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) if err := pollerType.PollUntilDone(ctx); err != nil { @@ -444,40 +363,3 @@ func (r CloudHardwareSecurityModuleClusterResource) Delete() sdk.ResourceFunc { }, } } - -func flattenPrivateEndpointConnections(connections *[]cloudhsmclusters.PrivateEndpointConnection) []PrivateEndpointConnectionModel { - if connections == nil { - return []PrivateEndpointConnectionModel{} - } - - result := make([]PrivateEndpointConnectionModel, 0) - for _, conn := range *connections { - connModel := PrivateEndpointConnectionModel{ - Id: pointer.From(conn.Id), - Name: pointer.From(conn.Name), - Type: pointer.From(conn.Type), - } - - if conn.Properties != nil { - connModel.GroupIds = pointer.From(conn.Properties.GroupIds) - if conn.Properties.PrivateEndpoint != nil { - connModel.PrivateEndpoint = []PrivateEndpointModel{ - { - Id: pointer.From(conn.Properties.PrivateEndpoint.Id), - }, - } - } - if conn.Properties.PrivateLinkServiceConnectionState != (cloudhsmclusters.PrivateLinkServiceConnectionState{}) { - connModel.PrivateLinkServiceConnectionState = []PrivateLinkServiceConnectionStateModel{ - { - Status: string(pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Status)), - Description: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.Description), - ActionsRequired: pointer.From(conn.Properties.PrivateLinkServiceConnectionState.ActionsRequired), - }, - } - } - } - result = append(result, connModel) - } - return result -} diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index 4db52d0523a1..27b23e9e63db 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -30,7 +30,6 @@ func TestAccCloudHardwareSecurityModuleCluster_basic(t *testing.T) { ), }, data.ImportStep(), - data.RequiresImportErrorStep(r.requiresImport), }) } @@ -58,9 +57,6 @@ func TestAccCloudHardwareSecurityModuleCluster_complete(t *testing.T) { Config: r.complete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("auto_generated_domain_name_label_scope").HasValue("TenantReuse"), - check.That(data.ResourceName).Key("identity.0.type").HasValue("UserAssigned"), - check.That(data.ResourceName).Key("tags.environment").HasValue("test"), ), }, data.ImportStep(), @@ -83,7 +79,6 @@ func TestAccCloudHardwareSecurityModuleCluster_update(t *testing.T) { Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("tags.environment").HasValue("updated"), ), }, data.ImportStep(), @@ -113,7 +108,6 @@ func TestAccCloudHardwareSecurityModuleCluster_userAssignedIdentity(t *testing.T Config: r.userAssignedIdentity(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("identity.0.type").HasValue("UserAssigned"), ), }, data.ImportStep(), @@ -129,24 +123,9 @@ func TestAccCloudHardwareSecurityModuleCluster_privateEndpoint(t *testing.T) { Config: r.privateEndpoint(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("private_endpoint_connections.#").Exists(), ), }, data.ImportStep(), - { - // need another apply to read the private endpoint connection - Config: r.privateEndpoint(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("private_endpoint_connections.#").Exists(), - check.That(data.ResourceName).Key("private_endpoint_connections.0.id").Exists(), - check.That(data.ResourceName).Key("private_endpoint_connections.0.name").Exists(), - check.That(data.ResourceName).Key("private_endpoint_connections.0.type").Exists(), - check.That(data.ResourceName).Key("private_endpoint_connections.0.group_ids.#").HasValue("1"), - check.That(data.ResourceName).Key("private_endpoint_connections.0.private_endpoint.0.id").Exists(), - check.That(data.ResourceName).Key("private_endpoint_connections.0.private_link_service_connection_state.0.status").Exists(), - ), - }, }) } @@ -197,7 +176,6 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { name = "acctest-hsm-%s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - } `, r.template(data), data.RandomString) } diff --git a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go index b50153456027..87a53a1a72b9 100644 --- a/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -18,6 +18,7 @@ import ( var _ pollers.PollerType = &CloudHsmClusterStatePoller{} // CloudHsmClusterStatePoller polls until the Cloud HSM cluster has finished provisioning +// https://github.com/Azure/azure-rest-api-specs/issues/36393 type CloudHsmClusterStatePoller struct { client *cloudhsmclusters.CloudHsmClustersClient clusterId cloudhsmclusters.CloudHsmClusterId diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name.go b/internal/services/hsm/validate/cloud_hardware_security_module_name.go index 5ecb952f18ed..9178856c46cc 100644 --- a/internal/services/hsm/validate/cloud_hardware_security_module_name.go +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name.go @@ -6,6 +6,7 @@ package validate import ( "fmt" "regexp" + "strings" ) func ValidateCloudHsmClusterName(i interface{}, k string) (warnings []string, errors []error) { @@ -24,7 +25,7 @@ func ValidateCloudHsmClusterName(i interface{}, k string) (warnings []string, er } // No consecutive hyphens - if regexp.MustCompile("(--)").MatchString(v) { + if strings.Contains(v, "--") { errors = append(errors, fmt.Errorf("%q must not contain any consecutive hyphens", k)) } From 25d1a00ac7fe8352054e04ded5b1fd4fd2d2bf48 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 15 Dec 2025 16:03:31 +1100 Subject: [PATCH 21/24] rename hsms to hsm --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 8ed920b0cced..710a02e61472 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -34,7 +34,7 @@ type CloudHardwareSecurityModuleClusterModel struct { // Computed ActivationState string `tfschema:"activation_state"` - Hsms []CloudHsmPropertiesModel `tfschema:"hsms"` + HSM []CloudHsmPropertiesModel `tfschema:"hsm"` StatusMessage string `tfschema:"status_message"` } @@ -95,7 +95,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*plu Computed: true, }, - "hsms": { + "hsm": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -242,7 +242,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { } hsms = append(hsms, hsmModel) } - model.Hsms = hsms + model.HSM = hsms } // if props.PrivateEndpointConnections != nil { From 257a28b7e7bdfff430245d1ac87d7bfa2169fd49 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 15 Dec 2025 16:09:08 +1100 Subject: [PATCH 22/24] code format --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index 710a02e61472..c86c5d7d052e 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -244,10 +244,6 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { } model.HSM = hsms } - - // if props.PrivateEndpointConnections != nil { - // model.PrivateEndpointConnections = flattenPrivateEndpointConnections(props.PrivateEndpointConnections) - // } } } From 52a835948f1073505c1c9906f6755e6c052ef81c Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 16 Dec 2025 09:46:51 +1100 Subject: [PATCH 23/24] use hsms property name --- .../hsm/cloud_hardware_security_module_cluster_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index c86c5d7d052e..bb7a0da3a54a 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -34,7 +34,7 @@ type CloudHardwareSecurityModuleClusterModel struct { // Computed ActivationState string `tfschema:"activation_state"` - HSM []CloudHsmPropertiesModel `tfschema:"hsm"` + HSMs []CloudHsmPropertiesModel `tfschema:"hsms"` StatusMessage string `tfschema:"status_message"` } @@ -95,7 +95,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*plu Computed: true, }, - "hsm": { + "hsms": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -242,7 +242,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { } hsms = append(hsms, hsmModel) } - model.HSM = hsms + model.HSMs = hsms } } } From 9064c660a22fbdbaa64bc580bd8640622f8b7abf Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 26 Mar 2026 10:28:26 +1100 Subject: [PATCH 24/24] naming, format and remove unused properties --- ...rdware_security_module_cluster_resource.go | 54 +++++-------------- ...e_security_module_cluster_resource_test.go | 4 +- ...ware_security_module_cluster.html.markdown | 48 ++--------------- 3 files changed, 19 insertions(+), 87 deletions(-) diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go index bb7a0da3a54a..7058ad45f221 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -25,23 +25,19 @@ import ( // Resource Model type CloudHardwareSecurityModuleClusterModel struct { - Name string `tfschema:"name"` - ResourceGroupName string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` - Identity []identity.ModelUserAssigned `tfschema:"identity"` - AutoGeneratedDomainNameLabelScope string `tfschema:"auto_generated_domain_name_label_scope"` - Tags map[string]string `tfschema:"tags"` + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Identity []identity.ModelUserAssigned `tfschema:"identity"` + DomainNameReuse string `tfschema:"domain_name_reuse"` + Tags map[string]string `tfschema:"tags"` // Computed - ActivationState string `tfschema:"activation_state"` - HSMs []CloudHsmPropertiesModel `tfschema:"hsms"` - StatusMessage string `tfschema:"status_message"` + HardwareSecurityModules []CloudHsmPropertiesModel `tfschema:"hardware_security_module"` } type CloudHsmPropertiesModel struct { - Fqdn string `tfschema:"fqdn"` - State string `tfschema:"state"` - StateMessage string `tfschema:"state_message"` + Fqdn string `tfschema:"fqdn"` } var _ sdk.ResourceWithUpdate = CloudHardwareSecurityModuleClusterResource{} @@ -73,7 +69,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*plug "location": commonschema.Location(), - "auto_generated_domain_name_label_scope": { + "domain_name_reuse": { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, @@ -90,12 +86,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Arguments() map[string]*plug func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ - "activation_state": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "hsms": { + "hardware_security_module": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -104,22 +95,9 @@ func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*plu Type: pluginsdk.TypeString, Computed: true, }, - "state": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "state_message": { - Type: pluginsdk.TypeString, - Computed: true, - }, }, }, }, - - "status_message": { - Type: pluginsdk.TypeString, - Computed: true, - }, } } @@ -154,7 +132,7 @@ func (r CloudHardwareSecurityModuleClusterResource) Create() sdk.ResourceFunc { // Capacity is intentionally left unset as the API does not support it }, Properties: &cloudhsmclusters.CloudHsmClusterProperties{ - AutoGeneratedDomainNameLabelScope: pointer.ToEnum[cloudhsmclusters.AutoGeneratedDomainNameLabelScope](model.AutoGeneratedDomainNameLabelScope), + AutoGeneratedDomainNameLabelScope: pointer.ToEnum[cloudhsmclusters.AutoGeneratedDomainNameLabelScope](model.DomainNameReuse), }, } @@ -228,21 +206,17 @@ func (r CloudHardwareSecurityModuleClusterResource) Read() sdk.ResourceFunc { } if props := m.Properties; props != nil { - model.ActivationState = string(pointer.From(props.ActivationState)) - model.AutoGeneratedDomainNameLabelScope = string(pointer.From(props.AutoGeneratedDomainNameLabelScope)) - model.StatusMessage = pointer.From(props.StatusMessage) + model.DomainNameReuse = string(pointer.From(props.AutoGeneratedDomainNameLabelScope)) if props.Hsms != nil { hsms := make([]CloudHsmPropertiesModel, 0) for _, hsm := range *props.Hsms { hsmModel := CloudHsmPropertiesModel{ - Fqdn: pointer.From(hsm.Fqdn), - State: pointer.From(hsm.State), - StateMessage: pointer.From(hsm.StateMessage), + Fqdn: pointer.From(hsm.Fqdn), } hsms = append(hsms, hsmModel) } - model.HSMs = hsms + model.HardwareSecurityModules = hsms } } } diff --git a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go index 27b23e9e63db..35702ec250fe 100644 --- a/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -204,7 +204,7 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { identity_ids = [azurerm_user_assigned_identity.test.id] } - auto_generated_domain_name_label_scope = "TenantReuse" + domain_name_reuse = "TenantReuse" tags = { environment = "test" @@ -344,7 +344,7 @@ resource "azurerm_cloud_hardware_security_module_cluster" "test" { identity_ids = [azurerm_user_assigned_identity.test.id] } - auto_generated_domain_name_label_scope = "TenantReuse" + domain_name_reuse = "TenantReuse" tags = { environment = "test" diff --git a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown index 7069356365cb..0052b855deaf 100644 --- a/website/docs/r/cloud_hardware_security_module_cluster.html.markdown +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -43,7 +43,7 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. -* `auto_generated_domain_name_label_scope` - (Optional) Specifies the scope for auto-generated domain name labels. Possible values are `TenantReuse`, `SubscriptionReuse`, `ResourceGroupReuse`, and `NoReuse`. Defaults to `TenantReuse`. Changing this forces a new resource to be created. +* `domain_name_reuse` - (Optional) Specifies the scope for auto-generated domain name labels. Possible values are `TenantReuse`, `SubscriptionReuse`, `ResourceGroupReuse`, and `NoReuse`. Defaults to `TenantReuse`. Changing this forces a new resource to be created. * `tags` - (Optional) A mapping of tags to assign to the Cloud Hardware Security Module Cluster. @@ -61,56 +61,14 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Cloud Hardware Security Module Cluster. -* `activation_state` - The activation state of the Cloud Hardware Security Module Cluster. - -* `hsms` - A list of `hsms` blocks as defined below. - -* `private_endpoint_connections` - A list of `private_endpoint_connections` blocks as defined below. - -* `status_message` - The status message of the Cloud Hardware Security Module Cluster. +* `hardware_security_module` - A list of `hardware_security_module` blocks as defined below. --- -A `hsms` block exports the following: +A `hardware_security_module` block exports the following: * `fqdn` - The fully qualified domain name of the HSM instance. -* `state` - The state of the HSM instance. - -* `state_message` - The state message of the HSM instance. - ---- - -A `private_endpoint_connections` block exports the following: - -* `id` - The ID of the private endpoint connection. - -* `name` - The name of the private endpoint connection. - -* `group_ids` - A list of group IDs for the private endpoint connection. - -* `private_endpoint` - A `private_endpoint` block as defined below. - -* `private_link_service_connection_state` - A `private_link_service_connection_state` block as defined below. - -* `type` - The type of the private endpoint connection. - ---- - -A `private_endpoint` block exports the following: - -* `id` - The ID of the private endpoint. - ---- - -A `private_link_service_connection_state` block exports the following: - -* `actions_required` - The actions required for the private link service connection. - -* `description` - The description of the private link service connection state. - -* `status` - The status of the private link service connection. - ## Timeouts The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: