From 07c9c35269e2d0253022f14c2c33f258fbe7c69c Mon Sep 17 00:00:00 2001 From: elena Date: Tue, 11 Apr 2023 18:03:51 +0800 Subject: [PATCH 1/5] 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 9b6ed73d35c185b2fe650010e0ad1f6fac2ea38a Mon Sep 17 00:00:00 2001 From: elena Date: Wed, 19 Apr 2023 13:40:56 +0800 Subject: [PATCH 2/5] support new resource azurerm_storage_mover_project --- .../services/storagemover/client/client.go | 9 + .../services/storagemover/registration.go | 1 + .../storage_mover_project_resource.go | 204 ++++++++++++++++++ .../storage_mover_project_resource_test.go | 175 +++++++++++++++ .../2023-03-01/projects/README.md | 107 +++++++++ .../2023-03-01/projects/client.go | 26 +++ .../2023-03-01/projects/constants.go | 48 +++++ .../2023-03-01/projects/id_project.go | 140 ++++++++++++ .../2023-03-01/projects/id_storagemover.go | 127 +++++++++++ .../projects/method_createorupdate.go | 55 +++++ .../2023-03-01/projects/method_delete.go | 71 ++++++ .../2023-03-01/projects/method_get.go | 51 +++++ .../2023-03-01/projects/method_list.go | 89 ++++++++ .../2023-03-01/projects/method_update.go | 55 +++++ .../2023-03-01/projects/model_project.go | 16 ++ .../projects/model_projectproperties.go | 9 + .../projects/model_projectupdateparameters.go | 8 + .../projects/model_projectupdateproperties.go | 8 + .../2023-03-01/projects/predicates.go | 27 +++ .../2023-03-01/projects/version.go | 12 ++ .../r/storage_mover_project.html.markdown | 65 ++++++ 21 files changed, 1303 insertions(+) create mode 100644 internal/services/storagemover/storage_mover_project_resource.go create mode 100644 internal/services/storagemover/storage_mover_project_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_project.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_storagemover.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_project.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/version.go create mode 100644 website/docs/r/storage_mover_project.html.markdown diff --git a/internal/services/storagemover/client/client.go b/internal/services/storagemover/client/client.go index 3e27812b32d7..9aeb2d4b1769 100644 --- a/internal/services/storagemover/client/client.go +++ b/internal/services/storagemover/client/client.go @@ -5,6 +5,7 @@ import ( "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/projects" "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -13,6 +14,7 @@ type Client struct { StorageMoversClient *storagemovers.StorageMoversClient AgentsClient *agents.AgentsClient EndpointsClient *endpoints.EndpointsClient + ProjectsClient *projects.ProjectsClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -34,9 +36,16 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(endpointsClient.Client, o.Authorizers.ResourceManager) + projectsClient, err := projects.NewProjectsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Projects client: %+v", err) + } + o.Configure(projectsClient.Client, o.Authorizers.ResourceManager) + return &Client{ StorageMoversClient: storageMoversClient, AgentsClient: agentsClient, EndpointsClient: endpointsClient, + ProjectsClient: projectsClient, }, nil } diff --git a/internal/services/storagemover/registration.go b/internal/services/storagemover/registration.go index 3cc9cb1a3438..1593aa3ccc42 100644 --- a/internal/services/storagemover/registration.go +++ b/internal/services/storagemover/registration.go @@ -34,5 +34,6 @@ func (r Registration) Resources() []sdk.Resource { StorageMoverAgentResource{}, StorageMoverSourceEndpointResource{}, StorageMoverTargetEndpointResource{}, + StorageMoverProjectResource{}, } } diff --git a/internal/services/storagemover/storage_mover_project_resource.go b/internal/services/storagemover/storage_mover_project_resource.go new file mode 100644 index 000000000000..59d93cfbb928 --- /dev/null +++ b/internal/services/storagemover/storage_mover_project_resource.go @@ -0,0 +1,204 @@ +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/projects" + "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 StorageMoverProjectResourceModel struct { + Name string `tfschema:"name"` + StorageMoverId string `tfschema:"storage_mover_id"` + Description string `tfschema:"description"` +} + +type StorageMoverProjectResource struct{} + +var _ sdk.ResourceWithUpdate = StorageMoverProjectResource{} + +func (r StorageMoverProjectResource) ResourceType() string { + return "azurerm_storage_mover_project" +} + +func (r StorageMoverProjectResource) ModelObject() interface{} { + return &StorageMoverProjectResourceModel{} +} + +func (r StorageMoverProjectResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return projects.ValidateProjectID +} + +func (r StorageMoverProjectResource) 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, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } +} + +func (r StorageMoverProjectResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r StorageMoverProjectResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model StorageMoverProjectResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.StorageMover.ProjectsClient + storageMoverId, err := storagemovers.ParseStorageMoverID(model.StorageMoverId) + if err != nil { + return err + } + + id := projects.NewProjectID(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 := &projects.Project{ + Properties: &projects.ProjectProperties{}, + } + + 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 StorageMoverProjectResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.ProjectsClient + + id, err := projects.ParseProjectID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model StorageMoverProjectResourceModel + 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 StorageMoverProjectResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.ProjectsClient + + id, err := projects.ParseProjectID(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) + } + + state := StorageMoverProjectResourceModel{ + Name: id.ProjectName, + StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(), + } + + if resp.Model != nil { + if properties := resp.Model.Properties; properties != nil { + if properties.Description != nil { + state.Description = *properties.Description + } + } + } + + return metadata.Encode(&state) + }, + } +} + +func (r StorageMoverProjectResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.ProjectsClient + + id, err := projects.ParseProjectID(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_project_resource_test.go b/internal/services/storagemover/storage_mover_project_resource_test.go new file mode 100644 index 000000000000..32d9d8e9bff6 --- /dev/null +++ b/internal/services/storagemover/storage_mover_project_resource_test.go @@ -0,0 +1,175 @@ +package storagemover_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects" + + "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 StorageMoverProjectTestResource struct{} + +func TestAccStorageMoverProject_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_project", "test") + r := StorageMoverProjectTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverProject_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_project", "test") + r := StorageMoverProjectTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccStorageMoverProject_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_project", "test") + r := StorageMoverProjectTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverProject_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_project", "test") + r := StorageMoverProjectTestResource{} + 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 StorageMoverProjectTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := projects.ParseProjectID(state.ID) + if err != nil { + return nil, err + } + + client := clients.StorageMover.ProjectsClient + 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 StorageMoverProjectTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +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 StorageMoverProjectTestResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_storage_mover_project" "test" { + name = "acctest-sp-%d" + storage_mover_id = azurerm_storage_mover.test.id +} +`, template, data.RandomInteger) +} + +func (r StorageMoverProjectTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_storage_mover_project" "import" { + name = azurerm_storage_mover_project.test.name + storage_mover_id = azurerm_storage_mover.test.id +} +`, config) +} + +func (r StorageMoverProjectTestResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_storage_mover_project" "test" { + name = "acctest-sp-%d" + storage_mover_id = azurerm_storage_mover.test.id + description = "Example Project Description" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverProjectTestResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_storage_mover_project" "test" { + name = "acctest-sp-%d" + storage_mover_id = azurerm_storage_mover.test.id + description = "Update example Project Description" +} +`, template, data.RandomInteger) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/README.md new file mode 100644 index 000000000000..3e28ba82de07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects` Documentation + +The `projects` 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/projects" +``` + + +### Client Initialization + +```go +client := projects.NewProjectsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProjectsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := projects.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue") + +payload := projects.Project{ + // ... +} + + +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: `ProjectsClient.Delete` + +```go +ctx := context.TODO() +id := projects.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProjectsClient.Get` + +```go +ctx := context.TODO() +id := projects.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue") + +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: `ProjectsClient.List` + +```go +ctx := context.TODO() +id := projects.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: `ProjectsClient.Update` + +```go +ctx := context.TODO() +id := projects.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue") + +payload := projects.ProjectUpdateParameters{ + // ... +} + + +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/projects/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/client.go new file mode 100644 index 000000000000..7ca9b42b2ddb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/client.go @@ -0,0 +1,26 @@ +package projects + +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 ProjectsClient struct { + Client *resourcemanager.Client +} + +func NewProjectsClientWithBaseURI(api environments.Api) (*ProjectsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "projects", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProjectsClient: %+v", err) + } + + return &ProjectsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/constants.go new file mode 100644 index 000000000000..d1cacb09be70 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/constants.go @@ -0,0 +1,48 @@ +package projects + +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 ProvisioningState string + +const ( + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateSucceeded), + } +} + +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, + } + 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/projects/id_project.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_project.go new file mode 100644 index 000000000000..785547d0719c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_project.go @@ -0,0 +1,140 @@ +package projects + +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 = ProjectId{} + +// ProjectId is a struct representing the Resource ID for a Project +type ProjectId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string + ProjectName string +} + +// NewProjectID returns a new ProjectId struct +func NewProjectID(subscriptionId string, resourceGroupName string, storageMoverName string, projectName string) ProjectId { + return ProjectId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + ProjectName: projectName, + } +} + +// ParseProjectID parses 'input' into a ProjectId +func ParseProjectID(input string) (*ProjectId, error) { + parser := resourceids.NewParserFromResourceIdType(ProjectId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProjectId{} + + 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.ProjectName, ok = parsed.Parsed["projectName"]; !ok { + return nil, fmt.Errorf("the segment 'projectName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProjectIDInsensitively parses 'input' case-insensitively into a ProjectId +// note: this method should only be used for API response data and not user input +func ParseProjectIDInsensitively(input string) (*ProjectId, error) { + parser := resourceids.NewParserFromResourceIdType(ProjectId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProjectId{} + + 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.ProjectName, ok = parsed.Parsed["projectName"]; !ok { + return nil, fmt.Errorf("the segment 'projectName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProjectID checks that 'input' can be parsed as a Project ID +func ValidateProjectID(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 := ParseProjectID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Project ID +func (id ProjectId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s/projects/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.ProjectName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Project ID +func (id ProjectId) 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("staticProjects", "projects", "projects"), + resourceids.UserSpecifiedSegment("projectName", "projectValue"), + } +} + +// String returns a human-readable description of this Project ID +func (id ProjectId) 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("Project Name: %q", id.ProjectName), + } + return fmt.Sprintf("Project (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_storagemover.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_storagemover.go new file mode 100644 index 000000000000..4ebc57617d79 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/id_storagemover.go @@ -0,0 +1,127 @@ +package projects + +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/projects/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_createorupdate.go new file mode 100644 index 000000000000..4b7416ff77d7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_createorupdate.go @@ -0,0 +1,55 @@ +package projects + +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 *Project +} + +// CreateOrUpdate ... +func (c ProjectsClient) CreateOrUpdate(ctx context.Context, id ProjectId, input Project) (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/projects/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_delete.go new file mode 100644 index 000000000000..035d45e9b493 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_delete.go @@ -0,0 +1,71 @@ +package projects + +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 ProjectsClient) Delete(ctx context.Context, id ProjectId) (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 ProjectsClient) DeleteThenPoll(ctx context.Context, id ProjectId) 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/projects/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_get.go new file mode 100644 index 000000000000..0d6a8be890f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_get.go @@ -0,0 +1,51 @@ +package projects + +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 *Project +} + +// Get ... +func (c ProjectsClient) Get(ctx context.Context, id ProjectId) (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/projects/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_list.go new file mode 100644 index 000000000000..197fe6f84a5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_list.go @@ -0,0 +1,89 @@ +package projects + +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 *[]Project +} + +type ListCompleteResult struct { + Items []Project +} + +// List ... +func (c ProjectsClient) 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/projects", 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 *[]Project `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 ProjectsClient) ListComplete(ctx context.Context, id StorageMoverId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProjectOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProjectsClient) ListCompleteMatchingPredicate(ctx context.Context, id StorageMoverId, predicate ProjectOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Project, 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/projects/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_update.go new file mode 100644 index 000000000000..007ea17451a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/method_update.go @@ -0,0 +1,55 @@ +package projects + +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 *Project +} + +// Update ... +func (c ProjectsClient) Update(ctx context.Context, id ProjectId, input ProjectUpdateParameters) (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/projects/model_project.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_project.go new file mode 100644 index 000000000000..1694688d12fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_project.go @@ -0,0 +1,16 @@ +package projects + +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 Project struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProjectProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectproperties.go new file mode 100644 index 000000000000..6c92c8d003bb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectproperties.go @@ -0,0 +1,9 @@ +package projects + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProjectProperties struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateparameters.go new file mode 100644 index 000000000000..95afcfb18ee6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateparameters.go @@ -0,0 +1,8 @@ +package projects + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProjectUpdateParameters struct { + Properties *ProjectUpdateProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateproperties.go new file mode 100644 index 000000000000..6b4de49fe813 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/model_projectupdateproperties.go @@ -0,0 +1,8 @@ +package projects + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProjectUpdateProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/predicates.go new file mode 100644 index 000000000000..eda15dd637d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/predicates.go @@ -0,0 +1,27 @@ +package projects + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProjectOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ProjectOperationPredicate) Matches(input Project) 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/projects/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/version.go new file mode 100644 index 000000000000..e56f0693d3e7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects/version.go @@ -0,0 +1,12 @@ +package projects + +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/projects/%s", defaultApiVersion) +} diff --git a/website/docs/r/storage_mover_project.html.markdown b/website/docs/r/storage_mover_project.html.markdown new file mode 100644 index 000000000000..4dfc6f3f58d6 --- /dev/null +++ b/website/docs/r/storage_mover_project.html.markdown @@ -0,0 +1,65 @@ +--- +subcategory: "Storage Mover" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_storage_mover_project" +description: |- + Manages a Storage Mover Project. +--- + +# azurerm_storage_mover_project + +Manages a Storage Mover Project. + +## 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 + location = azurerm_resource_group.example.location +} + +resource "azurerm_storage_mover_project" "example" { + name = "example-sp" + storage_mover_id = azurerm_storage_mover.example.id + description = "Example Project Description" +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Storage Mover Project. Changing this forces a new resource to be created. + +* `storage_mover_id` - (Required) Specifies the ID of the storage mover for this Storage Mover Project. Changing this forces a new resource to be created. + +* `description` - (Optional) Specifies a description for this Storage Mover Project. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Storage Mover Project. + +## 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 Project. +* `read` - (Defaults to 5 minutes) Used when retrieving the Storage Mover Project. +* `update` - (Defaults to 30 minutes) Used when updating the Storage Mover Project. +* `delete` - (Defaults to 30 minutes) Used when deleting the Storage Mover Project. + +## Import + +Storage Mover Project can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_storage_mover_project.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/projects/project1 +``` From 18efa65538f9cc16358008c60261d40134be9cf3 Mon Sep 17 00:00:00 2001 From: elena Date: Wed, 19 Apr 2023 13:58:28 +0800 Subject: [PATCH 3/5] update code --- .../storagemover/storage_mover_project_resource.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/services/storagemover/storage_mover_project_resource.go b/internal/services/storagemover/storage_mover_project_resource.go index 59d93cfbb928..61d8a9b973f5 100644 --- a/internal/services/storagemover/storage_mover_project_resource.go +++ b/internal/services/storagemover/storage_mover_project_resource.go @@ -3,6 +3,7 @@ package storagemover import ( "context" "fmt" + "regexp" "time" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -38,10 +39,13 @@ func (r StorageMoverProjectResource) IDValidationFunc() pluginsdk.SchemaValidate func (r StorageMoverProjectResource) Arguments() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^[0-9a-zA-Z][-_0-9a-zA-Z]{0,63}$`), + `The name must be between 1 and 64 characters in length, begin with a letter or number, and may contain letters, numbers, dashes and underscore.`, + ), }, "storage_mover_id": { From 11be86d9fdafca9ed8eee2576d30dd5bdf0ff2f5 Mon Sep 17 00:00:00 2001 From: elena Date: Wed, 19 Apr 2023 14:21:58 +0800 Subject: [PATCH 4/5] update code --- vendor/modules.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/modules.txt b/vendor/modules.txt index 28d0bd9ffc75..cade73e5d625 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -576,6 +576,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2023-01-01/cache 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/endpoints +github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects 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 0b87a5adcdf75d1286dd951e2b7a0f1cc7193625 Mon Sep 17 00:00:00 2001 From: elena Date: Fri, 21 Apr 2023 10:31:24 +0800 Subject: [PATCH 5/5] update code --- .../storagemover/storage_mover_project_resource.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/storagemover/storage_mover_project_resource.go b/internal/services/storagemover/storage_mover_project_resource.go index 61d8a9b973f5..b24c5db04c11 100644 --- a/internal/services/storagemover/storage_mover_project_resource.go +++ b/internal/services/storagemover/storage_mover_project_resource.go @@ -6,6 +6,8 @@ import ( "regexp" "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/projects" "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/storagemovers" @@ -136,8 +138,8 @@ func (r StorageMoverProjectResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: model was nil", id) } - if metadata.ResourceData.HasChange("description") { - properties.Properties.Description = &model.Description + if metadata.ResourceData.HasChange("description") && properties.Properties != nil { + properties.Properties.Description = pointer.To(model.Description) } if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { @@ -176,9 +178,7 @@ func (r StorageMoverProjectResource) Read() sdk.ResourceFunc { if resp.Model != nil { if properties := resp.Model.Properties; properties != nil { - if properties.Description != nil { - state.Description = *properties.Description - } + state.Description = pointer.From(properties.Description) } }