diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 9bef90c14a49..b7bf10ddaf41 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)*)###' diff --git a/internal/provider/services.go b/internal/provider/services.go index ba4384148187..b0b718b79ef0 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -182,6 +182,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 96ada1443509..8f2aca04372e 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..7058ad45f221 --- /dev/null +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource.go @@ -0,0 +1,335 @@ +// Copyright IBM Corp. 2014, 2025 +// SPDX-License-Identifier: MPL-2.0 + +package hsm + +import ( + "context" + "errors" + "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-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"` + DomainNameReuse string `tfschema:"domain_name_reuse"` + Tags map[string]string `tfschema:"tags"` + + // Computed + HardwareSecurityModules []CloudHsmPropertiesModel `tfschema:"hardware_security_module"` +} + +type CloudHsmPropertiesModel struct { + Fqdn string `tfschema:"fqdn"` +} + +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(), + + "domain_name_reuse": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + Default: string(cloudhsmclusters.AutoGeneratedDomainNameLabelScopeTenantReuse), + 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(), + } +} + +func (r CloudHardwareSecurityModuleClusterResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "hardware_security_module": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "fqdn": { + 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), + Sku: &cloudhsmclusters.CloudHsmClusterSku{ + Name: cloudhsmclusters.CloudHsmClusterSkuNameStandardBOne, + Family: cloudhsmclusters.CloudHsmClusterSkuFamilyB, + // Capacity is intentionally left unset as the API does not support it + }, + Properties: &cloudhsmclusters.CloudHsmClusterProperties{ + AutoGeneratedDomainNameLabelScope: pointer.ToEnum[cloudhsmclusters.AutoGeneratedDomainNameLabelScope](model.DomainNameReuse), + }, + } + + 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 { + 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 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 = pointer.From(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 { + 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), + } + hsms = append(hsms, hsmModel) + } + model.HardwareSecurityModules = hsms + } + } + } + + 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) + } + + exists, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + if exists.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + 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) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + // Convert to LegacySystemAndUserAssignedMap since the SDK uses the legacy type + legacyIdentity := &identity.LegacySystemAndUserAssignedMap{ + Type: expandedIdentity.Type, + IdentityIds: expandedIdentity.IdentityIds, + } + 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 { + cluster.Tags = pointer.To(map[string]string{}) + } else { + cluster.Tags = pointer.To(model.Tags) + } + } + + // Initiate the update operation + err = client.CreateOrUpdateThenPoll(ctx, *id, cluster) + if err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + // Use custom poller to wait for provisioning to complete + 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 + } + + // the deletion of Cloud HSM may return 409 if the linked Private Endpoint is deleted recently + deadline, ok := ctx.Deadline() + if !ok { + return errors.New("internal-error: context had no 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) + } + + return nil + }, + } +} 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..35702ec250fe --- /dev/null +++ b/internal/services/hsm/cloud_hardware_security_module_cluster_resource_test.go @@ -0,0 +1,369 @@ +// Copyright IBM Corp. 2014, 2025 +// SPDX-License-Identifier: MPL-2.0 + +package hsm_test + +import ( + "context" + "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" +) + +type CloudHardwareSecurityModuleClusterResource struct{} + +func TestAccCloudHardwareSecurityModuleCluster_basic(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(), + }) +} + +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), + ), + }, + 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), + ), + }, + 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(), + }) +} + +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), + ), + }, + 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), + ), + }, + data.ImportStep(), + }) +} + +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 pointer.To(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(` +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(` +provider "azurerm" { + features {} +} + +%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(` +provider "azurerm" { + features {} +} + +%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] + } + + domain_name_reuse = "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(` +provider "azurerm" { + features {} +} + +%[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) 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" { + features {} +} + +%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(` +provider "azurerm" { + features {} +} + +%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] + } + + domain_name_reuse = "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..87a53a1a72b9 --- /dev/null +++ b/internal/services/hsm/custompollers/cloud_hsm_cluster_state_poller.go @@ -0,0 +1,74 @@ +// Copyright IBM Corp. 2014, 2025 +// 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 +// https://github.com/Azure/azure-rest-api-specs/issues/36393 +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 { + statusMessage = strings.ToLower(strings.TrimSpace(pointer.From(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 3567e07408b5..5b8999649ea6 100644 --- a/internal/services/hsm/registration.go +++ b/internal/services/hsm/registration.go @@ -13,8 +13,9 @@ import ( type Registration struct{} var ( - _ sdk.FrameworkServiceRegistration = Registration{} _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} + _ sdk.TypedServiceRegistration = Registration{} + _ sdk.FrameworkServiceRegistration = Registration{} ) func (r Registration) AssociatedGitHubLabel() string { @@ -45,6 +46,18 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { } } +// 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{} +} + func (r Registration) Actions() []func() action.Action { return []func() action.Action{} } diff --git a/internal/services/hsm/validate/cloud_hardware_security_module_name.go b/internal/services/hsm/validate/cloud_hardware_security_module_name.go new file mode 100644 index 000000000000..9178856c46cc --- /dev/null +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name.go @@ -0,0 +1,33 @@ +// Copyright IBM Corp. 2014, 2025 +// SPDX-License-Identifier: MPL-2.0 + +package validate + +import ( + "fmt" + "regexp" + "strings" +) + +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 strings.Contains(v, "--") { + errors = append(errors, fmt.Errorf("%q must not contain any consecutive hyphens", k)) + } + + return +} 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..dff11639c322 --- /dev/null +++ b/internal/services/hsm/validate/cloud_hardware_security_module_name_test.go @@ -0,0 +1,115 @@ +// Copyright IBM Corp. 2014, 2025 +// 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)) + } + } +} 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 55ada82654f2..997703d97e18 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -607,6 +607,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/2024-04-05/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..0052b855deaf --- /dev/null +++ b/website/docs/r/cloud_hardware_security_module_cluster.html.markdown @@ -0,0 +1,93 @@ +--- +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. + +* `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. + +--- + +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. + +* `hardware_security_module` - A list of `hardware_security_module` blocks as defined below. + +--- + +A `hardware_security_module` block exports the following: + +* `fqdn` - The fully qualified domain name of the HSM instance. + +## Timeouts + +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. +* `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 + +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 +``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.HardwareSecurityModules` - 2025-03-31