From 8142bfc53d2adbc1658bf6562b472d53cc726653 Mon Sep 17 00:00:00 2001 From: elena Date: Wed, 19 Apr 2023 17:06:23 +0800 Subject: [PATCH] support new resource azurerm_storage_mover_job_definition --- .../services/storagemover/client/client.go | 26 +- .../services/storagemover/registration.go | 1 + .../storage_mover_agent_resource_test.go | 3 + .../storage_mover_job_definition_resource.go | 298 ++++++++++++++++++ ...rage_mover_job_definition_resource_test.go | 247 +++++++++++++++ .../2023-03-01/jobdefinitions/README.md | 139 ++++++++ .../2023-03-01/jobdefinitions/client.go | 26 ++ .../2023-03-01/jobdefinitions/constants.go | 148 +++++++++ .../jobdefinitions/id_jobdefinition.go | 153 +++++++++ .../2023-03-01/jobdefinitions/id_project.go | 140 ++++++++ .../jobdefinitions/method_createorupdate.go | 55 ++++ .../jobdefinitions/method_delete.go | 71 +++++ .../2023-03-01/jobdefinitions/method_get.go | 51 +++ .../2023-03-01/jobdefinitions/method_list.go | 89 ++++++ .../jobdefinitions/method_startjob.go | 52 +++ .../jobdefinitions/method_stopjob.go | 52 +++ .../jobdefinitions/method_update.go | 55 ++++ .../jobdefinitions/model_jobdefinition.go | 16 + .../model_jobdefinitionproperties.go | 21 ++ .../model_jobdefinitionupdateparameters.go | 8 + .../model_jobdefinitionupdateproperties.go | 10 + .../jobdefinitions/model_jobrunresourceid.go | 8 + .../2023-03-01/jobdefinitions/predicates.go | 27 ++ .../2023-03-01/jobdefinitions/version.go | 12 + vendor/modules.txt | 1 + ...storage_mover_job_definition.html.markdown | 123 ++++++++ 26 files changed, 1824 insertions(+), 8 deletions(-) create mode 100644 internal/services/storagemover/storage_mover_job_definition_resource.go create mode 100644 internal/services/storagemover/storage_mover_job_definition_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_jobdefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_project.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_startjob.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_stopjob.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobrunresourceid.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/version.go create mode 100644 website/docs/r/storage_mover_job_definition.html.markdown diff --git a/internal/services/storagemover/client/client.go b/internal/services/storagemover/client/client.go index 9aeb2d4b1769c..686076328a274 100644 --- a/internal/services/storagemover/client/client.go +++ b/internal/services/storagemover/client/client.go @@ -3,6 +3,8 @@ package client import ( "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions" + "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" @@ -11,10 +13,11 @@ import ( ) type Client struct { - StorageMoversClient *storagemovers.StorageMoversClient - AgentsClient *agents.AgentsClient - EndpointsClient *endpoints.EndpointsClient - ProjectsClient *projects.ProjectsClient + StorageMoversClient *storagemovers.StorageMoversClient + AgentsClient *agents.AgentsClient + EndpointsClient *endpoints.EndpointsClient + ProjectsClient *projects.ProjectsClient + JobDefinitionsClient *jobdefinitions.JobDefinitionsClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -42,10 +45,17 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(projectsClient.Client, o.Authorizers.ResourceManager) + jobDefinitionsClient, err := jobdefinitions.NewJobDefinitionsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Job Definitions client: %+v", err) + } + o.Configure(jobDefinitionsClient.Client, o.Authorizers.ResourceManager) + return &Client{ - StorageMoversClient: storageMoversClient, - AgentsClient: agentsClient, - EndpointsClient: endpointsClient, - ProjectsClient: projectsClient, + StorageMoversClient: storageMoversClient, + AgentsClient: agentsClient, + EndpointsClient: endpointsClient, + ProjectsClient: projectsClient, + JobDefinitionsClient: jobDefinitionsClient, }, nil } diff --git a/internal/services/storagemover/registration.go b/internal/services/storagemover/registration.go index 1593aa3ccc426..4213595acf77e 100644 --- a/internal/services/storagemover/registration.go +++ b/internal/services/storagemover/registration.go @@ -35,5 +35,6 @@ func (r Registration) Resources() []sdk.Resource { StorageMoverSourceEndpointResource{}, StorageMoverTargetEndpointResource{}, StorageMoverProjectResource{}, + StorageMoverJobDefinitionResource{}, } } diff --git a/internal/services/storagemover/storage_mover_agent_resource_test.go b/internal/services/storagemover/storage_mover_agent_resource_test.go index 00725cc8dcd7c..0e05476858cdc 100644 --- a/internal/services/storagemover/storage_mover_agent_resource_test.go +++ b/internal/services/storagemover/storage_mover_agent_resource_test.go @@ -104,6 +104,8 @@ func (r StorageMoverAgentTestResource) template(data acceptance.TestData) string return fmt.Sprintf(` + + data "azurerm_client_config" "current" {} resource "azurerm_resource_group" "test" { @@ -241,6 +243,7 @@ data "azurerm_hybrid_compute_machine" "test" { ] } + `, data.RandomInteger, data.Locations.Primary, randomUUID, os.Getenv("ARM_CLIENT_SECRET")) } diff --git a/internal/services/storagemover/storage_mover_job_definition_resource.go b/internal/services/storagemover/storage_mover_job_definition_resource.go new file mode 100644 index 0000000000000..dca13a59c8f7c --- /dev/null +++ b/internal/services/storagemover/storage_mover_job_definition_resource.go @@ -0,0 +1,298 @@ +package storagemover + +import ( + "context" + "fmt" + "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/jobdefinitions" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/projects" + "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 StorageMoverJobDefinitionResourceModel struct { + Name string `tfschema:"name"` + StorageMoverProjectId string `tfschema:"storage_mover_project_id"` + SourceName string `tfschema:"source_name"` + TargetName string `tfschema:"target_name"` + CopyMode jobdefinitions.CopyMode `tfschema:"copy_mode"` + SourceSubpath string `tfschema:"source_sub_path"` + TargetSubpath string `tfschema:"target_sub_path"` + AgentName string `tfschema:"agent_name"` + Description string `tfschema:"description"` +} + +type StorageMoverJobDefinitionResource struct{} + +var _ sdk.ResourceWithUpdate = StorageMoverJobDefinitionResource{} + +func (r StorageMoverJobDefinitionResource) ResourceType() string { + return "azurerm_storage_mover_job_definition" +} + +func (r StorageMoverJobDefinitionResource) ModelObject() interface{} { + return &StorageMoverJobDefinitionResourceModel{} +} + +func (r StorageMoverJobDefinitionResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return jobdefinitions.ValidateJobDefinitionID +} + +func (r StorageMoverJobDefinitionResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + 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_project_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: projects.ValidateProjectID, + }, + + "source_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "target_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "copy_mode": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(jobdefinitions.CopyModeMirror), + string(jobdefinitions.CopyModeAdditive), + }, false), + }, + + "source_sub_path": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "target_sub_path": { + Type: pluginsdk.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "agent_name": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } +} + +func (r StorageMoverJobDefinitionResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r StorageMoverJobDefinitionResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model StorageMoverJobDefinitionResourceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.StorageMover.JobDefinitionsClient + projectId, err := projects.ParseProjectID(model.StorageMoverProjectId) + if err != nil { + return err + } + + id := jobdefinitions.NewJobDefinitionID(projectId.SubscriptionId, projectId.ResourceGroupName, projectId.StorageMoverName, projectId.ProjectName, 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 := jobdefinitions.JobDefinition{ + Properties: jobdefinitions.JobDefinitionProperties{ + CopyMode: model.CopyMode, + SourceName: model.SourceName, + TargetName: model.TargetName, + }, + } + + if model.AgentName != "" { + properties.Properties.AgentName = &model.AgentName + } + + if model.Description != "" { + properties.Properties.Description = &model.Description + } + + if model.TargetSubpath != "" { + properties.Properties.TargetSubpath = &model.TargetSubpath + } + + if model.SourceSubpath != "" { + properties.Properties.SourceSubpath = &model.SourceSubpath + } + + if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r StorageMoverJobDefinitionResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.JobDefinitionsClient + + id, err := jobdefinitions.ParseJobDefinitionID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model StorageMoverJobDefinitionResourceModel + 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("agent_name") { + if model.AgentName != "" { + properties.Properties.AgentName = &model.AgentName + } else { + properties.Properties.AgentName = nil + } + } + + if metadata.ResourceData.HasChange("copy_mode") { + properties.Properties.CopyMode = model.CopyMode + } + + if metadata.ResourceData.HasChange("agent_name") { + properties.Properties.AgentName = pointer.To(model.AgentName) + } + + if metadata.ResourceData.HasChange("description") { + properties.Properties.Description = pointer.To(model.Description) + } + + if _, err := client.CreateOrUpdate(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r StorageMoverJobDefinitionResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.JobDefinitionsClient + + id, err := jobdefinitions.ParseJobDefinitionID(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 := StorageMoverJobDefinitionResourceModel{ + Name: id.JobDefinitionName, + StorageMoverProjectId: projects.NewProjectID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.ProjectName).ID(), + } + + if v := resp.Model; v != nil { + state.AgentName = pointer.From(v.Properties.AgentName) + + state.CopyMode = v.Properties.CopyMode + + state.Description = pointer.From(v.Properties.Description) + + state.SourceName = v.Properties.SourceName + + state.SourceSubpath = pointer.From(v.Properties.SourceSubpath) + + state.TargetName = v.Properties.TargetName + + state.TargetSubpath = pointer.From(v.Properties.TargetSubpath) + } + return metadata.Encode(&state) + }, + } +} + +func (r StorageMoverJobDefinitionResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.StorageMover.JobDefinitionsClient + + id, err := jobdefinitions.ParseJobDefinitionID(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_job_definition_resource_test.go b/internal/services/storagemover/storage_mover_job_definition_resource_test.go new file mode 100644 index 0000000000000..f9886a01d9d2d --- /dev/null +++ b/internal/services/storagemover/storage_mover_job_definition_resource_test.go @@ -0,0 +1,247 @@ +package storagemover_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions" + + "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 StorageMoverJobDefinitionTestResource struct{} + +func TestAccStorageMoverJobDefinition_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_job_definition", "test") + r := StorageMoverJobDefinitionTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverJobDefinition_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_job_definition", "test") + r := StorageMoverJobDefinitionTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccStorageMoverJobDefinition_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_job_definition", "test") + r := StorageMoverJobDefinitionTestResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccStorageMoverJobDefinition_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_mover_job_definition", "test") + r := StorageMoverJobDefinitionTestResource{} + 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 StorageMoverJobDefinitionTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := jobdefinitions.ParseJobDefinitionID(state.ID) + if err != nil { + return nil, err + } + + client := clients.StorageMover.JobDefinitionsClient + 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 StorageMoverJobDefinitionTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` + + +%[1]s + +resource "azurerm_storage_mover_agent" "test" { + name = "acctest-sa-%[2]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 +} + +resource "azurerm_storage_account" "test" { + name = "accsa%[4]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + allow_nested_items_to_be_public = true +} + +resource "azurerm_storage_container" "test" { + name = "acccontainer%[4]s" + storage_account_name = azurerm_storage_account.test.name + container_access_type = "blob" +} + +resource "azurerm_storage_mover_target_endpoint" "test" { + name = "acctest-smte-%[2]d" + storage_mover_id = azurerm_storage_mover.test.id + storage_account_id = azurerm_storage_account.test.id + storage_container_name = azurerm_storage_container.test.name +} + +resource "azurerm_storage_mover_source_endpoint" "test" { + name = "acctest-smse-%[2]d" + storage_mover_id = azurerm_storage_mover.test.id + host = "192.168.0.1" +} + +resource "azurerm_storage_mover_project" "test" { + name = "acctest-sp-%[2]d" + storage_mover_id = azurerm_storage_mover.test.id +} +`, StorageMoverAgentTestResource{}.template(data), data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +func (r StorageMoverJobDefinitionTestResource) 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_job_definition" "test" { + name = "acctest-sjd-%d" + storage_mover_project_id = azurerm_storage_mover_project.test.id + agent_name = azurerm_storage_mover_agent.test.name + copy_mode = "Additive" + source_name = azurerm_storage_mover_source_endpoint.test.name + target_name = azurerm_storage_mover_target_endpoint.test.name +} +`, template, data.RandomInteger) +} + +func (r StorageMoverJobDefinitionTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_storage_mover_job_definition" "import" { + name = azurerm_storage_mover_job_definition.test.name + storage_mover_project_id = azurerm_storage_mover_job_definition.test.storage_mover_project_id + agent_name = azurerm_storage_mover_job_definition.test.agent_name + copy_mode = azurerm_storage_mover_job_definition.test.copy_mode + source_name = azurerm_storage_mover_job_definition.test.source_name + target_name = azurerm_storage_mover_job_definition.test.target_name +} +`, config) +} + +func (r StorageMoverJobDefinitionTestResource) 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_job_definition" "test" { + name = "acctest-sjd-%d" + storage_mover_project_id = azurerm_storage_mover_project.test.id + agent_name = azurerm_storage_mover_agent.test.name + copy_mode = "Additive" + source_name = azurerm_storage_mover_source_endpoint.test.name + source_sub_path = "/" + target_name = azurerm_storage_mover_target_endpoint.test.name + target_sub_path = "/" + description = "Example Job Definition Description" +} +`, template, data.RandomInteger) +} + +func (r StorageMoverJobDefinitionTestResource) 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" "test2" { + name = "acctest-sa2-%[2]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 +} + +resource "azurerm_storage_mover_job_definition" "test" { + name = "acctest-sjd-%[2]d" + storage_mover_project_id = azurerm_storage_mover_project.test.id + agent_name = azurerm_storage_mover_agent.test2.name + copy_mode = "Mirror" + source_name = azurerm_storage_mover_source_endpoint.test.name + source_sub_path = "/" + target_name = azurerm_storage_mover_target_endpoint.test.name + target_sub_path = "/" + description = "Update example Job Definition Description" +} +`, template, data.RandomInteger) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/README.md new file mode 100644 index 0000000000000..533f765ce8f80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/README.md @@ -0,0 +1,139 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions` Documentation + +The `jobdefinitions` 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/jobdefinitions" +``` + + +### Client Initialization + +```go +client := jobdefinitions.NewJobDefinitionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `JobDefinitionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +payload := jobdefinitions.JobDefinition{ + // ... +} + + +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: `JobDefinitionsClient.Delete` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobDefinitionsClient.Get` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +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: `JobDefinitionsClient.List` + +```go +ctx := context.TODO() +id := jobdefinitions.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue") + +// 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: `JobDefinitionsClient.StartJob` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +read, err := client.StartJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobDefinitionsClient.StopJob` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +read, err := client.StopJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobDefinitionsClient.Update` + +```go +ctx := context.TODO() +id := jobdefinitions.NewJobDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageMoverValue", "projectValue", "jobDefinitionValue") + +payload := jobdefinitions.JobDefinitionUpdateParameters{ + // ... +} + + +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/jobdefinitions/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/client.go new file mode 100644 index 0000000000000..b9093934f69a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/client.go @@ -0,0 +1,26 @@ +package jobdefinitions + +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 JobDefinitionsClient struct { + Client *resourcemanager.Client +} + +func NewJobDefinitionsClientWithBaseURI(api environments.Api) (*JobDefinitionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "jobdefinitions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating JobDefinitionsClient: %+v", err) + } + + return &JobDefinitionsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/constants.go new file mode 100644 index 0000000000000..3855f35ed9487 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/constants.go @@ -0,0 +1,148 @@ +package jobdefinitions + +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 CopyMode string + +const ( + CopyModeAdditive CopyMode = "Additive" + CopyModeMirror CopyMode = "Mirror" +) + +func PossibleValuesForCopyMode() []string { + return []string{ + string(CopyModeAdditive), + string(CopyModeMirror), + } +} + +func (s *CopyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCopyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCopyMode(input string) (*CopyMode, error) { + vals := map[string]CopyMode{ + "additive": CopyModeAdditive, + "mirror": CopyModeMirror, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyMode(input) + return &out, nil +} + +type JobRunStatus string + +const ( + JobRunStatusCancelRequested JobRunStatus = "CancelRequested" + JobRunStatusCanceled JobRunStatus = "Canceled" + JobRunStatusCanceling JobRunStatus = "Canceling" + JobRunStatusFailed JobRunStatus = "Failed" + JobRunStatusQueued JobRunStatus = "Queued" + JobRunStatusRunning JobRunStatus = "Running" + JobRunStatusStarted JobRunStatus = "Started" + JobRunStatusSucceeded JobRunStatus = "Succeeded" +) + +func PossibleValuesForJobRunStatus() []string { + return []string{ + string(JobRunStatusCancelRequested), + string(JobRunStatusCanceled), + string(JobRunStatusCanceling), + string(JobRunStatusFailed), + string(JobRunStatusQueued), + string(JobRunStatusRunning), + string(JobRunStatusStarted), + string(JobRunStatusSucceeded), + } +} + +func (s *JobRunStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobRunStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobRunStatus(input string) (*JobRunStatus, error) { + vals := map[string]JobRunStatus{ + "cancelrequested": JobRunStatusCancelRequested, + "canceled": JobRunStatusCanceled, + "canceling": JobRunStatusCanceling, + "failed": JobRunStatusFailed, + "queued": JobRunStatusQueued, + "running": JobRunStatusRunning, + "started": JobRunStatusStarted, + "succeeded": JobRunStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobRunStatus(input) + return &out, nil +} + +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/jobdefinitions/id_jobdefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_jobdefinition.go new file mode 100644 index 0000000000000..b08b79777d11b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_jobdefinition.go @@ -0,0 +1,153 @@ +package jobdefinitions + +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 = JobDefinitionId{} + +// JobDefinitionId is a struct representing the Resource ID for a Job Definition +type JobDefinitionId struct { + SubscriptionId string + ResourceGroupName string + StorageMoverName string + ProjectName string + JobDefinitionName string +} + +// NewJobDefinitionID returns a new JobDefinitionId struct +func NewJobDefinitionID(subscriptionId string, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string) JobDefinitionId { + return JobDefinitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageMoverName: storageMoverName, + ProjectName: projectName, + JobDefinitionName: jobDefinitionName, + } +} + +// ParseJobDefinitionID parses 'input' into a JobDefinitionId +func ParseJobDefinitionID(input string) (*JobDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(JobDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := JobDefinitionId{} + + 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) + } + + if id.JobDefinitionName, ok = parsed.Parsed["jobDefinitionName"]; !ok { + return nil, fmt.Errorf("the segment 'jobDefinitionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseJobDefinitionIDInsensitively parses 'input' case-insensitively into a JobDefinitionId +// note: this method should only be used for API response data and not user input +func ParseJobDefinitionIDInsensitively(input string) (*JobDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(JobDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := JobDefinitionId{} + + 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) + } + + if id.JobDefinitionName, ok = parsed.Parsed["jobDefinitionName"]; !ok { + return nil, fmt.Errorf("the segment 'jobDefinitionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateJobDefinitionID checks that 'input' can be parsed as a Job Definition ID +func ValidateJobDefinitionID(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 := ParseJobDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Job Definition ID +func (id JobDefinitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageMover/storageMovers/%s/projects/%s/jobDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName, id.ProjectName, id.JobDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Job Definition ID +func (id JobDefinitionId) 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"), + resourceids.StaticSegment("staticJobDefinitions", "jobDefinitions", "jobDefinitions"), + resourceids.UserSpecifiedSegment("jobDefinitionName", "jobDefinitionValue"), + } +} + +// String returns a human-readable description of this Job Definition ID +func (id JobDefinitionId) 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), + fmt.Sprintf("Job Definition Name: %q", id.JobDefinitionName), + } + return fmt.Sprintf("Job Definition (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_project.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_project.go new file mode 100644 index 0000000000000..e3d202fe19bd6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/id_project.go @@ -0,0 +1,140 @@ +package jobdefinitions + +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/jobdefinitions/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_createorupdate.go new file mode 100644 index 0000000000000..17735bfefcfce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_createorupdate.go @@ -0,0 +1,55 @@ +package jobdefinitions + +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 *JobDefinition +} + +// CreateOrUpdate ... +func (c JobDefinitionsClient) CreateOrUpdate(ctx context.Context, id JobDefinitionId, input JobDefinition) (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/jobdefinitions/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_delete.go new file mode 100644 index 0000000000000..7826ec39bcb72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_delete.go @@ -0,0 +1,71 @@ +package jobdefinitions + +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 JobDefinitionsClient) Delete(ctx context.Context, id JobDefinitionId) (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 JobDefinitionsClient) DeleteThenPoll(ctx context.Context, id JobDefinitionId) 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/jobdefinitions/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_get.go new file mode 100644 index 0000000000000..5df954aecaeac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_get.go @@ -0,0 +1,51 @@ +package jobdefinitions + +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 *JobDefinition +} + +// Get ... +func (c JobDefinitionsClient) Get(ctx context.Context, id JobDefinitionId) (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/jobdefinitions/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_list.go new file mode 100644 index 0000000000000..c1793d8b223cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_list.go @@ -0,0 +1,89 @@ +package jobdefinitions + +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 *[]JobDefinition +} + +type ListCompleteResult struct { + Items []JobDefinition +} + +// List ... +func (c JobDefinitionsClient) List(ctx context.Context, id ProjectId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/jobDefinitions", 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 *[]JobDefinition `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 JobDefinitionsClient) ListComplete(ctx context.Context, id ProjectId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, JobDefinitionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobDefinitionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProjectId, predicate JobDefinitionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]JobDefinition, 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/jobdefinitions/method_startjob.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_startjob.go new file mode 100644 index 0000000000000..cce3ec9fbabeb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_startjob.go @@ -0,0 +1,52 @@ +package jobdefinitions + +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 StartJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JobRunResourceId +} + +// StartJob ... +func (c JobDefinitionsClient) StartJob(ctx context.Context, id JobDefinitionId) (result StartJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startJob", 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/jobdefinitions/method_stopjob.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_stopjob.go new file mode 100644 index 0000000000000..f48463d37f542 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_stopjob.go @@ -0,0 +1,52 @@ +package jobdefinitions + +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 StopJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JobRunResourceId +} + +// StopJob ... +func (c JobDefinitionsClient) StopJob(ctx context.Context, id JobDefinitionId) (result StopJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopJob", 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/jobdefinitions/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_update.go new file mode 100644 index 0000000000000..1b816208f442d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/method_update.go @@ -0,0 +1,55 @@ +package jobdefinitions + +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 *JobDefinition +} + +// Update ... +func (c JobDefinitionsClient) Update(ctx context.Context, id JobDefinitionId, input JobDefinitionUpdateParameters) (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/jobdefinitions/model_jobdefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinition.go new file mode 100644 index 0000000000000..d39a2ac7eb07a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinition.go @@ -0,0 +1,16 @@ +package jobdefinitions + +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 JobDefinition struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties JobDefinitionProperties `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/jobdefinitions/model_jobdefinitionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionproperties.go new file mode 100644 index 0000000000000..bb3accd550f79 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionproperties.go @@ -0,0 +1,21 @@ +package jobdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobDefinitionProperties struct { + AgentName *string `json:"agentName,omitempty"` + AgentResourceId *string `json:"agentResourceId,omitempty"` + CopyMode CopyMode `json:"copyMode"` + Description *string `json:"description,omitempty"` + LatestJobRunName *string `json:"latestJobRunName,omitempty"` + LatestJobRunResourceId *string `json:"latestJobRunResourceId,omitempty"` + LatestJobRunStatus *JobRunStatus `json:"latestJobRunStatus,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceName string `json:"sourceName"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + SourceSubpath *string `json:"sourceSubpath,omitempty"` + TargetName string `json:"targetName"` + TargetResourceId *string `json:"targetResourceId,omitempty"` + TargetSubpath *string `json:"targetSubpath,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateparameters.go new file mode 100644 index 0000000000000..834400983c47d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateparameters.go @@ -0,0 +1,8 @@ +package jobdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobDefinitionUpdateParameters struct { + Properties *JobDefinitionUpdateProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateproperties.go new file mode 100644 index 0000000000000..70d4debddf556 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobdefinitionupdateproperties.go @@ -0,0 +1,10 @@ +package jobdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobDefinitionUpdateProperties struct { + AgentName *string `json:"agentName,omitempty"` + CopyMode *CopyMode `json:"copyMode,omitempty"` + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobrunresourceid.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobrunresourceid.go new file mode 100644 index 0000000000000..d028b716733f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/model_jobrunresourceid.go @@ -0,0 +1,8 @@ +package jobdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobRunResourceId struct { + JobRunResourceId *string `json:"jobRunResourceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/predicates.go new file mode 100644 index 0000000000000..4a068ea77626c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/predicates.go @@ -0,0 +1,27 @@ +package jobdefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobDefinitionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p JobDefinitionOperationPredicate) Matches(input JobDefinition) 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/jobdefinitions/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/version.go new file mode 100644 index 0000000000000..b631aa2d405fc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2023-03-01/jobdefinitions/version.go @@ -0,0 +1,12 @@ +package jobdefinitions + +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/jobdefinitions/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e53c43c7c4b6..04b0e55a8e91a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -577,6 +577,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/jobdefinitions 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 diff --git a/website/docs/r/storage_mover_job_definition.html.markdown b/website/docs/r/storage_mover_job_definition.html.markdown new file mode 100644 index 0000000000000..e05e4ea83d279 --- /dev/null +++ b/website/docs/r/storage_mover_job_definition.html.markdown @@ -0,0 +1,123 @@ +--- +subcategory: "Storage Mover" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_storage_mover_job_definition" +description: |- + Manages a Storage Mover Job Definition. +--- + +# azurerm_storage_mover_job_definition + +Manages a Storage Mover Job Definition. + +## 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_agent" "example" { + name = "example-agent" + 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" +} + +resource "azurerm_storage_account" "example" { + name = "examplesa" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + account_tier = "Standard" + account_replication_type = "LRS" + allow_nested_items_to_be_public = true +} + +resource "azurerm_storage_container" "example" { + name = "acccontainer" + storage_account_name = azurerm_storage_account.example.name + container_access_type = "blob" +} + +resource "azurerm_storage_mover_target_endpoint" "example" { + name = "example-smte" + storage_mover_id = azurerm_storage_mover.example.id + storage_account_id = azurerm_storage_account.example.id + storage_container_name = azurerm_storage_container.example.name +} + +resource "azurerm_storage_mover_source_endpoint" "example" { + name = "example-smse" + storage_mover_id = azurerm_storage_mover.example.id + host = "192.168.0.1" +} + +resource "azurerm_storage_mover_project" "example" { + name = "example-sp" + storage_mover_id = azurerm_storage_mover.example.id +} + +resource "azurerm_storage_mover_job_definition" "example" { + name = "example-sjd" + storage_mover_project_id = azurerm_storage_mover_project.example.id + agent_name = azurerm_storage_mover_agent.example.name + copy_mode = "Additive" + source_name = azurerm_storage_mover_source_endpoint.example.name + source_sub_path = "/" + target_name = azurerm_storage_mover_target_endpoint.example.name + target_sub_path = "/" + description = "Example Job Definition Description" +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Storage Mover Job Definition. Changing this forces a new resource to be created. + +* `storage_mover_project_id` - (Required) Specifies the ID of the Storage Mover Project. Changing this forces a new resource to be created. + +* `source_name` - (Required) Specifies the name of the Storage Mover Source Endpoint. Changing this forces a new resource to be created. + +* `target_name` - (Required) Specifies the name of the Storage Mover target Endpoint. Changing this forces a new resource to be created. + +* `copy_mode` - (Required) Specifies the strategy to use for copy. Possible values are `Additive` and `Mirror`. + +* `source_sub_path` - (Optional) Specifies the sub path to use when reading from the Storage Mover Source Endpoint. Changing this forces a new resource to be created. + +* `target_sub_path` - (Optional) Specifies the sub path to use when writing to the Storage Mover Target Endpoint. Changing this forces a new resource to be created. + +* `agent_name` - (Optional) Specifies the name of the Storage Mover Agent to assign for new Job Runs of this Storage Mover Job Definition. + +* `description` - (Optional) Specifies a description for this Storage Mover Job Definition. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Storage Mover Job Definition. + +## 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 Job Definition. +* `read` - (Defaults to 5 minutes) Used when retrieving the Storage Mover Job Definition. +* `update` - (Defaults to 30 minutes) Used when updating the Storage Mover Job Definition. +* `delete` - (Defaults to 30 minutes) Used when deleting the Storage Mover Job Definition. + +## Import + +Storage Mover Job Definition can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_storage_mover_job_definition.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/projects/project1/jobDefinitions/jobDefinition1 +```