From 07c9c35269e2d0253022f14c2c33f258fbe7c69c Mon Sep 17 00:00:00 2001 From: elena Date: Tue, 11 Apr 2023 18:03:51 +0800 Subject: [PATCH 1/7] fix issue 21363 --- internal/resourceproviders/required.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/resourceproviders/required.go b/internal/resourceproviders/required.go index 88530054ef70..eef1a28b0c5b 100644 --- a/internal/resourceproviders/required.go +++ b/internal/resourceproviders/required.go @@ -70,7 +70,6 @@ func Required() map[string]struct{} { "Microsoft.ServiceFabric": {}, "Microsoft.Sql": {}, "Microsoft.Storage": {}, - "Microsoft.StorageMover": {}, "Microsoft.StreamAnalytics": {}, "Microsoft.TimeSeriesInsights": {}, "Microsoft.Web": {}, From 76db65b7356a6209d3314e2e181831fab347f81f Mon Sep 17 00:00:00 2001 From: elena Date: Tue, 4 Apr 2023 11:08:41 +0800 Subject: [PATCH 2/7] support new resource azurerm_storage_mover_agent --- .../services/storagemover/client/client.go | 9 + .../services/storagemover/registration.go | 1 + .../storage_mover_agent_resource.go | 231 ++++++++++++++++++ .../storage_mover_agent_resource_test.go | 180 ++++++++++++++ .../storage_mover_source_endpoint_resource.go | 231 ++++++++++++++++++ ...age_mover_source_endpoint_resource_test.go | 171 +++++++++++++ .../storage_mover_target_endpoint_resource.go | 225 +++++++++++++++++ ...age_mover_target_endpoint_resource_test.go | 171 +++++++++++++ .../storagemover/2023-03-01/agents/README.md | 107 ++++++++ .../storagemover/2023-03-01/agents/client.go | 26 ++ .../2023-03-01/agents/constants.go | 71 ++++++ .../2023-03-01/agents/id_agent.go | 140 +++++++++++ .../2023-03-01/agents/id_storagemover.go | 127 ++++++++++ .../agents/method_createorupdate.go | 55 +++++ .../2023-03-01/agents/method_delete.go | 71 ++++++ .../2023-03-01/agents/method_get.go | 51 ++++ .../2023-03-01/agents/method_list.go | 89 +++++++ .../2023-03-01/agents/method_update.go | 55 +++++ .../2023-03-01/agents/model_agent.go | 16 ++ .../agents/model_agentproperties.go | 37 +++ .../model_agentpropertieserrordetails.go | 9 + .../agents/model_agentupdateparameters.go | 8 + .../agents/model_agentupdateproperties.go | 8 + .../2023-03-01/agents/predicates.go | 27 ++ .../storagemover/2023-03-01/agents/version.go | 12 + .../2023-03-01/endpoints/README.md | 107 ++++++++ .../2023-03-01/endpoints/client.go | 26 ++ .../2023-03-01/endpoints/constants.go | 90 +++++++ .../2023-03-01/endpoints/id_endpoint.go | 140 +++++++++++ .../2023-03-01/endpoints/id_storagemover.go | 127 ++++++++++ .../endpoints/method_createorupdate.go | 55 +++++ .../2023-03-01/endpoints/method_delete.go | 71 ++++++ .../2023-03-01/endpoints/method_get.go | 51 ++++ .../2023-03-01/endpoints/method_list.go | 89 +++++++ .../2023-03-01/endpoints/method_update.go | 55 +++++ ...estorageblobcontainerendpointproperties.go | 44 ++++ .../2023-03-01/endpoints/model_endpoint.go | 48 ++++ .../endpoints/model_endpointbaseproperties.go | 56 +++++ .../model_endpointbaseupdateparameters.go | 8 + .../model_endpointbaseupdateproperties.go | 8 + .../model_nfsmountendpointproperties.go | 45 ++++ .../2023-03-01/endpoints/predicates.go | 27 ++ .../2023-03-01/endpoints/version.go | 12 + vendor/modules.txt | 2 + .../docs/r/storage_mover_agent.html.markdown | 70 ++++++ .../r/storage_mover_endpoint.html.markdown | 70 ++++++ 46 files changed, 3329 insertions(+) create mode 100644 internal/services/storagemover/storage_mover_agent_resource.go create mode 100644 internal/services/storagemover/storage_mover_agent_resource_test.go create mode 100644 internal/services/storagemover/storage_mover_source_endpoint_resource.go create mode 100644 internal/services/storagemover/storage_mover_source_endpoint_resource_test.go create mode 100644 internal/services/storagemover/storage_mover_target_endpoint_resource.go create mode 100644 internal/services/storagemover/storage_mover_target_endpoint_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_agent.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_storagemover.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agent.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentpropertieserrordetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go create mode 100644 website/docs/r/storage_mover_agent.html.markdown create mode 100644 website/docs/r/storage_mover_endpoint.html.markdown diff --git a/internal/services/storagemover/client/client.go b/internal/services/storagemover/client/client.go index 23cbe0cd6845..1f0c8e084203 100644 --- a/internal/services/storagemover/client/client.go +++ b/internal/services/storagemover/client/client.go @@ -3,12 +3,14 @@ package client import ( "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents" "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { StorageMoversClient *storagemovers.StorageMoversClient + AgentsClient *agents.AgentsClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -18,7 +20,14 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(storageMoversClient.Client, o.Authorizers.ResourceManager) + agentsClient, err := agents.NewAgentsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building agent client: %+v", err) + } + o.Configure(agentsClient.Client, o.Authorizers.ResourceManager) + return &Client{ StorageMoversClient: storageMoversClient, + AgentsClient: agentsClient, }, nil } diff --git a/internal/services/storagemover/registration.go b/internal/services/storagemover/registration.go index 4036695732c0..c256bdb3abf2 100644 --- a/internal/services/storagemover/registration.go +++ b/internal/services/storagemover/registration.go @@ -31,5 +31,6 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ StorageMoverResource{}, + StorageMoverAgentResource{}, } } diff --git a/internal/services/storagemover/storage_mover_agent_resource.go b/internal/services/storagemover/storage_mover_agent_resource.go new file mode 100644 index 000000000000..74b4a7f1fa8c --- /dev/null +++ b/internal/services/storagemover/storage_mover_agent_resource.go @@ -0,0 +1,231 @@ +package storagemover + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + computevalidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type StorageMoverAgentResourceModel struct { + Name string `tfschema:"name"` + StorageMoverId string `tfschema:"storage_mover_id"` + ArcResourceId string `tfschema:"arc_resource_id"` + ArcVmUuid string `tfschema:"arc_vm_uuid"` + Description string `tfschema:"description"` +} + +type StorageMoverAgentResource struct{} + +var _ sdk.ResourceWithUpdate = StorageMoverAgentResource{} + +func (r StorageMoverAgentResource) ResourceType() string { + return "azurerm_storage_mover_agent" +} + +func (r StorageMoverAgentResource) ModelObject() interface{} { + return &StorageMoverAgentResourceModel{} +} + +func (r StorageMoverAgentResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return agents.ValidateAgentID +} + +func (r StorageMoverAgentResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "arc_resource_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: computevalidate.HybridMachineID, + }, + + "arc_vm_uuid": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.IsUUID, + }, + + "storage_mover_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: storagemovers.ValidateStorageMoverID, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } +} + +func (r StorageMoverAgentResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r StorageMoverAgentResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model StorageMoverAgentResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.StorageMover.AgentsClient + storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) + if err != nil { + return err + } + + id := agents.NewAgentID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, 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) + } + + properties := agents.Agent{ + Properties: agents.AgentProperties{ + ArcResourceId: model.ArcResourceId, + ArcVMUuid: model.ArcVmUuid, + }, + } + + if model.Description != "" { + properties.Properties.Description = &model.Description + } + + if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r StorageMoverAgentResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.AgentsClient + + id, err := agents.ParseAgentID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model StorageMoverAgentResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + if metadata.ResourceData.HasChange("description") { + properties.Properties.Description = &model.Description + } + + if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r StorageMoverAgentResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.AgentsClient + + id, err := agents.ParseAgentID(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 := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + state := StorageMoverAgentResourceModel{ + Name: id.AgentName, + StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), + } + + properties := &model.Properties + + state.ArcVmUuid = properties.ArcVMUuid + + des := "" + if properties.Description != nil { + des = *properties.Description + } + state.Description = des + + return metadata.Encode(&state) + }, + } +} + +func (r StorageMoverAgentResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.AgentsClient + + id, err := agents.ParseAgentID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go new file mode 100644 index 000000000000..f2187c194e18 --- /dev/null +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -0,0 +1,180 @@ +package storagemover_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type StorageMoverAgentTestResource struct{} + +func TestAccStorageMoverAgent_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_agent", "test") + r := StorageMoverAgentTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverAgent_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_agent", "test") + r := StorageMoverAgentTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccStorageMoverAgent_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_agent", "test") + r := StorageMoverAgentTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverAgent_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_agent", "test") + r := StorageMoverAgentTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(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(), + }) +} + +func (r StorageMoverAgentTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := agents.ParseAgentID(state.ID) + if err != nil { + return nil, err + } + + client := clients.StorageMover.AgentsClient + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func (r StorageMoverAgentTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} + +resource "azurerm_storage_mover" "test" { + name = "acctest-ssm-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (r StorageMoverAgentTestResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + +%s + +resource "azurerm_storage_mover_agent" "test" { + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverAgentTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + +%s + +resource "azurerm_storage_mover_agent" "import" { + name = azurerm_storage_mover_agent.test.name + storage_mover_id = azurerm_storage_mover_agent.test.storage_mover_id + arc_resource_id = azurerm_storage_mover_agent.test.arc_resource_id + arc_vm_uuid = azurerm_storage_mover_agent.test.arc_vm_uuid +} +`, config) +} + +func (r StorageMoverAgentTestResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + +%s + +resource "azurerm_storage_mover_agent" "test" { + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + description = "Example Agent Description" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverAgentTestResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + +%s + +resource "azurerm_storage_mover_agent" "test" { + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + description = "Update Example Agent Description" + +} +`, template, data.RandomInteger) +} diff --git a/internal/services/storagemover/storage_mover_source_endpoint_resource.go b/internal/services/storagemover/storage_mover_source_endpoint_resource.go new file mode 100644 index 000000000000..35f2d9524378 --- /dev/null +++ b/internal/services/storagemover/storage_mover_source_endpoint_resource.go @@ -0,0 +1,231 @@ +package storagemover + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-provider-azurerm/utils" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type StorageMoverSourceEndpointResourceModel struct { + Name string `tfschema:"name"` + StorageMoverId string `tfschema:"storage_mover_id"` + Host string `tfschema:"host"` + Export string `tfschema:"export"` + NfsVersion endpoints.NfsVersion `tfschema:"nfs_version"` + Description string `tfschema:"description"` +} + +type StorageMoverSourceEndpointResource struct{} + +var _ sdk.ResourceWithUpdate = StorageMoverSourceEndpointResourceModel{} + +func (r StorageMoverSourceEndpointResourceModel) ResourceType() string { + return "azurerm_storagemover_endpoint" +} + +func (r StorageMoverSourceEndpointResourceModel) ModelObject() interface{} { + return &StorageMoverSourceEndpointResourceModel{} +} + +func (r StorageMoverSourceEndpointResourceModel) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return endpoints.ValidateEndpointID +} + +func (r StorageMoverSourceEndpointResourceModel) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "storage_mover_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: storagemovers.ValidateStorageMoverID, + }, + + "host": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "export": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "nfs_version": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } +} + +func (r StorageMoverSourceEndpointResourceModel) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r StorageMoverSourceEndpointResourceModel) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model StorageMoverSourceEndpointResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.StorageMover.EndpointsClient + storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) + if err != nil { + return err + } + + id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, 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) + } + + properties := endpoints.Endpoint{ + Name: utils.String(model.Name), + Type: utils.String(string(endpoints.EndpointTypeNfsMount)), + Properties: endpoints.NfsMountEndpointProperties{ + Export: model.Export, + Host: model.Host, + NfsVersion: &model.NfsVersion, + Description: &model.Description, + }, + } + + if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r StorageMoverSourceEndpointResourceModel) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model StorageMoverSourceEndpointResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r StorageMoverSourceEndpointResourceModel) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(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 := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + state := StorageMoverSourceEndpointResourceModel{ + Name: id.EndpointName, + StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), + } + + properties := endpoints.NfsMountEndpointProperties{} + properties = model.Properties + if properties != nil { + state.Description = *properties.Description + } + + state.EndpointType = properties.EndpointType + + return metadata.Encode(&state) + }, + } +} + +func (r StorageMoverSourceEndpointResourceModel) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} diff --git a/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go b/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go new file mode 100644 index 000000000000..9b0fecee424f --- /dev/null +++ b/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go @@ -0,0 +1,171 @@ +package storagemover_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type StorageMoverSourceEndpointTestResource struct{} + +func TestAccstoragemoverEndpoint_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverSourceEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccstoragemoverEndpoint_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverSourceEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccstoragemoverEndpoint_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverSourceEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccstoragemoverEndpoint_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverSourceEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(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(), + }) +} + +func (r StorageMoverSourceEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := endpoints.ParseEndpointID(state.ID) + if err != nil { + return nil, err + } + + client := clients.storagemover.EndpointsClient + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func (r StorageMoverSourceEndpointTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} +resource "azurerm_storagemover_storage_mover" "test" { + name = "acctest-ssm-%d" + resource_group_name = azurerm_resource_group.test.name +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (r StorageMoverSourceEndpointTestResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + endpoint_type = "" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverSourceEndpointTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "import" { + name = azurerm_storagemover_endpoint.test.name + StorageMoverId = azurerm_storagemover_storage_mover.test.id + endpoint_type = "" +} +`, config) +} + +func (r StorageMoverSourceEndpointTestResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + description = "" + endpoint_type = "" + +} +`, template, data.RandomInteger) +} + +func (r StorageMoverSourceEndpointTestResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + description = "" + endpoint_type = "" + +} +`, template, data.RandomInteger) +} diff --git a/internal/services/storagemover/storage_mover_target_endpoint_resource.go b/internal/services/storagemover/storage_mover_target_endpoint_resource.go new file mode 100644 index 000000000000..712ba0249cd3 --- /dev/null +++ b/internal/services/storagemover/storage_mover_target_endpoint_resource.go @@ -0,0 +1,225 @@ +package storagemover + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-provider-azurerm/utils" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type StorageMoverTargetEndpointResourceModel struct { + Name string `tfschema:"name"` + StorageMoverId string `tfschema:"storage_mover_id"` + EndpointType endpoints.EndpointType `tfschema:"endpoint_type"` + Description string `tfschema:"description"` + BlobContainerName string `tfschema:"blob_container_name"` + StorageAccountId string `tfschema:"storage_account_id"` + Host string `tfschema:"host"` + Export string `tfschema:"export"` + NfsVersion string `tfschema:"nfs_version"` +} + +type StorageMoverTargetEndpointResource struct{} + +var _ sdk.ResourceWithUpdate = StorageMoverTargetEndpointResource{} + +func (r StorageMoverTargetEndpointResource) ResourceType() string { + return "azurerm_storagemover_endpoint" +} + +func (r StorageMoverTargetEndpointResource) ModelObject() interface{} { + return &StorageMoverTargetEndpointResourceModel{} +} + +func (r StorageMoverTargetEndpointResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return endpoints.ValidateEndpointID +} + +func (r StorageMoverTargetEndpointResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "endpoint_type": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(endpoints.EndpointTypeAzureStorageBlobContainer), + string(endpoints.EndpointTypeNfsMount), + }, false), + }, + + "storage_mover_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: storagemovers.ValidateStorageMoverID, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } +} + +func (r StorageMoverTargetEndpointResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r StorageMoverTargetEndpointResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model StorageMoverTargetEndpointResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.StorageMover.EndpointsClient + storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) + if err != nil { + return err + } + + id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, 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) + } + + properties := endpoints.Endpoint{ + Name: utils.String(model.Name), + Type: utils.String(string(model.EndpointType)), + } + + if model.EndpointType == endpoints.EndpointTypeAzureStorageBlobContainer { + properties.Properties = endpoints.AzureStorageBlobContainerEndpointProperties{} + } else if model.EndpointType == endpoints.EndpointTypeNfsMount { + properties.Properties = endpoints.NfsMountEndpointProperties{} + } + + if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r StorageMoverTargetEndpointResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model StorageMoverTargetEndpointResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r StorageMoverTargetEndpointResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(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 := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + state := StorageMoverTargetEndpointResourceModel{ + Name: id.EndpointName, + StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), + } + + properties := &model.Properties + if properties.Description != nil { + state.Description = *properties.Description + } + + state.EndpointType = properties.EndpointType + + return metadata.Encode(&state) + }, + } +} + +func (r StorageMoverTargetEndpointResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.EndpointsClient + + id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} diff --git a/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go b/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go new file mode 100644 index 000000000000..ab4186effaa4 --- /dev/null +++ b/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go @@ -0,0 +1,171 @@ +package storagemover_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type StorageMoverTargetEndpointTestResource struct{} + +func TestAccstoragemoverEndpoint_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverTargetEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccstoragemoverEndpoint_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverTargetEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccstoragemoverEndpoint_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverTargetEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccstoragemoverEndpoint_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") + r := StorageMoverTargetEndpointTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(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(), + }) +} + +func (r StorageMoverTargetEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := endpoints.ParseEndpointID(state.ID) + if err != nil { + return nil, err + } + + client := clients.storagemover.EndpointsClient + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Model != nil), nil +} + +func (r StorageMoverTargetEndpointTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} +resource "azurerm_storagemover_storage_mover" "test" { + name = "acctest-ssm-%d" + resource_group_name = azurerm_resource_group.test.name +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (r StorageMoverTargetEndpointTestResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + endpoint_type = "" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverTargetEndpointTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "import" { + name = azurerm_storagemover_endpoint.test.name + StorageMoverId = azurerm_storagemover_storage_mover.test.id + endpoint_type = "" +} +`, config) +} + +func (r StorageMoverTargetEndpointTestResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + description = "" + endpoint_type = "" + +} +`, template, data.RandomInteger) +} + +func (r StorageMoverTargetEndpointTestResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_storagemover_endpoint" "test" { + name = "acctest-se-%d" + StorageMoverId = azurerm_storagemover_storage_mover.test.id + description = "" + endpoint_type = "" + +} +`, template, data.RandomInteger) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/README.md new file mode 100644 index 000000000000..cd62e7c1955f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents` Documentation + +The `agents` SDK allows for interaction with the Azure Resource Manager Service `storagemover` (API Version `2023-03-01`). + +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-sdk/resource-manager/storagemover/2023-03-01/agents" +``` + + +### Client Initialization + +```go +client := agents.NewAgentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AgentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := agents.NewAgentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "agentValue") + +payload := agents.Agent{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentsClient.Delete` + +```go +ctx := context.TODO() +id := agents.NewAgentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "agentValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentsClient.Get` + +```go +ctx := context.TODO() +id := agents.NewAgentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "agentValue") + +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: `AgentsClient.List` + +```go +ctx := context.TODO() +id := agents.NewStorageMoverID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AgentsClient.Update` + +```go +ctx := context.TODO() +id := agents.NewAgentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "agentValue") + +payload := agents.AgentUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/client.go new file mode 100644 index 000000000000..73edd0c7f0cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/client.go @@ -0,0 +1,26 @@ +package agents + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AgentsClient struct { + Client *resourcemanager.Client +} + +func NewAgentsClientWithBaseURI(api environments.Api) (*AgentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "agents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AgentsClient: %+v", err) + } + + return &AgentsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go new file mode 100644 index 000000000000..9566d6a15388 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go @@ -0,0 +1,71 @@ +package agents + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentStatus string + +const ( + AgentStatusExecuting AgentStatus = "Executing" + AgentStatusOffline AgentStatus = "Offline" + AgentStatusOnline AgentStatus = "Online" + AgentStatusRegistering AgentStatus = "Registering" + AgentStatusRequiresAttention AgentStatus = "RequiresAttention" + AgentStatusUnregistering AgentStatus = "Unregistering" +) + +func PossibleValuesForAgentStatus() []string { + return []string{ + string(AgentStatusExecuting), + string(AgentStatusOffline), + string(AgentStatusOnline), + string(AgentStatusRegistering), + string(AgentStatusRequiresAttention), + string(AgentStatusUnregistering), + } +} + +func parseAgentStatus(input string) (*AgentStatus, error) { + vals := map[string]AgentStatus{ + "executing": AgentStatusExecuting, + "offline": AgentStatusOffline, + "online": AgentStatusOnline, + "registering": AgentStatusRegistering, + "requiresattention": AgentStatusRequiresAttention, + "unregistering": AgentStatusUnregistering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "succeeded": ProvisioningStateSucceeded, + } + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_agent.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_agent.go new file mode 100644 index 000000000000..b6717c48222a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_agent.go @@ -0,0 +1,140 @@ +package agents + +import ( + "fmt" + "strings" + + "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. + +var _ resourceids.ResourceId = AgentId{} + +// AgentId is a struct representing the Resource ID for a Agent +type AgentId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string + AgentName string +} + +// NewAgentID returns a new AgentId struct +func NewAgentID(subscriptionId string, resourceGroupName string, storageMoverName string, agentName string) AgentId { + return AgentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + AgentName: agentName, + } +} + +// ParseAgentID parses 'input' into a AgentId +func ParseAgentID(input string) (*AgentId, error) { + parser := resourceids.NewParserFromResourceIdType(AgentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AgentId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + if id.AgentName, ok = parsed.Parsed["agentName"]; !ok { + return nil, fmt.Errorf("the segment 'agentName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAgentIDInsensitively parses 'input' case-insensitively into a AgentId +// note: this method should only be used for API response data and not user input +func ParseAgentIDInsensitively(input string) (*AgentId, error) { + parser := resourceids.NewParserFromResourceIdType(AgentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AgentId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + if id.AgentName, ok = parsed.Parsed["agentName"]; !ok { + return nil, fmt.Errorf("the segment 'agentName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAgentID checks that 'input' can be parsed as a Agent ID +func ValidateAgentID(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 := ParseAgentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Agent ID +func (id AgentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s/agents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.AgentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Agent ID +func (id AgentId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), + resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), + resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), + resourceids.StaticSegment("staticAgents", "agents", "agents"), + resourceids.UserSpecifiedSegment("agentName", "agentValue"), + } +} + +// String returns a human-readable description of this Agent ID +func (id AgentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), + fmt.Sprintf("Agent Name: %q", id.AgentName), + } + return fmt.Sprintf("Agent (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_storagemover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_storagemover.go new file mode 100644 index 000000000000..bbc7fe68459c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/id_storagemover.go @@ -0,0 +1,127 @@ +package agents + +import ( + "fmt" + "strings" + + "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. + +var _ resourceids.ResourceId = StorageMoverId{} + +// StorageMoverId is a struct representing the Resource ID for a Storage Mover +type StorageMoverId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string +} + +// NewStorageMoverID returns a new StorageMoverId struct +func NewStorageMoverID(subscriptionId string, resourceGroupName string, storageMoverName string) StorageMoverId { + return StorageMoverId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + } +} + +// ParseStorageMoverID parses 'input' into a StorageMoverId +func ParseStorageMoverID(input string) (*StorageMoverId, error) { + parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := StorageMoverId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseStorageMoverIDInsensitively parses 'input' case-insensitively into a StorageMoverId +// note: this method should only be used for API response data and not user input +func ParseStorageMoverIDInsensitively(input string) (*StorageMoverId, error) { + parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := StorageMoverId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateStorageMoverID checks that 'input' can be parsed as a Storage Mover ID +func ValidateStorageMoverID(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 := ParseStorageMoverID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Mover ID +func (id StorageMoverId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Mover ID +func (id StorageMoverId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), + resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), + resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), + } +} + +// String returns a human-readable description of this Storage Mover ID +func (id StorageMoverId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), + } + return fmt.Sprintf("Storage Mover (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_createorupdate.go new file mode 100644 index 000000000000..fc639f8882af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_createorupdate.go @@ -0,0 +1,55 @@ +package agents + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Agent +} + +// CreateOrUpdate ... +func (c AgentsClient) CreateOrUpdate(ctx context.Context, id AgentId, input Agent) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_delete.go new file mode 100644 index 000000000000..c6a72a852cd1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_delete.go @@ -0,0 +1,71 @@ +package agents + +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 AgentsClient) Delete(ctx context.Context, id AgentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AgentsClient) DeleteThenPoll(ctx context.Context, id AgentId) 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/storagemover/2023-03-01/agents/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_get.go new file mode 100644 index 000000000000..cfce7b6c485d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_get.go @@ -0,0 +1,51 @@ +package agents + +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 *Agent +} + +// Get ... +func (c AgentsClient) Get(ctx context.Context, id AgentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_list.go new file mode 100644 index 000000000000..5e56d8972a32 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_list.go @@ -0,0 +1,89 @@ +package agents + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Agent +} + +type ListCompleteResult struct { + Items []Agent +} + +// List ... +func (c AgentsClient) List(ctx context.Context, id StorageMoverId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/agents", 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 *[]Agent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AgentsClient) ListComplete(ctx context.Context, id StorageMoverId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AgentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AgentsClient) ListCompleteMatchingPredicate(ctx context.Context, id StorageMoverId, predicate AgentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Agent, 0) + + resp, err := c.List(ctx, id) + if err != nil { + 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 = ListCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_update.go new file mode 100644 index 000000000000..3497a72a772a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/method_update.go @@ -0,0 +1,55 @@ +package agents + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Agent +} + +// Update ... +func (c AgentsClient) Update(ctx context.Context, id AgentId, input AgentUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agent.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agent.go new file mode 100644 index 000000000000..c2f8de36bc5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agent.go @@ -0,0 +1,16 @@ +package agents + +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 Agent struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AgentProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentproperties.go new file mode 100644 index 000000000000..4655daa828fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentproperties.go @@ -0,0 +1,37 @@ +package agents + +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 AgentProperties struct { + AgentStatus *AgentStatus `json:"agentStatus,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + ArcResourceId string `json:"arcResourceId"` + ArcVMUuid string `json:"arcVmUuid"` + Description *string `json:"description,omitempty"` + ErrorDetails *AgentPropertiesErrorDetails `json:"errorDetails,omitempty"` + LastStatusUpdate *string `json:"lastStatusUpdate,omitempty"` + LocalIPAddress *string `json:"localIPAddress,omitempty"` + MemoryInMB *int64 `json:"memoryInMB,omitempty"` + NumberOfCores *int64 `json:"numberOfCores,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UptimeInSeconds *int64 `json:"uptimeInSeconds,omitempty"` +} + +func (o *AgentProperties) GetLastStatusUpdateAsTime() (*time.Time, error) { + if o.LastStatusUpdate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastStatusUpdate, "2006-01-02T15:04:05Z07:00") +} + +func (o *AgentProperties) SetLastStatusUpdateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastStatusUpdate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentpropertieserrordetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentpropertieserrordetails.go new file mode 100644 index 000000000000..54e40a369374 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentpropertieserrordetails.go @@ -0,0 +1,9 @@ +package agents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPropertiesErrorDetails struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateparameters.go new file mode 100644 index 000000000000..38c9c3ca07d6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateparameters.go @@ -0,0 +1,8 @@ +package agents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentUpdateParameters struct { + Properties *AgentUpdateProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateproperties.go new file mode 100644 index 000000000000..633817a0d41b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/model_agentupdateproperties.go @@ -0,0 +1,8 @@ +package agents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentUpdateProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/predicates.go new file mode 100644 index 000000000000..98e30d4c4051 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/predicates.go @@ -0,0 +1,27 @@ +package agents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AgentOperationPredicate) Matches(input Agent) 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/storagemover/2023-03-01/agents/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/version.go new file mode 100644 index 000000000000..9181413d185d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/version.go @@ -0,0 +1,12 @@ +package agents + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/agents/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md new file mode 100644 index 000000000000..50f43b91e98a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints` Documentation + +The `endpoints` SDK allows for interaction with the Azure Resource Manager Service `storagemover` (API Version `2023-03-01`). + +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-sdk/resource-manager/storagemover/2023-03-01/endpoints" +``` + + +### Client Initialization + +```go +client := endpoints.NewEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EndpointsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") + +payload := endpoints.Endpoint{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `EndpointsClient.Delete` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EndpointsClient.Get` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") + +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: `EndpointsClient.List` + +```go +ctx := context.TODO() +id := endpoints.NewStorageMoverID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `EndpointsClient.Update` + +```go +ctx := context.TODO() +id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") + +payload := endpoints.EndpointBaseUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go new file mode 100644 index 000000000000..d5d5f4782570 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go @@ -0,0 +1,26 @@ +package endpoints + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 EndpointsClient struct { + Client *resourcemanager.Client +} + +func NewEndpointsClientWithBaseURI(api environments.Api) (*EndpointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "endpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EndpointsClient: %+v", err) + } + + return &EndpointsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go new file mode 100644 index 000000000000..416284d70679 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go @@ -0,0 +1,90 @@ +package endpoints + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointType string + +const ( + EndpointTypeAzureStorageBlobContainer EndpointType = "AzureStorageBlobContainer" + EndpointTypeNfsMount EndpointType = "NfsMount" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeAzureStorageBlobContainer), + string(EndpointTypeNfsMount), + } +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "azurestorageblobcontainer": EndpointTypeAzureStorageBlobContainer, + "nfsmount": EndpointTypeNfsMount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type NfsVersion string + +const ( + NfsVersionNFSauto NfsVersion = "NFSauto" + NfsVersionNFSvFour NfsVersion = "NFSv4" + NfsVersionNFSvThree NfsVersion = "NFSv3" +) + +func PossibleValuesForNfsVersion() []string { + return []string{ + string(NfsVersionNFSauto), + string(NfsVersionNFSvFour), + string(NfsVersionNFSvThree), + } +} + +func parseNfsVersion(input string) (*NfsVersion, error) { + vals := map[string]NfsVersion{ + "nfsauto": NfsVersionNFSauto, + "nfsv4": NfsVersionNFSvFour, + "nfsv3": NfsVersionNFSvThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NfsVersion(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "succeeded": ProvisioningStateSucceeded, + } + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go new file mode 100644 index 000000000000..1476ea711d5e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go @@ -0,0 +1,140 @@ +package endpoints + +import ( + "fmt" + "strings" + + "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. + +var _ resourceids.ResourceId = EndpointId{} + +// EndpointId is a struct representing the Resource ID for a Endpoint +type EndpointId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string + EndpointName string +} + +// NewEndpointID returns a new EndpointId struct +func NewEndpointID(subscriptionId string, resourceGroupName string, storageMoverName string, endpointName string) EndpointId { + return EndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + EndpointName: endpointName, + } +} + +// ParseEndpointID parses 'input' into a EndpointId +func ParseEndpointID(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(EndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := EndpointId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + if id.EndpointName, ok = parsed.Parsed["endpointName"]; !ok { + return nil, fmt.Errorf("the segment 'endpointName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId +// note: this method should only be used for API response data and not user input +func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(EndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := EndpointId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + if id.EndpointName, ok = parsed.Parsed["endpointName"]; !ok { + return nil, fmt.Errorf("the segment 'endpointName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID +func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Endpoint ID +func (id EndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s/endpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.EndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID +func (id EndpointId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), + resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), + resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), + resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), + resourceids.UserSpecifiedSegment("endpointName", "endpointValue"), + } +} + +// String returns a human-readable description of this Endpoint ID +func (id EndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), + fmt.Sprintf("Endpoint Name: %q", id.EndpointName), + } + return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go new file mode 100644 index 000000000000..3631ab09348a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go @@ -0,0 +1,127 @@ +package endpoints + +import ( + "fmt" + "strings" + + "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. + +var _ resourceids.ResourceId = StorageMoverId{} + +// StorageMoverId is a struct representing the Resource ID for a Storage Mover +type StorageMoverId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string +} + +// NewStorageMoverID returns a new StorageMoverId struct +func NewStorageMoverID(subscriptionId string, resourceGroupName string, storageMoverName string) StorageMoverId { + return StorageMoverId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + } +} + +// ParseStorageMoverID parses 'input' into a StorageMoverId +func ParseStorageMoverID(input string) (*StorageMoverId, error) { + parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := StorageMoverId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseStorageMoverIDInsensitively parses 'input' case-insensitively into a StorageMoverId +// note: this method should only be used for API response data and not user input +func ParseStorageMoverIDInsensitively(input string) (*StorageMoverId, error) { + parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := StorageMoverId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { + return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateStorageMoverID checks that 'input' can be parsed as a Storage Mover ID +func ValidateStorageMoverID(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 := ParseStorageMoverID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Mover ID +func (id StorageMoverId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Mover ID +func (id StorageMoverId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), + resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), + resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), + } +} + +// String returns a human-readable description of this Storage Mover ID +func (id StorageMoverId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), + } + return fmt.Sprintf("Storage Mover (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go new file mode 100644 index 000000000000..0cbd9602bee2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go @@ -0,0 +1,55 @@ +package endpoints + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Endpoint +} + +// CreateOrUpdate ... +func (c EndpointsClient) CreateOrUpdate(ctx context.Context, id EndpointId, input Endpoint) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go new file mode 100644 index 000000000000..2733aa721727 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go @@ -0,0 +1,71 @@ +package endpoints + +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 EndpointsClient) Delete(ctx context.Context, id EndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 EndpointsClient) DeleteThenPoll(ctx context.Context, id EndpointId) 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/storagemover/2023-03-01/endpoints/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go new file mode 100644 index 000000000000..c93ee983f3b1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go @@ -0,0 +1,51 @@ +package endpoints + +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 *Endpoint +} + +// Get ... +func (c EndpointsClient) Get(ctx context.Context, id EndpointId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go new file mode 100644 index 000000000000..9f3661189e98 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go @@ -0,0 +1,89 @@ +package endpoints + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Endpoint +} + +type ListCompleteResult struct { + Items []Endpoint +} + +// List ... +func (c EndpointsClient) List(ctx context.Context, id StorageMoverId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/endpoints", 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 *[]Endpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c EndpointsClient) ListComplete(ctx context.Context, id StorageMoverId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, EndpointOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EndpointsClient) ListCompleteMatchingPredicate(ctx context.Context, id StorageMoverId, predicate EndpointOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Endpoint, 0) + + resp, err := c.List(ctx, id) + if err != nil { + 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 = ListCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go new file mode 100644 index 000000000000..9f7177e4a9c1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go @@ -0,0 +1,55 @@ +package endpoints + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Endpoint +} + +// Update ... +func (c EndpointsClient) Update(ctx context.Context, id EndpointId, input EndpointBaseUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go new file mode 100644 index 000000000000..3a655d2725d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go @@ -0,0 +1,44 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EndpointBaseProperties = AzureStorageBlobContainerEndpointProperties{} + +type AzureStorageBlobContainerEndpointProperties struct { + BlobContainerName string `json:"blobContainerName"` + StorageAccountResourceId string `json:"storageAccountResourceId"` + + // Fields inherited from EndpointBaseProperties + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Marshaler = AzureStorageBlobContainerEndpointProperties{} + +func (s AzureStorageBlobContainerEndpointProperties) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageBlobContainerEndpointProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageBlobContainerEndpointProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageBlobContainerEndpointProperties: %+v", err) + } + decoded["endpointType"] = "AzureStorageBlobContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageBlobContainerEndpointProperties: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go new file mode 100644 index 000000000000..5f30fb5dd539 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go @@ -0,0 +1,48 @@ +package endpoints + +import ( + "encoding/json" + "fmt" + + "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 Endpoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties EndpointBaseProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &Endpoint{} + +func (s *Endpoint) UnmarshalJSON(bytes []byte) error { + type alias Endpoint + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into Endpoint: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Endpoint into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalEndpointBasePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'Endpoint': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go new file mode 100644 index 000000000000..b84fee435945 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go @@ -0,0 +1,56 @@ +package endpoints + +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 EndpointBaseProperties interface { +} + +func unmarshalEndpointBasePropertiesImplementation(input []byte) (EndpointBaseProperties, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling EndpointBaseProperties into map[string]interface: %+v", err) + } + + value, ok := temp["endpointType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorageBlobContainer") { + var out AzureStorageBlobContainerEndpointProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageBlobContainerEndpointProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NfsMount") { + var out NfsMountEndpointProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NfsMountEndpointProperties: %+v", err) + } + return out, nil + } + + type RawEndpointBasePropertiesImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawEndpointBasePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go new file mode 100644 index 000000000000..142c929182af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointBaseUpdateParameters struct { + Properties *EndpointBaseUpdateProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go new file mode 100644 index 000000000000..9d88fb22a32f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go @@ -0,0 +1,8 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointBaseUpdateProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go new file mode 100644 index 000000000000..d8631f3caf2d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go @@ -0,0 +1,45 @@ +package endpoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EndpointBaseProperties = NfsMountEndpointProperties{} + +type NfsMountEndpointProperties struct { + Export string `json:"export"` + Host string `json:"host"` + NfsVersion *NfsVersion `json:"nfsVersion,omitempty"` + + // Fields inherited from EndpointBaseProperties + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +var _ json.Marshaler = NfsMountEndpointProperties{} + +func (s NfsMountEndpointProperties) MarshalJSON() ([]byte, error) { + type wrapper NfsMountEndpointProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NfsMountEndpointProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NfsMountEndpointProperties: %+v", err) + } + decoded["endpointType"] = "NfsMount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NfsMountEndpointProperties: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go new file mode 100644 index 000000000000..968958292ac6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go @@ -0,0 +1,27 @@ +package endpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p EndpointOperationPredicate) Matches(input Endpoint) 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/storagemover/2023-03-01/endpoints/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go new file mode 100644 index 000000000000..4a86d747ef80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go @@ -0,0 +1,12 @@ +package endpoints + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/endpoints/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index eb78de640061..5463af696a52 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -561,6 +561,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/skus github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/storageaccounts github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableservice github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableserviceproperties +github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents +github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/diskpools github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/iscsitargets diff --git a/website/docs/r/storage_mover_agent.html.markdown b/website/docs/r/storage_mover_agent.html.markdown new file mode 100644 index 000000000000..3d89fedab231 --- /dev/null +++ b/website/docs/r/storage_mover_agent.html.markdown @@ -0,0 +1,70 @@ +--- +subcategory: "Storage Mover" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_storage_mover_agent" +description: |- + Manages a Storage Mover Agent. +--- + +# azurerm_storage_mover_agent + +Manages a Storage Mover Agents. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_storage_mover" "example" { + name = "example-ssm" + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_storage_mover_agent" "example" { + name = "example-sa" + storage_mover_id = azurerm_storage_mover.example.id + arc_resource_id = "${azurerm_resource_group.example.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + description = "Example Agent Description" +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Storage Mover Agent. Changing this forces a new resource to be created. + +* `arc_resource_id` - (Required) Specifies the fully qualified resource ID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. + +* `arc_vm_uuid` - (Required) Specifies the VM UUID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. + +* `storage_mover_id` - (Required) Specifies the ID of the Storage Mover. Changing this forces a new resource to be created. + +* `description` - (Optional) A description for the Storage Mover Agent. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Storage Mover Agent. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Storage Mover Agent. +* `read` - (Defaults to 5 minutes) Used when retrieving the Storage Mover Agent. +* `update` - (Defaults to 30 minutes) Used when updating the Storage Mover Agent. +* `delete` - (Defaults to 30 minutes) Used when deleting the Storage Mover Agent. + +## Import + +Storage Mover Agent can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_storage_mover_agent.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/agents/agent1 +``` diff --git a/website/docs/r/storage_mover_endpoint.html.markdown b/website/docs/r/storage_mover_endpoint.html.markdown new file mode 100644 index 000000000000..3a0ffdd19b04 --- /dev/null +++ b/website/docs/r/storage_mover_endpoint.html.markdown @@ -0,0 +1,70 @@ +--- +subcategory: "storagemover" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_storagemover_endpoint" +description: |- + Manages a Storagemover Endpoints. +--- + +# azurerm_storagemover_endpoint + +Manages a Storagemover Endpoints. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_storagemover_storage_mover" "example" { + name = "example-ssm" + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_storagemover_endpoint" "example" { + name = "example-se" + storagemover_storage_mover_id = azurerm_storagemover_storage_mover.test.id + description = "" + endpoint_type = "" + +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Storagemover Endpoints. Changing this forces a new Storagemover Endpoints to be created. + +* `storagemover_storage_mover_id` - (Required) Specifies the ID of the Storagemover Endpoints. Changing this forces a new Storagemover Endpoints to be created. + +* `endpoint_type` - (Required) Specifies the Endpoint resource type. Changing this forces a new Storagemover Endpoints to be created. + +* `description` - (Optional) A description for the Endpoint. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Storagemover Endpoints. + + + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Storagemover Endpoints. +* `read` - (Defaults to 5 minutes) Used when retrieving the Storagemover Endpoints. +* `update` - (Defaults to 30 minutes) Used when updating the Storagemover Endpoints. +* `delete` - (Defaults to 30 minutes) Used when deleting the Storagemover Endpoints. + +## Import + +Storagemover Endpoints can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_storagemover_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/endpoints/endpoint1 +``` From bd19060530ede29356967add0512d5761f882003 Mon Sep 17 00:00:00 2001 From: elena Date: Tue, 4 Apr 2023 14:13:07 +0800 Subject: [PATCH 3/7] update code --- .../storage_mover_agent_resource.go | 2 + .../storage_mover_source_endpoint_resource.go | 231 ------------------ ...age_mover_source_endpoint_resource_test.go | 171 ------------- .../storage_mover_target_endpoint_resource.go | 225 ----------------- ...age_mover_target_endpoint_resource_test.go | 171 ------------- .../2023-03-01/endpoints/README.md | 107 -------- .../2023-03-01/endpoints/client.go | 26 -- .../2023-03-01/endpoints/constants.go | 90 ------- .../2023-03-01/endpoints/id_endpoint.go | 140 ----------- .../2023-03-01/endpoints/id_storagemover.go | 127 ---------- .../endpoints/method_createorupdate.go | 55 ----- .../2023-03-01/endpoints/method_delete.go | 71 ------ .../2023-03-01/endpoints/method_get.go | 51 ---- .../2023-03-01/endpoints/method_list.go | 89 ------- .../2023-03-01/endpoints/method_update.go | 55 ----- ...estorageblobcontainerendpointproperties.go | 44 ---- .../2023-03-01/endpoints/model_endpoint.go | 48 ---- .../endpoints/model_endpointbaseproperties.go | 56 ----- .../model_endpointbaseupdateparameters.go | 8 - .../model_endpointbaseupdateproperties.go | 8 - .../model_nfsmountendpointproperties.go | 45 ---- .../2023-03-01/endpoints/predicates.go | 27 -- .../2023-03-01/endpoints/version.go | 12 - vendor/modules.txt | 1 - 24 files changed, 2 insertions(+), 1858 deletions(-) delete mode 100644 internal/services/storagemover/storage_mover_source_endpoint_resource.go delete mode 100644 internal/services/storagemover/storage_mover_source_endpoint_resource_test.go delete mode 100644 internal/services/storagemover/storage_mover_target_endpoint_resource.go delete mode 100644 internal/services/storagemover/storage_mover_target_endpoint_resource_test.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go diff --git a/internal/services/storagemover/storage_mover_agent_resource.go b/internal/services/storagemover/storage_mover_agent_resource.go index 74b4a7f1fa8c..7d380cef0fb1 100644 --- a/internal/services/storagemover/storage_mover_agent_resource.go +++ b/internal/services/storagemover/storage_mover_agent_resource.go @@ -199,6 +199,8 @@ func (r StorageMoverAgentResource) Read() sdk.ResourceFunc { state.ArcVmUuid = properties.ArcVMUuid + state.ArcResourceId = properties.ArcResourceId + des := "" if properties.Description != nil { des = *properties.Description diff --git a/internal/services/storagemover/storage_mover_source_endpoint_resource.go b/internal/services/storagemover/storage_mover_source_endpoint_resource.go deleted file mode 100644 index 35f2d9524378..000000000000 --- a/internal/services/storagemover/storage_mover_source_endpoint_resource.go +++ /dev/null @@ -1,231 +0,0 @@ -package storagemover - -import ( - "context" - "fmt" - "time" - - "github.com/hashicorp/terraform-provider-azurerm/utils" - - "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" - "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" -) - -type StorageMoverSourceEndpointResourceModel struct { - Name string `tfschema:"name"` - StorageMoverId string `tfschema:"storage_mover_id"` - Host string `tfschema:"host"` - Export string `tfschema:"export"` - NfsVersion endpoints.NfsVersion `tfschema:"nfs_version"` - Description string `tfschema:"description"` -} - -type StorageMoverSourceEndpointResource struct{} - -var _ sdk.ResourceWithUpdate = StorageMoverSourceEndpointResourceModel{} - -func (r StorageMoverSourceEndpointResourceModel) ResourceType() string { - return "azurerm_storagemover_endpoint" -} - -func (r StorageMoverSourceEndpointResourceModel) ModelObject() interface{} { - return &StorageMoverSourceEndpointResourceModel{} -} - -func (r StorageMoverSourceEndpointResourceModel) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return endpoints.ValidateEndpointID -} - -func (r StorageMoverSourceEndpointResourceModel) Arguments() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "storage_mover_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: storagemovers.ValidateStorageMoverID, - }, - - "host": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "export": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "nfs_version": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "description": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - } -} - -func (r StorageMoverSourceEndpointResourceModel) Attributes() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{} -} - -func (r StorageMoverSourceEndpointResourceModel) Create() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - var model StorageMoverSourceEndpointResourceModel - if err := metadata.Decode(&model); err != nil { - return fmt.Errorf("decoding: %+v", err) - } - - client := metadata.Client.StorageMover.EndpointsClient - storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) - if err != nil { - return err - } - - id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, 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) - } - - properties := endpoints.Endpoint{ - Name: utils.String(model.Name), - Type: utils.String(string(endpoints.EndpointTypeNfsMount)), - Properties: endpoints.NfsMountEndpointProperties{ - Export: model.Export, - Host: model.Host, - NfsVersion: &model.NfsVersion, - Description: &model.Description, - }, - } - - if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { - return fmt.Errorf("creating %s: %+v", id, err) - } - - metadata.SetID(id) - return nil - }, - } -} - -func (r StorageMoverSourceEndpointResourceModel) Update() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) - if err != nil { - return err - } - - var model StorageMoverSourceEndpointResourceModel - if err := metadata.Decode(&model); err != nil { - return fmt.Errorf("decoding: %+v", err) - } - - resp, err := client.Get(ctx, *id) - if err != nil { - return fmt.Errorf("retrieving %s: %+v", *id, err) - } - - properties := resp.Model - if properties == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - - if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { - return fmt.Errorf("updating %s: %+v", *id, err) - } - - return nil - }, - } -} - -func (r StorageMoverSourceEndpointResourceModel) Read() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 5 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(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 := resp.Model - if model == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - - state := StorageMoverSourceEndpointResourceModel{ - Name: id.EndpointName, - StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), - } - - properties := endpoints.NfsMountEndpointProperties{} - properties = model.Properties - if properties != nil { - state.Description = *properties.Description - } - - state.EndpointType = properties.EndpointType - - return metadata.Encode(&state) - }, - } -} - -func (r StorageMoverSourceEndpointResourceModel) Delete() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) - if err != nil { - return err - } - - if err := client.DeleteThenPoll(ctx, *id); err != nil { - return fmt.Errorf("deleting %s: %+v", *id, err) - } - - return nil - }, - } -} diff --git a/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go b/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go deleted file mode 100644 index 9b0fecee424f..000000000000 --- a/internal/services/storagemover/storage_mover_source_endpoint_resource_test.go +++ /dev/null @@ -1,171 +0,0 @@ -package storagemover_test - -import ( - "context" - "fmt" - "testing" - - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" - - "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -type StorageMoverSourceEndpointTestResource struct{} - -func TestAccstoragemoverEndpoint_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverSourceEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - }) -} - -func TestAccstoragemoverEndpoint_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverSourceEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.RequiresImportErrorStep(r.requiresImport), - }) -} - -func TestAccstoragemoverEndpoint_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverSourceEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.complete(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - }) -} - -func TestAccstoragemoverEndpoint_update(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverSourceEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.complete(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(), - }) -} - -func (r StorageMoverSourceEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := endpoints.ParseEndpointID(state.ID) - if err != nil { - return nil, err - } - - client := clients.storagemover.EndpointsClient - resp, err := client.Get(ctx, *id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } - return nil, fmt.Errorf("retrieving %s: %+v", id, err) - } - return utils.Bool(resp.Model != nil), nil -} - -func (r StorageMoverSourceEndpointTestResource) template(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctest-rg-%d" - location = "%s" -} -resource "azurerm_storagemover_storage_mover" "test" { - name = "acctest-ssm-%d" - resource_group_name = azurerm_resource_group.test.name -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - -func (r StorageMoverSourceEndpointTestResource) basic(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - endpoint_type = "" -} -`, template, data.RandomInteger) -} - -func (r StorageMoverSourceEndpointTestResource) requiresImport(data acceptance.TestData) string { - config := r.basic(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "import" { - name = azurerm_storagemover_endpoint.test.name - StorageMoverId = azurerm_storagemover_storage_mover.test.id - endpoint_type = "" -} -`, config) -} - -func (r StorageMoverSourceEndpointTestResource) complete(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - description = "" - endpoint_type = "" - -} -`, template, data.RandomInteger) -} - -func (r StorageMoverSourceEndpointTestResource) update(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - description = "" - endpoint_type = "" - -} -`, template, data.RandomInteger) -} diff --git a/internal/services/storagemover/storage_mover_target_endpoint_resource.go b/internal/services/storagemover/storage_mover_target_endpoint_resource.go deleted file mode 100644 index 712ba0249cd3..000000000000 --- a/internal/services/storagemover/storage_mover_target_endpoint_resource.go +++ /dev/null @@ -1,225 +0,0 @@ -package storagemover - -import ( - "context" - "fmt" - "time" - - "github.com/hashicorp/terraform-provider-azurerm/utils" - - "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" - "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" -) - -type StorageMoverTargetEndpointResourceModel struct { - Name string `tfschema:"name"` - StorageMoverId string `tfschema:"storage_mover_id"` - EndpointType endpoints.EndpointType `tfschema:"endpoint_type"` - Description string `tfschema:"description"` - BlobContainerName string `tfschema:"blob_container_name"` - StorageAccountId string `tfschema:"storage_account_id"` - Host string `tfschema:"host"` - Export string `tfschema:"export"` - NfsVersion string `tfschema:"nfs_version"` -} - -type StorageMoverTargetEndpointResource struct{} - -var _ sdk.ResourceWithUpdate = StorageMoverTargetEndpointResource{} - -func (r StorageMoverTargetEndpointResource) ResourceType() string { - return "azurerm_storagemover_endpoint" -} - -func (r StorageMoverTargetEndpointResource) ModelObject() interface{} { - return &StorageMoverTargetEndpointResourceModel{} -} - -func (r StorageMoverTargetEndpointResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return endpoints.ValidateEndpointID -} - -func (r StorageMoverTargetEndpointResource) Arguments() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "endpoint_type": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(endpoints.EndpointTypeAzureStorageBlobContainer), - string(endpoints.EndpointTypeNfsMount), - }, false), - }, - - "storage_mover_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: storagemovers.ValidateStorageMoverID, - }, - - "description": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - } -} - -func (r StorageMoverTargetEndpointResource) Attributes() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{} -} - -func (r StorageMoverTargetEndpointResource) Create() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - var model StorageMoverTargetEndpointResourceModel - if err := metadata.Decode(&model); err != nil { - return fmt.Errorf("decoding: %+v", err) - } - - client := metadata.Client.StorageMover.EndpointsClient - storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) - if err != nil { - return err - } - - id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, 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) - } - - properties := endpoints.Endpoint{ - Name: utils.String(model.Name), - Type: utils.String(string(model.EndpointType)), - } - - if model.EndpointType == endpoints.EndpointTypeAzureStorageBlobContainer { - properties.Properties = endpoints.AzureStorageBlobContainerEndpointProperties{} - } else if model.EndpointType == endpoints.EndpointTypeNfsMount { - properties.Properties = endpoints.NfsMountEndpointProperties{} - } - - if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { - return fmt.Errorf("creating %s: %+v", id, err) - } - - metadata.SetID(id) - return nil - }, - } -} - -func (r StorageMoverTargetEndpointResource) Update() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) - if err != nil { - return err - } - - var model StorageMoverTargetEndpointResourceModel - if err := metadata.Decode(&model); err != nil { - return fmt.Errorf("decoding: %+v", err) - } - - resp, err := client.Get(ctx, *id) - if err != nil { - return fmt.Errorf("retrieving %s: %+v", *id, err) - } - - properties := resp.Model - if properties == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - - if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { - return fmt.Errorf("updating %s: %+v", *id, err) - } - - return nil - }, - } -} - -func (r StorageMoverTargetEndpointResource) Read() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 5 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(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 := resp.Model - if model == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - - state := StorageMoverTargetEndpointResourceModel{ - Name: id.EndpointName, - StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), - } - - properties := &model.Properties - if properties.Description != nil { - state.Description = *properties.Description - } - - state.EndpointType = properties.EndpointType - - return metadata.Encode(&state) - }, - } -} - -func (r StorageMoverTargetEndpointResource) Delete() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.StorageMover.EndpointsClient - - id, err := endpoints.ParseEndpointID(metadata.ResourceData.Id()) - if err != nil { - return err - } - - if err := client.DeleteThenPoll(ctx, *id); err != nil { - return fmt.Errorf("deleting %s: %+v", *id, err) - } - - return nil - }, - } -} diff --git a/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go b/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go deleted file mode 100644 index ab4186effaa4..000000000000 --- a/internal/services/storagemover/storage_mover_target_endpoint_resource_test.go +++ /dev/null @@ -1,171 +0,0 @@ -package storagemover_test - -import ( - "context" - "fmt" - "testing" - - "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints" - - "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -type StorageMoverTargetEndpointTestResource struct{} - -func TestAccstoragemoverEndpoint_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverTargetEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - }) -} - -func TestAccstoragemoverEndpoint_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverTargetEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.RequiresImportErrorStep(r.requiresImport), - }) -} - -func TestAccstoragemoverEndpoint_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverTargetEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.complete(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - }) -} - -func TestAccstoragemoverEndpoint_update(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_storagemover_endpoint", "test") - r := StorageMoverTargetEndpointTestResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.complete(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(), - }) -} - -func (r StorageMoverTargetEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := endpoints.ParseEndpointID(state.ID) - if err != nil { - return nil, err - } - - client := clients.storagemover.EndpointsClient - resp, err := client.Get(ctx, *id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } - return nil, fmt.Errorf("retrieving %s: %+v", id, err) - } - return utils.Bool(resp.Model != nil), nil -} - -func (r StorageMoverTargetEndpointTestResource) template(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctest-rg-%d" - location = "%s" -} -resource "azurerm_storagemover_storage_mover" "test" { - name = "acctest-ssm-%d" - resource_group_name = azurerm_resource_group.test.name -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - -func (r StorageMoverTargetEndpointTestResource) basic(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - endpoint_type = "" -} -`, template, data.RandomInteger) -} - -func (r StorageMoverTargetEndpointTestResource) requiresImport(data acceptance.TestData) string { - config := r.basic(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "import" { - name = azurerm_storagemover_endpoint.test.name - StorageMoverId = azurerm_storagemover_storage_mover.test.id - endpoint_type = "" -} -`, config) -} - -func (r StorageMoverTargetEndpointTestResource) complete(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - description = "" - endpoint_type = "" - -} -`, template, data.RandomInteger) -} - -func (r StorageMoverTargetEndpointTestResource) update(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` - %s - -resource "azurerm_storagemover_endpoint" "test" { - name = "acctest-se-%d" - StorageMoverId = azurerm_storagemover_storage_mover.test.id - description = "" - endpoint_type = "" - -} -`, template, data.RandomInteger) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md deleted file mode 100644 index 50f43b91e98a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/README.md +++ /dev/null @@ -1,107 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints` Documentation - -The `endpoints` SDK allows for interaction with the Azure Resource Manager Service `storagemover` (API Version `2023-03-01`). - -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-sdk/resource-manager/storagemover/2023-03-01/endpoints" -``` - - -### Client Initialization - -```go -client := endpoints.NewEndpointsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `EndpointsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") - -payload := endpoints.Endpoint{ - // ... -} - - -read, err := client.CreateOrUpdate(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `EndpointsClient.Delete` - -```go -ctx := context.TODO() -id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `EndpointsClient.Get` - -```go -ctx := context.TODO() -id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") - -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: `EndpointsClient.List` - -```go -ctx := context.TODO() -id := endpoints.NewStorageMoverID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `EndpointsClient.Update` - -```go -ctx := context.TODO() -id := endpoints.NewEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "endpointValue") - -payload := endpoints.EndpointBaseUpdateParameters{ - // ... -} - - -read, err := client.Update(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go deleted file mode 100644 index d5d5f4782570..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/client.go +++ /dev/null @@ -1,26 +0,0 @@ -package endpoints - -import ( - "fmt" - - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "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 EndpointsClient struct { - Client *resourcemanager.Client -} - -func NewEndpointsClientWithBaseURI(api environments.Api) (*EndpointsClient, error) { - client, err := resourcemanager.NewResourceManagerClient(api, "endpoints", defaultApiVersion) - if err != nil { - return nil, fmt.Errorf("instantiating EndpointsClient: %+v", err) - } - - return &EndpointsClient{ - Client: client, - }, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go deleted file mode 100644 index 416284d70679..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/constants.go +++ /dev/null @@ -1,90 +0,0 @@ -package endpoints - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type EndpointType string - -const ( - EndpointTypeAzureStorageBlobContainer EndpointType = "AzureStorageBlobContainer" - EndpointTypeNfsMount EndpointType = "NfsMount" -) - -func PossibleValuesForEndpointType() []string { - return []string{ - string(EndpointTypeAzureStorageBlobContainer), - string(EndpointTypeNfsMount), - } -} - -func parseEndpointType(input string) (*EndpointType, error) { - vals := map[string]EndpointType{ - "azurestorageblobcontainer": EndpointTypeAzureStorageBlobContainer, - "nfsmount": EndpointTypeNfsMount, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := EndpointType(input) - return &out, nil -} - -type NfsVersion string - -const ( - NfsVersionNFSauto NfsVersion = "NFSauto" - NfsVersionNFSvFour NfsVersion = "NFSv4" - NfsVersionNFSvThree NfsVersion = "NFSv3" -) - -func PossibleValuesForNfsVersion() []string { - return []string{ - string(NfsVersionNFSauto), - string(NfsVersionNFSvFour), - string(NfsVersionNFSvThree), - } -} - -func parseNfsVersion(input string) (*NfsVersion, error) { - vals := map[string]NfsVersion{ - "nfsauto": NfsVersionNFSauto, - "nfsv4": NfsVersionNFSvFour, - "nfsv3": NfsVersionNFSvThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := NfsVersion(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateSucceeded ProvisioningState = "Succeeded" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateSucceeded), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "succeeded": ProvisioningStateSucceeded, - } - 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 -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go deleted file mode 100644 index 1476ea711d5e..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_endpoint.go +++ /dev/null @@ -1,140 +0,0 @@ -package endpoints - -import ( - "fmt" - "strings" - - "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. - -var _ resourceids.ResourceId = EndpointId{} - -// EndpointId is a struct representing the Resource ID for a Endpoint -type EndpointId struct { - SubscriptionId string - ResourceGroupName string - StorageMoverName string - EndpointName string -} - -// NewEndpointID returns a new EndpointId struct -func NewEndpointID(subscriptionId string, resourceGroupName string, storageMoverName string, endpointName string) EndpointId { - return EndpointId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - StorageMoverName: storageMoverName, - EndpointName: endpointName, - } -} - -// ParseEndpointID parses 'input' into a EndpointId -func ParseEndpointID(input string) (*EndpointId, error) { - parser := resourceids.NewParserFromResourceIdType(EndpointId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := EndpointId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { - return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) - } - - if id.EndpointName, ok = parsed.Parsed["endpointName"]; !ok { - return nil, fmt.Errorf("the segment 'endpointName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseEndpointIDInsensitively parses 'input' case-insensitively into a EndpointId -// note: this method should only be used for API response data and not user input -func ParseEndpointIDInsensitively(input string) (*EndpointId, error) { - parser := resourceids.NewParserFromResourceIdType(EndpointId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := EndpointId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { - return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) - } - - if id.EndpointName, ok = parsed.Parsed["endpointName"]; !ok { - return nil, fmt.Errorf("the segment 'endpointName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateEndpointID checks that 'input' can be parsed as a Endpoint ID -func ValidateEndpointID(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 := ParseEndpointID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Endpoint ID -func (id EndpointId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s/endpoints/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.EndpointName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Endpoint ID -func (id EndpointId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), - resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), - resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), - resourceids.StaticSegment("staticEndpoints", "endpoints", "endpoints"), - resourceids.UserSpecifiedSegment("endpointName", "endpointValue"), - } -} - -// String returns a human-readable description of this Endpoint ID -func (id EndpointId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), - fmt.Sprintf("Endpoint Name: %q", id.EndpointName), - } - return fmt.Sprintf("Endpoint (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go deleted file mode 100644 index 3631ab09348a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/id_storagemover.go +++ /dev/null @@ -1,127 +0,0 @@ -package endpoints - -import ( - "fmt" - "strings" - - "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. - -var _ resourceids.ResourceId = StorageMoverId{} - -// StorageMoverId is a struct representing the Resource ID for a Storage Mover -type StorageMoverId struct { - SubscriptionId string - ResourceGroupName string - StorageMoverName string -} - -// NewStorageMoverID returns a new StorageMoverId struct -func NewStorageMoverID(subscriptionId string, resourceGroupName string, storageMoverName string) StorageMoverId { - return StorageMoverId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - StorageMoverName: storageMoverName, - } -} - -// ParseStorageMoverID parses 'input' into a StorageMoverId -func ParseStorageMoverID(input string) (*StorageMoverId, error) { - parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := StorageMoverId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { - return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseStorageMoverIDInsensitively parses 'input' case-insensitively into a StorageMoverId -// note: this method should only be used for API response data and not user input -func ParseStorageMoverIDInsensitively(input string) (*StorageMoverId, error) { - parser := resourceids.NewParserFromResourceIdType(StorageMoverId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := StorageMoverId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.StorageMoverName, ok = parsed.Parsed["storageMoverName"]; !ok { - return nil, fmt.Errorf("the segment 'storageMoverName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateStorageMoverID checks that 'input' can be parsed as a Storage Mover ID -func ValidateStorageMoverID(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 := ParseStorageMoverID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Storage Mover ID -func (id StorageMoverId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Storage Mover ID -func (id StorageMoverId) 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("staticMicrosoftStorageMover", "Microsoft.StorageMover", "Microsoft.StorageMover"), - resourceids.StaticSegment("staticStorageMovers", "storageMovers", "storageMovers"), - resourceids.UserSpecifiedSegment("storageMoverName", "storageMoverValue"), - } -} - -// String returns a human-readable description of this Storage Mover ID -func (id StorageMoverId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Storage Mover Name: %q", id.StorageMoverName), - } - return fmt.Sprintf("Storage Mover (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go deleted file mode 100644 index 0cbd9602bee2..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_createorupdate.go +++ /dev/null @@ -1,55 +0,0 @@ -package endpoints - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *Endpoint -} - -// CreateOrUpdate ... -func (c EndpointsClient) CreateOrUpdate(ctx context.Context, id EndpointId, input Endpoint) (result CreateOrUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json", - ExpectedStatusCodes: []int{ - 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 - } - - if err = resp.Unmarshal(&result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go deleted file mode 100644 index 2733aa721727..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_delete.go +++ /dev/null @@ -1,71 +0,0 @@ -package endpoints - -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 EndpointsClient) Delete(ctx context.Context, id EndpointId) (result DeleteOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json", - ExpectedStatusCodes: []int{ - http.StatusAccepted, - http.StatusNoContent, - http.StatusOK, - }, - 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 EndpointsClient) DeleteThenPoll(ctx context.Context, id EndpointId) 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/storagemover/2023-03-01/endpoints/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go deleted file mode 100644 index c93ee983f3b1..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_get.go +++ /dev/null @@ -1,51 +0,0 @@ -package endpoints - -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 *Endpoint -} - -// Get ... -func (c EndpointsClient) Get(ctx context.Context, id EndpointId) (result GetOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json", - 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 - } - - if err = resp.Unmarshal(&result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go deleted file mode 100644 index 9f3661189e98..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_list.go +++ /dev/null @@ -1,89 +0,0 @@ -package endpoints - -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 ListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]Endpoint -} - -type ListCompleteResult struct { - Items []Endpoint -} - -// List ... -func (c EndpointsClient) List(ctx context.Context, id StorageMoverId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Path: fmt.Sprintf("%s/endpoints", 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 *[]Endpoint `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// ListComplete retrieves all the results into a single object -func (c EndpointsClient) ListComplete(ctx context.Context, id StorageMoverId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, EndpointOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c EndpointsClient) ListCompleteMatchingPredicate(ctx context.Context, id StorageMoverId, predicate EndpointOperationPredicate) (result ListCompleteResult, err error) { - items := make([]Endpoint, 0) - - resp, err := c.List(ctx, id) - if err != nil { - 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 = ListCompleteResult{ - Items: items, - } - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go deleted file mode 100644 index 9f7177e4a9c1..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/method_update.go +++ /dev/null @@ -1,55 +0,0 @@ -package endpoints - -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 UpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *Endpoint -} - -// Update ... -func (c EndpointsClient) Update(ctx context.Context, id EndpointId, input EndpointBaseUpdateParameters) (result UpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json", - ExpectedStatusCodes: []int{ - 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 - } - - if err = resp.Unmarshal(&result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go deleted file mode 100644 index 3a655d2725d9..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_azurestorageblobcontainerendpointproperties.go +++ /dev/null @@ -1,44 +0,0 @@ -package endpoints - -import ( - "encoding/json" - "fmt" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ EndpointBaseProperties = AzureStorageBlobContainerEndpointProperties{} - -type AzureStorageBlobContainerEndpointProperties struct { - BlobContainerName string `json:"blobContainerName"` - StorageAccountResourceId string `json:"storageAccountResourceId"` - - // Fields inherited from EndpointBaseProperties - Description *string `json:"description,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} - -var _ json.Marshaler = AzureStorageBlobContainerEndpointProperties{} - -func (s AzureStorageBlobContainerEndpointProperties) MarshalJSON() ([]byte, error) { - type wrapper AzureStorageBlobContainerEndpointProperties - wrapped := wrapper(s) - encoded, err := json.Marshal(wrapped) - if err != nil { - return nil, fmt.Errorf("marshaling AzureStorageBlobContainerEndpointProperties: %+v", err) - } - - var decoded map[string]interface{} - if err := json.Unmarshal(encoded, &decoded); err != nil { - return nil, fmt.Errorf("unmarshaling AzureStorageBlobContainerEndpointProperties: %+v", err) - } - decoded["endpointType"] = "AzureStorageBlobContainer" - - encoded, err = json.Marshal(decoded) - if err != nil { - return nil, fmt.Errorf("re-marshaling AzureStorageBlobContainerEndpointProperties: %+v", err) - } - - return encoded, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go deleted file mode 100644 index 5f30fb5dd539..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpoint.go +++ /dev/null @@ -1,48 +0,0 @@ -package endpoints - -import ( - "encoding/json" - "fmt" - - "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 Endpoint struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties EndpointBaseProperties `json:"properties"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} - -var _ json.Unmarshaler = &Endpoint{} - -func (s *Endpoint) UnmarshalJSON(bytes []byte) error { - type alias Endpoint - var decoded alias - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling into Endpoint: %+v", err) - } - - s.Id = decoded.Id - s.Name = decoded.Name - s.SystemData = decoded.SystemData - s.Type = decoded.Type - - var temp map[string]json.RawMessage - if err := json.Unmarshal(bytes, &temp); err != nil { - return fmt.Errorf("unmarshaling Endpoint into map[string]json.RawMessage: %+v", err) - } - - if v, ok := temp["properties"]; ok { - impl, err := unmarshalEndpointBasePropertiesImplementation(v) - if err != nil { - return fmt.Errorf("unmarshaling field 'Properties' for 'Endpoint': %+v", err) - } - s.Properties = impl - } - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go deleted file mode 100644 index b84fee435945..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseproperties.go +++ /dev/null @@ -1,56 +0,0 @@ -package endpoints - -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 EndpointBaseProperties interface { -} - -func unmarshalEndpointBasePropertiesImplementation(input []byte) (EndpointBaseProperties, error) { - if input == nil { - return nil, nil - } - - var temp map[string]interface{} - if err := json.Unmarshal(input, &temp); err != nil { - return nil, fmt.Errorf("unmarshaling EndpointBaseProperties into map[string]interface: %+v", err) - } - - value, ok := temp["endpointType"].(string) - if !ok { - return nil, nil - } - - if strings.EqualFold(value, "AzureStorageBlobContainer") { - var out AzureStorageBlobContainerEndpointProperties - if err := json.Unmarshal(input, &out); err != nil { - return nil, fmt.Errorf("unmarshaling into AzureStorageBlobContainerEndpointProperties: %+v", err) - } - return out, nil - } - - if strings.EqualFold(value, "NfsMount") { - var out NfsMountEndpointProperties - if err := json.Unmarshal(input, &out); err != nil { - return nil, fmt.Errorf("unmarshaling into NfsMountEndpointProperties: %+v", err) - } - return out, nil - } - - type RawEndpointBasePropertiesImpl struct { - Type string `json:"-"` - Values map[string]interface{} `json:"-"` - } - out := RawEndpointBasePropertiesImpl{ - Type: value, - Values: temp, - } - return out, nil - -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go deleted file mode 100644 index 142c929182af..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateparameters.go +++ /dev/null @@ -1,8 +0,0 @@ -package endpoints - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type EndpointBaseUpdateParameters struct { - Properties *EndpointBaseUpdateProperties `json:"properties,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go deleted file mode 100644 index 9d88fb22a32f..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_endpointbaseupdateproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package endpoints - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type EndpointBaseUpdateProperties struct { - Description *string `json:"description,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go deleted file mode 100644 index d8631f3caf2d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/model_nfsmountendpointproperties.go +++ /dev/null @@ -1,45 +0,0 @@ -package endpoints - -import ( - "encoding/json" - "fmt" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -var _ EndpointBaseProperties = NfsMountEndpointProperties{} - -type NfsMountEndpointProperties struct { - Export string `json:"export"` - Host string `json:"host"` - NfsVersion *NfsVersion `json:"nfsVersion,omitempty"` - - // Fields inherited from EndpointBaseProperties - Description *string `json:"description,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} - -var _ json.Marshaler = NfsMountEndpointProperties{} - -func (s NfsMountEndpointProperties) MarshalJSON() ([]byte, error) { - type wrapper NfsMountEndpointProperties - wrapped := wrapper(s) - encoded, err := json.Marshal(wrapped) - if err != nil { - return nil, fmt.Errorf("marshaling NfsMountEndpointProperties: %+v", err) - } - - var decoded map[string]interface{} - if err := json.Unmarshal(encoded, &decoded); err != nil { - return nil, fmt.Errorf("unmarshaling NfsMountEndpointProperties: %+v", err) - } - decoded["endpointType"] = "NfsMount" - - encoded, err = json.Marshal(decoded) - if err != nil { - return nil, fmt.Errorf("re-marshaling NfsMountEndpointProperties: %+v", err) - } - - return encoded, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go deleted file mode 100644 index 968958292ac6..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/predicates.go +++ /dev/null @@ -1,27 +0,0 @@ -package endpoints - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type EndpointOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p EndpointOperationPredicate) Matches(input Endpoint) 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/storagemover/2023-03-01/endpoints/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go deleted file mode 100644 index 4a86d747ef80..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package endpoints - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2023-03-01" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/endpoints/%s", defaultApiVersion) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5463af696a52..7cb9b1f0b0e6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -562,7 +562,6 @@ github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/storageacc github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableservice github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableserviceproperties github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents -github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/endpoints github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/diskpools github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/iscsitargets From 61ea9e7a5c80ae66b08db90d164e27699e5f706f Mon Sep 17 00:00:00 2001 From: elena Date: Tue, 4 Apr 2023 14:19:32 +0800 Subject: [PATCH 4/7] update code --- .../storagemover/scripts/install_arc.sh.tftpl | 54 +++++ .../storage_mover_agent_resource.go | 36 ++- .../storage_mover_agent_resource_test.go | 206 +++++++++++++++--- .../docs/r/storage_mover_agent.html.markdown | 22 +- .../r/storage_mover_endpoint.html.markdown | 70 ------ 5 files changed, 260 insertions(+), 128 deletions(-) create mode 100644 internal/services/storagemover/scripts/install_arc.sh.tftpl delete mode 100644 website/docs/r/storage_mover_endpoint.html.markdown diff --git a/internal/services/storagemover/scripts/install_arc.sh.tftpl b/internal/services/storagemover/scripts/install_arc.sh.tftpl new file mode 100644 index 000000000000..a44495683a45 --- /dev/null +++ b/internal/services/storagemover/scripts/install_arc.sh.tftpl @@ -0,0 +1,54 @@ +#!/bin/bash + +# Disable the Azure VM Guest Agent. +current_hostname=$(hostname) +sudo service walinuxagent stop +sudo waagent -deprovision -force +sudo rm -rf /var/lib/waagent +sudo hostnamectl set-hostname $current_hostname + +# Block access to the Azure IMDS endpoint. +sudo ufw --force enable +sudo ufw deny out from any to 169.254.169.254 +sudo ufw default allow incoming + +# Add the service principal application ID and secret here +servicePrincipalClientId="${client_id}" +servicePrincipalSecret="${client_secret}" +cloud="AzureCloud" +tenantId="${tenant_id}" +subscriptionId="${subscription_id}" +resourceGroup="${resource_group_name}" +location="${location}" +authType="principal" +correlationId="${uuid}" +output="$(wget https://aka.ms/azcmagent -O ~/install_linux_azcmagent.sh 2>&1)" +if [ $? != 0 ]; then + read -d '' bodyData < /dev/null || true +fi +echo "$output" +sudo chmod +x ~/install_linux_azcmagent.sh +cd ~ +./install_linux_azcmagent.sh +sudo azcmagent connect \ + --service-principal-id "$servicePrincipalClientId" \ + --service-principal-secret "$servicePrincipalSecret" \ + --cloud "$cloud" \ + --tenant-id "$tenantId" \ + --subscription-id "$subscriptionId" \ + --resource-group "$resourceGroup" \ + --location "$location" \ + --correlation-id "$correlationId" \ No newline at end of file diff --git a/internal/services/storagemover/storage_mover_agent_resource.go b/internal/services/storagemover/storage_mover_agent_resource.go index 7d380cef0fb1..43e04af4dbd4 100644 --- a/internal/services/storagemover/storage_mover_agent_resource.go +++ b/internal/services/storagemover/storage_mover_agent_resource.go @@ -15,11 +15,11 @@ import ( ) type StorageMoverAgentResourceModel struct { - Name string `tfschema:"name"` - StorageMoverId string `tfschema:"storage_mover_id"` - ArcResourceId string `tfschema:"arc_resource_id"` - ArcVmUuid string `tfschema:"arc_vm_uuid"` - Description string `tfschema:"description"` + Name string `tfschema:"name"` + StorageMoverId string `tfschema:"storage_mover_id"` + ArcVirtualMachineId string `tfschema:"arc_virtual_machine_id"` + ArcVmUuid string `tfschema:"arc_vm_uuid"` + Description string `tfschema:"description"` } type StorageMoverAgentResource struct{} @@ -47,7 +47,7 @@ func (r StorageMoverAgentResource) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: validation.StringIsNotEmpty, }, - "arc_resource_id": { + "arc_virtual_machine_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, @@ -108,7 +108,7 @@ func (r StorageMoverAgentResource) Create() sdk.ResourceFunc { properties := agents.Agent{ Properties: agents.AgentProperties{ - ArcResourceId: model.ArcResourceId, + ArcResourceId: model.ArcVirtualMachineId, ArcVMUuid: model.ArcVmUuid, }, } @@ -185,27 +185,21 @@ func (r StorageMoverAgentResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", *id, err) } - model := resp.Model - if model == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - state := StorageMoverAgentResourceModel{ Name: id.AgentName, StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), } - properties := &model.Properties + if model := resp.Model; model != nil { + state.ArcVmUuid = model.Properties.ArcVMUuid + state.ArcVirtualMachineId = model.Properties.ArcResourceId - state.ArcVmUuid = properties.ArcVMUuid - - state.ArcResourceId = properties.ArcResourceId - - des := "" - if properties.Description != nil { - des = *properties.Description + des := "" + if model.Properties.Description != nil { + des = *model.Properties.Description + } + state.Description = des } - state.Description = des return metadata.Encode(&state) }, diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go index f2187c194e18..dbb68e65a65f 100644 --- a/internal/services/storagemover/storage_mover_agent_resource_test.go +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -3,8 +3,11 @@ package storagemover_test import ( "context" "fmt" + "os" "testing" + "github.com/hashicorp/go-uuid" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -34,6 +37,7 @@ func TestAccStorageMoverAgent_basic(t *testing.T) { func TestAccStorageMoverAgent_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_storage_mover_agent", "test") r := StorageMoverAgentTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), @@ -98,35 +102,169 @@ func (r StorageMoverAgentTestResource) Exists(ctx context.Context, clients *clie } func (r StorageMoverAgentTestResource) template(data acceptance.TestData) string { + randomUUID, _ := uuid.GenerateUUID() return fmt.Sprintf(` -provider "azurerm" { - features {} -} + + +data "azurerm_client_config" "current" {} resource "azurerm_resource_group" "test" { - name = "acctest-rg-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestnw-%[1]d" + 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 = "internal" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test.name + address_prefixes = ["10.0.2.0/24"] +} + +resource "azurerm_network_interface" "test" { + name = "acctestnic-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + ip_configuration { + name = "internal" + subnet_id = azurerm_subnet.test.id + private_ip_address_allocation = "Dynamic" + public_ip_address_id = azurerm_public_ip.test.id + } +} + +resource "azurerm_network_security_group" "my_terraform_nsg" { + name = "myNetworkSecurityGroup" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + security_rule { + name = "SSH" + priority = 1001 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "22" + source_address_prefix = "*" + destination_address_prefix = "*" + } +} + +resource "azurerm_network_interface_security_group_association" "example" { + network_interface_id = azurerm_network_interface.test.id + network_security_group_id = azurerm_network_security_group.my_terraform_nsg.id +} + +resource "azurerm_public_ip" "test" { + name = "acctestpip-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + allocation_method = "Static" +} + +resource "azurerm_linux_virtual_machine" "test" { + name = "acctestVM-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + size = "Standard_F2" + admin_username = "adminuser" + admin_password = "TerraformTest01!" + provision_vm_agent = false + allow_extension_operations = false + disable_password_authentication = false + network_interface_ids = [ + azurerm_network_interface.test.id, + ] + + os_disk { + caching = "ReadWrite" + storage_account_type = "Standard_LRS" + } + + source_image_reference { + publisher = "Canonical" + offer = "UbuntuServer" + sku = "18.04-LTS" + version = "latest" + } + + connection { + type = "ssh" + host = azurerm_public_ip.test.ip_address + user = "adminuser" + password = "TerraformTest01!" + } + + provisioner "file" { + content = templatefile("scripts/install_arc.sh.tftpl", { + resource_group_name = azurerm_resource_group.test.name + uuid = "%[3]s" + location = azurerm_resource_group.test.location + tenant_id = data.azurerm_client_config.current.tenant_id + client_id = data.azurerm_client_config.current.client_id + client_secret = "%[4]s" + subscription_id = data.azurerm_client_config.current.subscription_id + }) + destination = "/home/adminuser/install_arc_agent.sh" + } + + provisioner "remote-exec" { + inline = [ + "sudo apt-get install -y python-ctypes", + "sudo sed -i 's/\r$//' /home/adminuser/install_arc_agent.sh", + "sudo chmod +x /home/adminuser/install_arc_agent.sh", + "bash /home/adminuser/install_arc_agent.sh", + ] + } +} + +data "azurerm_hybrid_compute_machine" "test" { + name = azurerm_linux_virtual_machine.test.name + resource_group_name = azurerm_resource_group.test.name + depends_on = [ + azurerm_linux_virtual_machine.test + ] } resource "azurerm_storage_mover" "test" { - name = "acctest-ssm-%d" + name = "acctest-ssm-%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location + depends_on = [ + data.azurerm_hybrid_compute_machine.test + ] } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) + +`, data.RandomInteger, data.Locations.Primary, randomUUID, os.Getenv("ARM_CLIENT_SECRET")) } func (r StorageMoverAgentTestResource) basic(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } +} + %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" - arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid } `, template, data.RandomInteger) } @@ -134,15 +272,15 @@ resource "azurerm_storage_mover_agent" "test" { func (r StorageMoverAgentTestResource) requiresImport(data acceptance.TestData) string { config := r.basic(data) return fmt.Sprintf(` - %s resource "azurerm_storage_mover_agent" "import" { - name = azurerm_storage_mover_agent.test.name - storage_mover_id = azurerm_storage_mover_agent.test.storage_mover_id - arc_resource_id = azurerm_storage_mover_agent.test.arc_resource_id - arc_vm_uuid = azurerm_storage_mover_agent.test.arc_vm_uuid + name = azurerm_storage_mover_agent.test.name + storage_mover_id = azurerm_storage_mover_agent.test.storage_mover_id + arc_virtual_machine_id = azurerm_storage_mover_agent.test.arc_virtual_machine_id + arc_vm_uuid = azurerm_storage_mover_agent.test.arc_vm_uuid } + `, config) } @@ -150,14 +288,22 @@ func (r StorageMoverAgentTestResource) complete(data acceptance.TestData) string template := r.template(data) return fmt.Sprintf(` +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } +} + %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" - arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" - description = "Example Agent Description" + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid + description = "Example Agent Description" } `, template, data.RandomInteger) } @@ -166,14 +312,22 @@ func (r StorageMoverAgentTestResource) update(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } +} + %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_resource_id = "${azurerm_resource_group.test.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" - arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" - description = "Update Example Agent Description" + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid + description = "Update Example Agent Description" } `, template, data.RandomInteger) diff --git a/website/docs/r/storage_mover_agent.html.markdown b/website/docs/r/storage_mover_agent.html.markdown index 3d89fedab231..b4aabed50634 100644 --- a/website/docs/r/storage_mover_agent.html.markdown +++ b/website/docs/r/storage_mover_agent.html.markdown @@ -8,14 +8,14 @@ description: |- # azurerm_storage_mover_agent -Manages a Storage Mover Agents. +Manages a Storage Mover Agent. ## Example Usage ```hcl resource "azurerm_resource_group" "example" { name = "example-resources" - location = "West Europe" + location = "East US" } resource "azurerm_storage_mover" "example" { @@ -24,11 +24,11 @@ resource "azurerm_storage_mover" "example" { } resource "azurerm_storage_mover_agent" "example" { - name = "example-sa" - storage_mover_id = azurerm_storage_mover.example.id - arc_resource_id = "${azurerm_resource_group.example.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" - arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" - description = "Example Agent Description" + name = "example-sa" + storage_mover_id = azurerm_storage_mover.example.id + arc_virtual_machine_id = "${azurerm_resource_group.example.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + description = "Example Agent Description" } ``` @@ -38,13 +38,13 @@ The following arguments are supported: * `name` - (Required) Specifies the name which should be used for this Storage Mover Agent. Changing this forces a new resource to be created. -* `arc_resource_id` - (Required) Specifies the fully qualified resource ID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. +* `arc_virtual_machine_id` - (Required) Specifies the fully qualified ID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. -* `arc_vm_uuid` - (Required) Specifies the VM UUID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. +* `arc_vm_uuid` - (Required) Specifies the Hybrid Compute resource's unique SMBIOS ID. Changing this forces a new resource to be created. -* `storage_mover_id` - (Required) Specifies the ID of the Storage Mover. Changing this forces a new resource to be created. +* `storage_mover_id` - (Required) Specifies the ID of the Storage Mover that this Agent should be connected to. Changing this forces a new resource to be created. -* `description` - (Optional) A description for the Storage Mover Agent. +* `description` - (Optional) Specifies a description for this Storage Mover Agent. ## Attributes Reference diff --git a/website/docs/r/storage_mover_endpoint.html.markdown b/website/docs/r/storage_mover_endpoint.html.markdown deleted file mode 100644 index 3a0ffdd19b04..000000000000 --- a/website/docs/r/storage_mover_endpoint.html.markdown +++ /dev/null @@ -1,70 +0,0 @@ ---- -subcategory: "storagemover" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_storagemover_endpoint" -description: |- - Manages a Storagemover Endpoints. ---- - -# azurerm_storagemover_endpoint - -Manages a Storagemover Endpoints. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_storagemover_storage_mover" "example" { - name = "example-ssm" - resource_group_name = azurerm_resource_group.example.name -} - -resource "azurerm_storagemover_endpoint" "example" { - name = "example-se" - storagemover_storage_mover_id = azurerm_storagemover_storage_mover.test.id - description = "" - endpoint_type = "" - -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) Specifies the name which should be used for this Storagemover Endpoints. Changing this forces a new Storagemover Endpoints to be created. - -* `storagemover_storage_mover_id` - (Required) Specifies the ID of the Storagemover Endpoints. Changing this forces a new Storagemover Endpoints to be created. - -* `endpoint_type` - (Required) Specifies the Endpoint resource type. Changing this forces a new Storagemover Endpoints to be created. - -* `description` - (Optional) A description for the Endpoint. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the Storagemover Endpoints. - - - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 30 minutes) Used when creating the Storagemover Endpoints. -* `read` - (Defaults to 5 minutes) Used when retrieving the Storagemover Endpoints. -* `update` - (Defaults to 30 minutes) Used when updating the Storagemover Endpoints. -* `delete` - (Defaults to 30 minutes) Used when deleting the Storagemover Endpoints. - -## Import - -Storagemover Endpoints can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_storagemover_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/endpoints/endpoint1 -``` From bda7d85233c8f6c58b7909957421280d185900ea Mon Sep 17 00:00:00 2001 From: elena Date: Thu, 13 Apr 2023 17:34:28 +0800 Subject: [PATCH 5/7] updat code --- .../storage_mover_agent_resource_test.go | 15 ++++----- .../2023-03-01/agents/constants.go | 32 ++++++++++++++++++- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go index dbb68e65a65f..b14b529275cc 100644 --- a/internal/services/storagemover/storage_mover_agent_resource_test.go +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -226,20 +226,17 @@ resource "azurerm_linux_virtual_machine" "test" { } } -data "azurerm_hybrid_compute_machine" "test" { - name = azurerm_linux_virtual_machine.test.name - resource_group_name = azurerm_resource_group.test.name - depends_on = [ - azurerm_linux_virtual_machine.test - ] -} - resource "azurerm_storage_mover" "test" { name = "acctest-ssm-%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location +} + +data "azurerm_hybrid_compute_machine" "test" { + name = azurerm_linux_virtual_machine.test.name + resource_group_name = azurerm_resource_group.test.name depends_on = [ - data.azurerm_hybrid_compute_machine.test + azurerm_linux_virtual_machine.test, azurerm_storage_mover.test ] } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go index 9566d6a15388..477acf962fde 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents/constants.go @@ -1,6 +1,10 @@ package agents -import "strings" +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. @@ -27,6 +31,19 @@ func PossibleValuesForAgentStatus() []string { } } +func (s *AgentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAgentStatus(input string) (*AgentStatus, error) { vals := map[string]AgentStatus{ "executing": AgentStatusExecuting, @@ -57,6 +74,19 @@ func PossibleValuesForProvisioningState() []string { } } +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{ "succeeded": ProvisioningStateSucceeded, From 574a8c28afad07e3cd682797d1895c951c01330d Mon Sep 17 00:00:00 2001 From: elena Date: Thu, 20 Apr 2023 10:47:06 +0800 Subject: [PATCH 6/7] update code --- .../storage_mover_agent_resource.go | 12 +++--- .../storage_mover_agent_resource_test.go | 40 ++++++++++--------- .../docs/r/storage_mover_agent.html.markdown | 12 +++--- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/internal/services/storagemover/storage_mover_agent_resource.go b/internal/services/storagemover/storage_mover_agent_resource.go index 43e04af4dbd4..ab4ff76cbf30 100644 --- a/internal/services/storagemover/storage_mover_agent_resource.go +++ b/internal/services/storagemover/storage_mover_agent_resource.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents" "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" @@ -18,7 +20,7 @@ type StorageMoverAgentResourceModel struct { Name string `tfschema:"name"` StorageMoverId string `tfschema:"storage_mover_id"` ArcVirtualMachineId string `tfschema:"arc_virtual_machine_id"` - ArcVmUuid string `tfschema:"arc_vm_uuid"` + ArcVmUuid string `tfschema:"arc_virtual_machine_uuid"` Description string `tfschema:"description"` } @@ -54,7 +56,7 @@ func (r StorageMoverAgentResource) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: computevalidate.HybridMachineID, }, - "arc_vm_uuid": { + "arc_virtual_machine_uuid": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, @@ -194,11 +196,7 @@ func (r StorageMoverAgentResource) Read() sdk.ResourceFunc { state.ArcVmUuid = model.Properties.ArcVMUuid state.ArcVirtualMachineId = model.Properties.ArcResourceId - des := "" - if model.Properties.Description != nil { - des = *model.Properties.Description - } - state.Description = des + state.Description = pointer.From(model.Properties.Description) } return metadata.Encode(&state) diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go index b14b529275cc..79386b8018e5 100644 --- a/internal/services/storagemover/storage_mover_agent_resource_test.go +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -247,6 +247,7 @@ func (r StorageMoverAgentTestResource) basic(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` + provider "azurerm" { features { resource_group { @@ -258,10 +259,10 @@ provider "azurerm" { %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id - arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_virtual_machine_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid } `, template, data.RandomInteger) } @@ -272,12 +273,13 @@ func (r StorageMoverAgentTestResource) requiresImport(data acceptance.TestData) %s resource "azurerm_storage_mover_agent" "import" { - name = azurerm_storage_mover_agent.test.name - storage_mover_id = azurerm_storage_mover_agent.test.storage_mover_id - arc_virtual_machine_id = azurerm_storage_mover_agent.test.arc_virtual_machine_id - arc_vm_uuid = azurerm_storage_mover_agent.test.arc_vm_uuid + name = azurerm_storage_mover_agent.test.name + storage_mover_id = azurerm_storage_mover_agent.test.storage_mover_id + arc_virtual_machine_id = azurerm_storage_mover_agent.test.arc_virtual_machine_id + arc_virtual_machine_uuid = azurerm_storage_mover_agent.test.arc_virtual_machine_uuid } + `, config) } @@ -285,6 +287,7 @@ func (r StorageMoverAgentTestResource) complete(data acceptance.TestData) string template := r.template(data) return fmt.Sprintf(` + provider "azurerm" { features { resource_group { @@ -296,11 +299,11 @@ provider "azurerm" { %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id - arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid - description = "Example Agent Description" + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_virtual_machine_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid + description = "Example Agent Description" } `, template, data.RandomInteger) } @@ -309,6 +312,7 @@ func (r StorageMoverAgentTestResource) update(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` + provider "azurerm" { features { resource_group { @@ -320,11 +324,11 @@ provider "azurerm" { %s resource "azurerm_storage_mover_agent" "test" { - name = "acctest-sa-%d" - storage_mover_id = azurerm_storage_mover.test.id - arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id - arc_vm_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid - description = "Update Example Agent Description" + name = "acctest-sa-%d" + storage_mover_id = azurerm_storage_mover.test.id + arc_virtual_machine_id = data.azurerm_hybrid_compute_machine.test.id + arc_virtual_machine_uuid = data.azurerm_hybrid_compute_machine.test.vm_uuid + description = "Update Example Agent Description" } `, template, data.RandomInteger) diff --git a/website/docs/r/storage_mover_agent.html.markdown b/website/docs/r/storage_mover_agent.html.markdown index b4aabed50634..7d5303292df7 100644 --- a/website/docs/r/storage_mover_agent.html.markdown +++ b/website/docs/r/storage_mover_agent.html.markdown @@ -24,11 +24,11 @@ resource "azurerm_storage_mover" "example" { } resource "azurerm_storage_mover_agent" "example" { - name = "example-sa" - storage_mover_id = azurerm_storage_mover.example.id - arc_virtual_machine_id = "${azurerm_resource_group.example.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" - arc_vm_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" - description = "Example Agent Description" + name = "example-sa" + storage_mover_id = azurerm_storage_mover.example.id + arc_virtual_machine_id = "${azurerm_resource_group.example.id}/providers/Microsoft.HybridCompute/machines/examples-hybridComputeName" + arc_virtual_machine_uuid = "3bb2c024-eba9-4d18-9e7a-1d772fcc5fe9" + description = "Example Agent Description" } ``` @@ -40,7 +40,7 @@ The following arguments are supported: * `arc_virtual_machine_id` - (Required) Specifies the fully qualified ID of the Hybrid Compute resource for the Storage Mover Agent. Changing this forces a new resource to be created. -* `arc_vm_uuid` - (Required) Specifies the Hybrid Compute resource's unique SMBIOS ID. Changing this forces a new resource to be created. +* `arc_virtual_machine_uuid` - (Required) Specifies the Hybrid Compute resource's unique SMBIOS ID. Changing this forces a new resource to be created. * `storage_mover_id` - (Required) Specifies the ID of the Storage Mover that this Agent should be connected to. Changing this forces a new resource to be created. From c039e94890e449dd65231c50575bfd22bfb1c01e Mon Sep 17 00:00:00 2001 From: elena Date: Thu, 20 Apr 2023 11:40:56 +0800 Subject: [PATCH 7/7] update code --- .../storagemover/storage_mover_agent_resource_test.go | 5 ++++- vendor/modules.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go index 79386b8018e5..23e44e602d1c 100644 --- a/internal/services/storagemover/storage_mover_agent_resource_test.go +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -230,13 +230,16 @@ resource "azurerm_storage_mover" "test" { name = "acctest-ssm-%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location + depends_on = [ + azurerm_linux_virtual_machine.test + ] } data "azurerm_hybrid_compute_machine" "test" { name = azurerm_linux_virtual_machine.test.name resource_group_name = azurerm_resource_group.test.name depends_on = [ - azurerm_linux_virtual_machine.test, azurerm_storage_mover.test + azurerm_storage_mover.test ] } diff --git a/vendor/modules.txt b/vendor/modules.txt index 426d0b5cbe94..bad5dd8692e0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -572,6 +572,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/storageacc github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableservice github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/tableserviceproperties github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2023-01-01/caches +github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2023-01-01/storagetargets github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/agents github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/diskpools