From c24fb0ebd2b80da60942e180531f4d71f7aed069 Mon Sep 17 00:00:00 2001 From: Paulo Marques Date: Mon, 22 Feb 2021 22:44:03 -0700 Subject: [PATCH] azurerm_netapp_volume - support the `data_protection_replication` block (#10610) Co-authored-by: kt This PR implements support for Cross-Region Replication (CRR) feature of ANF Volumes. Worth it to call out that since CRR is extremely sensitive on resources being complete, we extended usage of stateCOnf.WaitForState for all steps of volume creation/deletion. --- .../internal/services/netapp/client/client.go | 2 +- .../netapp/netapp_account_resource.go | 2 +- .../services/netapp/netapp_pool_resource.go | 2 +- .../netapp/netapp_snapshot_resource.go | 47 +- .../netapp/netapp_volume_data_source.go | 33 + .../services/netapp/netapp_volume_resource.go | 364 ++- .../netapp/netapp_volume_resource_test.go | 116 + examples/netapp/volume_crr/README.md | 5 + examples/netapp/volume_crr/main.tf | 143 + examples/netapp/volume_crr/variables.tf | 11 + .../mgmt/2019-10-01/netapp/CHANGELOG.md | 5 - .../netapp/mgmt/2019-10-01/netapp/models.go | 1411 -------- .../mgmt/2020-09-01/netapp/CHANGELOG.md | 5 + .../mgmt/2020-09-01/netapp/accountbackups.go | 313 ++ .../netapp/accounts.go | 65 +- .../mgmt/2020-09-01/netapp/backuppolicies.go | 525 +++ .../netapp/mgmt/2020-09-01/netapp/backups.go | 591 ++++ .../netapp/client.go | 2 +- .../netapp/enums.go | 70 + .../netapp/mgmt/2020-09-01/netapp/models.go | 2873 +++++++++++++++++ .../netapp/operations.go | 2 +- .../netapp/pools.go | 87 +- .../netapp/resource.go | 96 +- .../2020-09-01/netapp/snapshotpolicies.go | 587 ++++ .../netapp/snapshots.go | 120 +- .../netapp/vaults.go} | 48 +- .../netapp/version.go | 2 +- .../netapp/volumes.go | 762 ++++- vendor/modules.txt | 2 +- website/docs/r/netapp_snapshot.html.markdown | 2 - website/docs/r/netapp_volume.html.markdown | 27 + 31 files changed, 6639 insertions(+), 1681 deletions(-) create mode 100644 examples/netapp/volume_crr/README.md create mode 100644 examples/netapp/volume_crr/main.tf create mode 100644 examples/netapp/volume_crr/variables.tf delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/CHANGELOG.md delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/CHANGELOG.md create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accountbackups.go rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/accounts.go (91%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backuppolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backups.go rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/client.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/enums.go (60%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/models.go rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/operations.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/pools.go (86%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/resource.go (69%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshotpolicies.go rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/snapshots.go (79%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01/netapp/mounttargets.go => 2020-09-01/netapp/vaults.go} (59%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/version.go (94%) rename vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/{2019-10-01 => 2020-09-01}/netapp/volumes.go (56%) diff --git a/azurerm/internal/services/netapp/client/client.go b/azurerm/internal/services/netapp/client/client.go index fdffa5a2214d..5a6c36321f7a 100644 --- a/azurerm/internal/services/netapp/client/client.go +++ b/azurerm/internal/services/netapp/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" + "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/azurerm/internal/services/netapp/netapp_account_resource.go b/azurerm/internal/services/netapp/netapp_account_resource.go index 46fc694785b1..083c7591c4b6 100644 --- a/azurerm/internal/services/netapp/netapp_account_resource.go +++ b/azurerm/internal/services/netapp/netapp_account_resource.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" + "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/netapp/netapp_pool_resource.go b/azurerm/internal/services/netapp/netapp_pool_resource.go index 1786fed0ba37..4b9d76c781ff 100644 --- a/azurerm/internal/services/netapp/netapp_pool_resource.go +++ b/azurerm/internal/services/netapp/netapp_pool_resource.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" + "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/netapp/netapp_snapshot_resource.go b/azurerm/internal/services/netapp/netapp_snapshot_resource.go index e4f48525d0b1..ff84b8516d03 100644 --- a/azurerm/internal/services/netapp/netapp_snapshot_resource.go +++ b/azurerm/internal/services/netapp/netapp_snapshot_resource.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" + "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -71,7 +71,16 @@ func resourceNetAppSnapshot() *schema.Resource { ValidateFunc: ValidateNetAppVolumeName, }, - "tags": tags.Schema(), + // TODO: remove this in a next breaking changes release since tags are + // not supported anymore on Snapshots (todo 3.0) + "tags": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Deprecated: "This property as been deprecated as the API no longer supports tags and will be removed in version 3.0 of the provider.", + }, }, } } @@ -101,9 +110,12 @@ func resourceNetAppSnapshotCreate(d *schema.ResourceData, meta interface{}) erro location := azure.NormalizeLocation(d.Get("location").(string)) + if tags.Expand(d.Get("tags").(map[string]interface{})) != nil { + log.Printf("[WARN] Tags are not supported on snaphots anymore, ignoring values.") + } + parameters := netapp.Snapshot{ Location: utils.String(location), - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } future, err := client.Create(ctx, parameters, resourceGroup, accountName, poolName, volumeName, name) @@ -155,33 +167,14 @@ func resourceNetAppSnapshotRead(d *schema.ResourceData, meta interface{}) error d.Set("location", azure.NormalizeLocation(*location)) } - return tags.FlattenAndSet(d, resp.Tags) + return nil } func resourceNetAppSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).NetApp.SnapshotClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.SnapshotID(d.Id()) - if err != nil { - return err - } - - parameters := netapp.SnapshotPatch{ - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), - } - - if _, err = client.Update(ctx, parameters, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName, id.Name); err != nil { - return fmt.Errorf("Error updating NetApp Snapshot %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - - resp, err := client.Get(ctx, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.VolumeName, id.Name) - if err != nil { - return fmt.Errorf("Error retrieving NetApp Snapshot %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - if resp.ID == nil || *resp.ID == "" { - return fmt.Errorf("Cannot read NetApp Snapshot %q (Resource Group %q) ID", id.Name, id.ResourceGroup) + // Snapshot resource in Azure changed its type to proxied resource, therefore + // tags are not supported anymore, ignoring any tags. + if tags.Expand(d.Get("tags").(map[string]interface{})) == nil { + log.Printf("[WARN] Tags are not supported on snaphots anymore, no update will happen in a snapshot at this time.") } return resourceNetAppSnapshotRead(d, meta) diff --git a/azurerm/internal/services/netapp/netapp_volume_data_source.go b/azurerm/internal/services/netapp/netapp_volume_data_source.go index b2666aac4a0c..868231058ca5 100644 --- a/azurerm/internal/services/netapp/netapp_volume_data_source.go +++ b/azurerm/internal/services/netapp/netapp_volume_data_source.go @@ -75,6 +75,31 @@ func dataSourceNetAppVolume() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "data_protection_replication": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "endpoint_type": { + Type: schema.TypeString, + Computed: true, + }, + + "remote_volume_location": azure.SchemaLocationForDataSource(), + + "remote_volume_resource_id": { + Type: schema.TypeString, + Computed: true, + }, + + "replication_schedule": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, } } @@ -107,9 +132,11 @@ func dataSourceNetAppVolumeRead(d *schema.ResourceData, meta interface{}) error d.Set("resource_group_name", resourceGroup) d.Set("account_name", accountName) d.Set("pool_name", poolName) + if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) } + if props := resp.VolumeProperties; props != nil { d.Set("volume_path", props.CreationToken) d.Set("service_level", props.ServiceLevel) @@ -127,6 +154,12 @@ func dataSourceNetAppVolumeRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("mount_ip_addresses", flattenNetAppVolumeMountIPAddresses(props.MountTargets)); err != nil { return fmt.Errorf("setting `mount_ip_addresses`: %+v", err) } + + if props.DataProtection.Replication != nil { + if err := d.Set("data_protection_replication", flattenNetAppVolumeDataProtectionReplication(props.DataProtection)); err != nil { + return fmt.Errorf("setting `data_protection_replication`: %+v", err) + } + } } return nil diff --git a/azurerm/internal/services/netapp/netapp_volume_resource.go b/azurerm/internal/services/netapp/netapp_volume_resource.go index 9d8117187980..19a9ae8ffc99 100644 --- a/azurerm/internal/services/netapp/netapp_volume_resource.go +++ b/azurerm/internal/services/netapp/netapp_volume_resource.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" + "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -194,6 +194,43 @@ func resourceNetAppVolume() *schema.Resource { Type: schema.TypeString, }, }, + + "data_protection_replication": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "endpoint_type": { + Type: schema.TypeString, + Optional: true, + Default: "dst", + ValidateFunc: validation.StringInSlice([]string{ + "dst", + }, false), + }, + + "remote_volume_location": azure.SchemaLocation(), + + "remote_volume_resource_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "replication_frequency": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "10minutes", + "daily", + "hourly", + }, false), + }, + }, + }, + }, }, } } @@ -223,24 +260,38 @@ func resourceNetAppVolumeCreateUpdate(d *schema.ResourceData, meta interface{}) location := azure.NormalizeLocation(d.Get("location").(string)) volumePath := d.Get("volume_path").(string) serviceLevel := d.Get("service_level").(string) - subnetId := d.Get("subnet_id").(string) + subnetID := d.Get("subnet_id").(string) protocols := d.Get("protocols").(*schema.Set).List() if len(protocols) == 0 { protocols = append(protocols, "NFSv3") } storageQuotaInGB := int64(d.Get("storage_quota_in_gb").(int) * 1073741824) - exportPolicyRule := d.Get("export_policy_rule").([]interface{}) + + exportPolicyRuleRaw := d.Get("export_policy_rule").([]interface{}) + exportPolicyRule := expandNetAppVolumeExportPolicyRule(exportPolicyRuleRaw) + + dataProtectionReplicationRaw := d.Get("data_protection_replication").([]interface{}) + dataProtectionReplication := expandNetAppVolumeDataProtectionReplication(dataProtectionReplicationRaw) + + authorizeReplication := false + volumeType := "" + if dataProtectionReplication != nil && dataProtectionReplication.Replication != nil && strings.ToLower(string(dataProtectionReplication.Replication.EndpointType)) == "dst" { + authorizeReplication = true + volumeType = "DataProtection" + } parameters := netapp.Volume{ Location: utils.String(location), VolumeProperties: &netapp.VolumeProperties{ CreationToken: utils.String(volumePath), ServiceLevel: netapp.ServiceLevel(serviceLevel), - SubnetID: utils.String(subnetId), + SubnetID: utils.String(subnetID), ProtocolTypes: utils.ExpandStringSlice(protocols), UsageThreshold: utils.Int64(storageQuotaInGB), - ExportPolicy: expandNetAppVolumeExportPolicyRule(exportPolicyRule), + ExportPolicy: exportPolicyRule, + VolumeType: utils.String(volumeType), + DataProtection: dataProtectionReplication, }, Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } @@ -253,14 +304,47 @@ func resourceNetAppVolumeCreateUpdate(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error waiting for creation of NetApp Volume %q (Resource Group %q): %+v", name, resourceGroup, err) } - resp, err := client.Get(ctx, resourceGroup, accountName, poolName, name) - if err != nil { - return fmt.Errorf("Error retrieving NetApp Volume %q (Resource Group %q): %+v", name, resourceGroup, err) + // Waiting for volume be completely provisioned + id := parse.NewVolumeID(client.SubscriptionID, resourceGroup, accountName, poolName, name) + log.Printf("[DEBUG] Waiting for NetApp Volume Provisioning Service %q (Resource Group %q) to complete", id.Name, id.ResourceGroup) + if err := waitForVolumeCreation(ctx, client, id, d.Timeout(schema.TimeoutDelete)); err != nil { + return err } - if resp.ID == nil || *resp.ID == "" { - return fmt.Errorf("Cannot read NetApp Volume %q (Resource Group %q) ID", name, resourceGroup) + + // If this is a data replication secondary volume, authorize replication on primary volume + if authorizeReplication { + replVolID, err := parse.VolumeID(*dataProtectionReplication.Replication.RemoteVolumeResourceID) + if err != nil { + return err + } + + future, err := client.AuthorizeReplication( + ctx, + replVolID.ResourceGroup, + replVolID.NetAppAccountName, + replVolID.CapacityPoolName, + replVolID.Name, + netapp.AuthorizeRequest{ + RemoteVolumeResourceID: utils.String(id.ID()), + }, + ) + + if err != nil { + return fmt.Errorf("Cannot authorize volume replication: %v", err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Cannot get authorize volume replication future response: %v", err) + } + + // Wait for volume replication authorization to complete + log.Printf("[DEBUG] Waiting for replication authorization on NetApp Volume Provisioning Service %q (Resource Group %q) to complete", id.Name, id.ResourceGroup) + if err := waitForReplAuthorization(ctx, client, id, d.Timeout(schema.TimeoutDelete)); err != nil { + return err + } } - d.SetId(*resp.ID) + + d.SetId(id.ID()) return resourceNetAppVolumeRead(d, meta) } @@ -306,6 +390,11 @@ func resourceNetAppVolumeRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("mount_ip_addresses", flattenNetAppVolumeMountIPAddresses(props.MountTargets)); err != nil { return fmt.Errorf("setting `mount_ip_addresses`: %+v", err) } + if props.DataProtection.Replication != nil { + if err := d.Set("data_protection_replication", flattenNetAppVolumeDataProtectionReplication(props.DataProtection)); err != nil { + return fmt.Errorf("setting `data_protection_replication`: %+v", err) + } + } } return tags.FlattenAndSet(d, resp.Tags) @@ -321,24 +410,154 @@ func resourceNetAppVolumeDelete(d *schema.ResourceData, meta interface{}) error return err } + // Removing replication if present + dataProtectionReplicationRaw := d.Get("data_protection_replication").([]interface{}) + dataProtectionReplication := expandNetAppVolumeDataProtectionReplication(dataProtectionReplicationRaw) + + if replVolumeID := id; dataProtectionReplication != nil && dataProtectionReplication.Replication != nil { + if strings.ToLower(string(dataProtectionReplication.Replication.EndpointType)) != "dst" { + // This is the case where primary volume started the deletion, in this case, to be consistent we will remove replication from secondary + replVolumeID, err = parse.VolumeID(*dataProtectionReplication.Replication.RemoteVolumeResourceID) + if err != nil { + return err + } + } + + // Checking replication status before deletion, it need to be broken before proceeding with deletion + if res, err := client.ReplicationStatusMethod(ctx, replVolumeID.ResourceGroup, replVolumeID.NetAppAccountName, replVolumeID.CapacityPoolName, replVolumeID.Name); err == nil { + // Wait for replication state = "mirrored" + if strings.ToLower(string(res.MirrorState)) == "uninitialized" { + if err := waitForReplMirrorState(ctx, client, *replVolumeID, d.Timeout(schema.TimeoutDelete), "mirrored"); err != nil { + return err + } + } + + // Breaking replication + _, err = client.BreakReplication(ctx, + replVolumeID.ResourceGroup, + replVolumeID.NetAppAccountName, + replVolumeID.CapacityPoolName, + replVolumeID.Name, + &netapp.BreakReplicationRequest{ + ForceBreakReplication: utils.Bool(true), + }) + + if err != nil { + return fmt.Errorf("Error deleting replication from NetApp Volume %q (Resource Group %q): %+v", replVolumeID.Name, replVolumeID.ResourceGroup, err) + } + + // Waiting for replication be in broken state + log.Printf("[DEBUG] Waiting for replication on NetApp Volume Provisioning Service %q (Resource Group %q) to be in broken state", replVolumeID.Name, replVolumeID.ResourceGroup) + if err := waitForReplMirrorState(ctx, client, *replVolumeID, d.Timeout(schema.TimeoutDelete), "broken"); err != nil { + return err + } + } + + // Deleting replication and waiting for it to fully complete the operation + if _, err = client.DeleteReplication(ctx, replVolumeID.ResourceGroup, replVolumeID.NetAppAccountName, replVolumeID.CapacityPoolName, replVolumeID.Name); err != nil { + return fmt.Errorf("Error deleting replication from NetApp Volume %q (Resource Group %q): %+v", replVolumeID.Name, replVolumeID.ResourceGroup, err) + } + + log.Printf("[DEBUG] Waiting for replication on NetApp Volume Provisioning Service %q (Resource Group %q) to be deleted", replVolumeID.Name, replVolumeID.ResourceGroup) + if err := waitForReplicationDeletion(ctx, client, *replVolumeID, d.Timeout(schema.TimeoutDelete)); err != nil { + return err + } + } + + // Deleting volume and waiting for it fo fully complete the operation if _, err = client.Delete(ctx, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.Name); err != nil { return fmt.Errorf("Error deleting NetApp Volume %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } - // The resource NetApp Volume depends on the resource NetApp Pool. - // Although the delete API returns 404 which means the NetApp Volume resource has been deleted. - // Then it tries to immediately delete NetApp Pool but it still throws error `Can not delete resource before nested resources are deleted.` - // In this case we're going to re-check status code again. - // For more details, see related Bug: https://github.com/Azure/azure-sdk-for-go/issues/6485 log.Printf("[DEBUG] Waiting for NetApp Volume Provisioning Service %q (Resource Group %q) to be deleted", id.Name, id.ResourceGroup) + if err := waitForVolumeDeletion(ctx, client, *id, d.Timeout(schema.TimeoutDelete)); err != nil { + return err + } + + return nil +} + +func waitForVolumeCreation(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, timeout time.Duration) error { + stateConf := &resource.StateChangeConf{ + ContinuousTargetOccurence: 5, + Delay: 10 * time.Second, + MinTimeout: 10 * time.Second, + Pending: []string{"204", "404"}, + Target: []string{"200", "202"}, + Refresh: netappVolumeStateRefreshFunc(ctx, client, id), + Timeout: timeout, + } + + if _, err := stateConf.WaitForState(); err != nil { + return fmt.Errorf("Error waiting NetApp Volume Provisioning Service %q (Resource Group %q) to complete: %+v", id.Name, id.ResourceGroup, err) + } + + return nil +} + +func waitForReplAuthorization(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, timeout time.Duration) error { + stateConf := &resource.StateChangeConf{ + ContinuousTargetOccurence: 5, + Delay: 10 * time.Second, + MinTimeout: 10 * time.Second, + Pending: []string{"204", "404", "400"}, // TODO: Remove 400 when bug is fixed on RP side, where replicationStatus returns 400 at some point during authorization process + Target: []string{"200", "202"}, + Refresh: netappVolumeReplicationStateRefreshFunc(ctx, client, id), + Timeout: timeout, + } + + if _, err := stateConf.WaitForState(); err != nil { + return fmt.Errorf("Error waiting for replication authorization NetApp Volume Provisioning Service %q (Resource Group %q) to complete: %+v", id.Name, id.ResourceGroup, err) + } + + return nil +} + +func waitForReplMirrorState(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, timeout time.Duration, desiredState string) error { + stateConf := &resource.StateChangeConf{ + ContinuousTargetOccurence: 5, + Delay: 10 * time.Second, + MinTimeout: 10 * time.Second, + Pending: []string{"200"}, // 200 means mirror state is still Mirrored + Target: []string{"204"}, // 204 means mirror state is <> than Mirrored + Refresh: netappVolumeReplicationMirrorStateRefreshFunc(ctx, client, id, desiredState), + Timeout: timeout, + } + + if _, err := stateConf.WaitForState(); err != nil { + return fmt.Errorf("Error waiting for NetApp Volume %q (Resource Group %q) to be in %s mirroring state: %+v", id.Name, id.ResourceGroup, desiredState, err) + } + + return nil +} + +func waitForReplicationDeletion(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, timeout time.Duration) error { + stateConf := &resource.StateChangeConf{ + ContinuousTargetOccurence: 5, + Delay: 10 * time.Second, + MinTimeout: 10 * time.Second, + Pending: []string{"200", "202", "400"}, // TODO: Remove 400 when bug is fixed on RP side, where replicationStatus returns 400 while it is in "Deleting" state + Target: []string{"404"}, + Refresh: netappVolumeReplicationStateRefreshFunc(ctx, client, id), + Timeout: timeout, + } + + if _, err := stateConf.WaitForState(); err != nil { + return fmt.Errorf("Error waiting for NetApp Volume replication %q (Resource Group %q) to be deleted: %+v", id.Name, id.ResourceGroup, err) + } + + return nil +} + +func waitForVolumeDeletion(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, timeout time.Duration) error { stateConf := &resource.StateChangeConf{ ContinuousTargetOccurence: 5, Delay: 10 * time.Second, MinTimeout: 10 * time.Second, Pending: []string{"200", "202"}, Target: []string{"204", "404"}, - Refresh: netappVolumeDeleteStateRefreshFunc(ctx, client, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.Name), - Timeout: d.Timeout(schema.TimeoutDelete), + Refresh: netappVolumeStateRefreshFunc(ctx, client, id), + Timeout: timeout, } if _, err := stateConf.WaitForState(); err != nil { @@ -348,12 +567,57 @@ func resourceNetAppVolumeDelete(d *schema.ResourceData, meta interface{}) error return nil } -func netappVolumeDeleteStateRefreshFunc(ctx context.Context, client *netapp.VolumesClient, resourceGroupName string, accountName string, poolName string, name string) resource.StateRefreshFunc { +func netappVolumeStateRefreshFunc(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId) resource.StateRefreshFunc { return func() (interface{}, string, error) { - res, err := client.Get(ctx, resourceGroupName, accountName, poolName, name) + res, err := client.Get(ctx, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.Name) if err != nil { if !utils.ResponseWasNotFound(res.Response) { - return nil, "", fmt.Errorf("Error retrieving NetApp Volume %q (Resource Group %q): %s", name, resourceGroupName, err) + return nil, "", fmt.Errorf("Error retrieving NetApp Volume %q (Resource Group %q): %s", id.Name, id.ResourceGroup, err) + } + } + + return res, strconv.Itoa(res.StatusCode), nil + } +} + +func netappVolumeReplicationMirrorStateRefreshFunc(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId, desiredState string) resource.StateRefreshFunc { + validStates := []string{"mirrored", "broken", "uninitialized"} + + return func() (interface{}, string, error) { + // Possible Mirror States to be used as desiredStates: + // mirrored, broken or uninitialized + if !utils.SliceContainsValue(validStates, strings.ToLower(desiredState)) { + return nil, "", fmt.Errorf("Invalid desired mirror state was passed to check mirror replication state (%s), possible values: (%+v)", desiredState, netapp.PossibleMirrorStateValues()) + } + + // Setting 200 as default response + response := 200 + + res, err := client.ReplicationStatusMethod(ctx, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.Name) + if err != nil { + if !utils.ResponseWasNotFound(res.Response) { + return nil, "", fmt.Errorf("Error retrieving replication status information from NetApp Volume %q (Resource Group %q): %s", id.Name, id.ResourceGroup, err) + } + } + + if strings.EqualFold(string(res.MirrorState), desiredState) { + // return 204 if state matches desired state + response = 204 + } + + return res, strconv.Itoa(response), nil + } +} + +func netappVolumeReplicationStateRefreshFunc(ctx context.Context, client *netapp.VolumesClient, id parse.VolumeId) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + res, err := client.ReplicationStatusMethod(ctx, id.ResourceGroup, id.NetAppAccountName, id.CapacityPoolName, id.Name) + if err != nil { + if res.StatusCode == 400 && (strings.Contains(strings.ToLower(err.Error()), "deleting") || strings.Contains(strings.ToLower(err.Error()), "volume replication missing or deleted")) { + // This error can be ignored until a bug is fixed on RP side that it is returning 400 while the replication is in "Deleting" process + // TODO: remove this workaround when above bug is fixed + } else if !utils.ResponseWasNotFound(res.Response) { + return nil, "", fmt.Errorf("Error retrieving replication status from NetApp Volume %q (Resource Group %q): %s", id.Name, id.ResourceGroup, err) } } @@ -418,6 +682,33 @@ func expandNetAppVolumeExportPolicyRule(input []interface{}) *netapp.VolumePrope } } +func expandNetAppVolumeDataProtectionReplication(input []interface{}) *netapp.VolumePropertiesDataProtection { + if len(input) == 0 || input[0] == nil { + return &netapp.VolumePropertiesDataProtection{} + } + + replicationObject := netapp.ReplicationObject{} + + replicationRaw := input[0].(map[string]interface{}) + + if v, ok := replicationRaw["endpoint_type"]; ok { + replicationObject.EndpointType = netapp.EndpointType(v.(string)) + } + if v, ok := replicationRaw["remote_volume_location"]; ok { + replicationObject.RemoteVolumeRegion = utils.String(v.(string)) + } + if v, ok := replicationRaw["remote_volume_resource_id"]; ok { + replicationObject.RemoteVolumeResourceID = utils.String(v.(string)) + } + if v, ok := replicationRaw["replication_frequency"]; ok { + replicationObject.ReplicationSchedule = netapp.ReplicationSchedule(translateTFSchedule(v.(string))) + } + + return &netapp.VolumePropertiesDataProtection{ + Replication: &replicationObject, + } +} + func flattenNetAppVolumeExportPolicyRule(input *netapp.VolumePropertiesExportPolicy) []interface{} { results := make([]interface{}, 0) if input == nil || input.Rules == nil { @@ -496,3 +787,34 @@ func flattenNetAppVolumeMountIPAddresses(input *[]netapp.MountTargetProperties) return results } + +func flattenNetAppVolumeDataProtectionReplication(input *netapp.VolumePropertiesDataProtection) []interface{} { + if input == nil || input.Replication == nil || strings.ToLower(string(input.Replication.EndpointType)) != "dst" { + return []interface{}{} + } + + return []interface{}{ + map[string]interface{}{ + "endpoint_type": strings.ToLower(string(input.Replication.EndpointType)), + "remote_volume_location": input.Replication.RemoteVolumeRegion, + "remote_volume_resource_id": input.Replication.RemoteVolumeResourceID, + "replication_frequency": translateSDKSchedule(strings.ToLower(string(input.Replication.ReplicationSchedule))), + }, + } +} + +func translateTFSchedule(scheduleName string) string { + if strings.EqualFold(scheduleName, "10minutes") { + return "_10minutely" + } + + return scheduleName +} + +func translateSDKSchedule(scheduleName string) string { + if strings.EqualFold(scheduleName, "_10minutely") { + return "10minutes" + } + + return scheduleName +} diff --git a/azurerm/internal/services/netapp/netapp_volume_resource_test.go b/azurerm/internal/services/netapp/netapp_volume_resource_test.go index cb69a6f53fd7..e71eaff1b9ed 100644 --- a/azurerm/internal/services/netapp/netapp_volume_resource_test.go +++ b/azurerm/internal/services/netapp/netapp_volume_resource_test.go @@ -51,6 +51,22 @@ func TestAccNetAppVolume_nfsv41(t *testing.T) { }) } +func TestAccNetAppVolume_crossRegionReplication(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_netapp_volume", "test_secondary") + r := NetAppVolumeResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.crossRegionReplication(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("data_protection_replication.0.endpoint_type").HasValue("dst"), + ), + }, + data.ImportStep(), + }) +} + func TestAccNetAppVolume_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_netapp_volume", "test") r := NetAppVolumeResource{} @@ -248,6 +264,62 @@ resource "azurerm_netapp_volume" "test" { `, template, data.RandomInteger, data.RandomInteger) } +func (NetAppVolumeResource) crossRegionReplication(data acceptance.TestData) string { + template := NetAppVolumeResource{}.templateForCrossRegionReplication(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_netapp_volume" "test_primary" { + name = "acctest-NetAppVolume-primary-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + account_name = azurerm_netapp_account.test.name + pool_name = azurerm_netapp_pool.test.name + volume_path = "my-unique-file-path-primary-%[2]d" + service_level = "Standard" + subnet_id = azurerm_subnet.test.id + protocols = ["NFSv3"] + storage_quota_in_gb = 100 + + export_policy_rule { + rule_index = 1 + allowed_clients = ["0.0.0.0/0"] + protocols_enabled = ["NFSv3"] + unix_read_only = false + unix_read_write = true + } +} + +resource "azurerm_netapp_volume" "test_secondary" { + name = "acctest-NetAppVolume-secondary-%[2]d" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name + account_name = azurerm_netapp_account.test_secondary.name + pool_name = azurerm_netapp_pool.test_secondary.name + volume_path = "my-unique-file-path-secondary-%[2]d" + service_level = "Standard" + subnet_id = azurerm_subnet.test_secondary.id + protocols = ["NFSv3"] + storage_quota_in_gb = 100 + + export_policy_rule { + rule_index = 1 + allowed_clients = ["0.0.0.0/0"] + protocols_enabled = ["NFSv3"] + unix_read_only = false + unix_read_write = true + } + + data_protection_replication { + endpoint_type = "dst" + remote_volume_location = azurerm_resource_group.test.location + remote_volume_resource_id = azurerm_netapp_volume.test_primary.id + replication_frequency = "10minutes" + } +} +`, template, data.RandomInteger, "northeurope") +} + func (r NetAppVolumeResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -388,6 +460,50 @@ resource "azurerm_netapp_volume" "test" { `, r.template(data), data.RandomInteger, data.RandomInteger) } +func (r NetAppVolumeResource) templateForCrossRegionReplication(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_virtual_network" "test_secondary" { + name = "acctest-VirtualNetwork-secondary-%[2]d" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name + address_space = ["10.6.0.0/16"] +} + +resource "azurerm_subnet" "test_secondary" { + name = "acctest-Subnet-secondary-%[2]d" + resource_group_name = azurerm_resource_group.test.name + virtual_network_name = azurerm_virtual_network.test_secondary.name + address_prefix = "10.6.2.0/24" + + delegation { + name = "testdelegation" + + service_delegation { + name = "Microsoft.Netapp/volumes" + actions = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"] + } + } +} + +resource "azurerm_netapp_account" "test_secondary" { + name = "acctest-NetAppAccount-secondary-%[2]d" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_netapp_pool" "test_secondary" { + name = "acctest-NetAppPool-secondary-%[2]d" + location = "%[3]s" + resource_group_name = azurerm_resource_group.test.name + account_name = azurerm_netapp_account.test_secondary.name + service_level = "Standard" + size_in_tb = 4 +} +`, r.template(data), data.RandomInteger, "northeurope") +} + func (NetAppVolumeResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/examples/netapp/volume_crr/README.md b/examples/netapp/volume_crr/README.md new file mode 100644 index 000000000000..aa01f7c7f180 --- /dev/null +++ b/examples/netapp/volume_crr/README.md @@ -0,0 +1,5 @@ +## Example: NetApp Files Volume with Cross-Region Replication data protection enabled + +This example shows how to create an Azure NetApp Files Volume with data protection enabled through cross-region replication feature. + +For more information, please refer to [Cross-region replication of Azure NetApp Files volumes](https://docs.microsoft.com/en-us/azure/azure-netapp-files/cross-region-replication-introduction). \ No newline at end of file diff --git a/examples/netapp/volume_crr/main.tf b/examples/netapp/volume_crr/main.tf new file mode 100644 index 000000000000..923e766811df --- /dev/null +++ b/examples/netapp/volume_crr/main.tf @@ -0,0 +1,143 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "${var.prefix}-resources" + location = var.location +} + +resource "azurerm_virtual_network" "example_primary" { + name = "${var.prefix}-virtualnetwork-primary" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + address_space = ["10.0.0.0/16"] +} + +resource "azurerm_subnet" "example_primary" { + name = "${var.prefix}-subnet" + resource_group_name = azurerm_resource_group.example.name + virtual_network_name = azurerm_virtual_network.example_primary.name + address_prefixes = ["10.0.2.0/24"] + + delegation { + name = "testdelegation" + + service_delegation { + name = "Microsoft.Netapp/volumes" + actions = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"] + } + } +} + +resource "azurerm_virtual_network" "example_secondary" { + name = "${var.prefix}-virtualnetwork-secondary" + location = var.alt_location + resource_group_name = azurerm_resource_group.example.name + address_space = ["10.1.0.0/16"] +} + +resource "azurerm_subnet" "example_secondary" { + name = "${var.prefix}-subnet" + resource_group_name = azurerm_resource_group.example.name + virtual_network_name = azurerm_virtual_network.example_secondary.name + address_prefixes = ["10.1.2.0/24"] + + delegation { + name = "testdelegation" + + service_delegation { + name = "Microsoft.Netapp/volumes" + actions = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"] + } + } +} + +resource "azurerm_netapp_account" "example_primary" { + name = "${var.prefix}-netappaccount-primary" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_netapp_account" "example_secondary" { + name = "${var.prefix}-netappaccount-secondary" + location = var.alt_location + resource_group_name = azurerm_resource_group.example.name +} + +resource "azurerm_netapp_pool" "example_primary" { + name = "${var.prefix}-netapppool-primary" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + account_name = azurerm_netapp_account.example_primary.name + service_level = "Premium" + size_in_tb = 4 +} + +resource "azurerm_netapp_pool" "example_secondary" { + name = "${var.prefix}-netapppool-secondary" + location = var.alt_location + resource_group_name = azurerm_resource_group.example.name + account_name = azurerm_netapp_account.example_secondary.name + service_level = "Standard" + size_in_tb = 4 +} + +resource "azurerm_netapp_volume" "example_primary" { + lifecycle { + prevent_destroy = true + } + + name = "${var.prefix}-netappvolume-primary" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + account_name = azurerm_netapp_account.example_primary.name + pool_name = azurerm_netapp_pool.example_primary.name + volume_path = "${var.prefix}-netappvolume" + service_level = "Standard" + protocols = ["NFSv3"] + subnet_id = azurerm_subnet.example_primary.id + storage_quota_in_gb = 100 + + export_policy_rule { + rule_index = 1 + allowed_clients = ["0.0.0.0/0"] + protocols_enabled = ["NFSv3"] + unix_read_only = false + unix_read_write = true + } +} + +resource "azurerm_netapp_volume" "example_secondary" { + lifecycle { + prevent_destroy = true + } + + depends_on = [ azurerm_netapp_volume.example_primary ] + + name = "${var.prefix}-netappvolume-secondary" + location = var.alt_location + resource_group_name = azurerm_resource_group.example.name + account_name = azurerm_netapp_account.example_secondary.name + pool_name = azurerm_netapp_pool.example_secondary.name + volume_path = "${var.prefix}-netappvolume-secondary" + service_level = "Standard" + protocols = ["NFSv3"] + subnet_id = azurerm_subnet.example_secondary.id + storage_quota_in_gb = 100 + + export_policy_rule { + rule_index = 1 + allowed_clients = ["0.0.0.0/0"] + protocols_enabled = ["NFSv3"] + unix_read_only = false + unix_read_write = true + } + + data_protection_replication { + endpoint_type = "dst" + remote_volume_location = azurerm_resource_group.example.location + remote_volume_resource_id = azurerm_netapp_volume.example_primary.id + replication_frequency = "10minutes" + } +} diff --git a/examples/netapp/volume_crr/variables.tf b/examples/netapp/volume_crr/variables.tf new file mode 100644 index 000000000000..7d1362c73886 --- /dev/null +++ b/examples/netapp/volume_crr/variables.tf @@ -0,0 +1,11 @@ +variable "location" { + description = "The Azure location where all resources in this example should be created." +} + +variable "alt_location" { + description = "The Azure location where the secondary volume will be created." +} + +variable "prefix" { + description = "The prefix used for all resources used by this NetApp Volume" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/CHANGELOG.md deleted file mode 100644 index 1c4ed53b611c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82//specification/netapp/resource-manager/readme.md tag: `package-netapp-2019-10-01` - -Code generator @microsoft.azure/autorest.go@2.1.171 - - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/models.go deleted file mode 100644 index cecbd611edb8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/models.go +++ /dev/null @@ -1,1411 +0,0 @@ -package netapp - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp" - -// Account netApp account resource -type Account struct { - autorest.Response `json:"-"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // AccountProperties - NetApp Account properties - *AccountProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for Account. -func (a Account) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if a.Location != nil { - objectMap["location"] = a.Location - } - if a.Tags != nil { - objectMap["tags"] = a.Tags - } - if a.AccountProperties != nil { - objectMap["properties"] = a.AccountProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Account struct. -func (a *Account) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - a.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - a.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - a.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - a.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - a.Tags = tags - } - case "properties": - if v != nil { - var accountProperties AccountProperties - err = json.Unmarshal(*v, &accountProperties) - if err != nil { - return err - } - a.AccountProperties = &accountProperties - } - } - } - - return nil -} - -// AccountList list of NetApp account resources -type AccountList struct { - autorest.Response `json:"-"` - // Value - Multiple NetApp accounts - Value *[]Account `json:"value,omitempty"` -} - -// AccountPatch netApp account patch resource -type AccountPatch struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // AccountProperties - NetApp Account properties - *AccountProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for AccountPatch. -func (ap AccountPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ap.Location != nil { - objectMap["location"] = ap.Location - } - if ap.Tags != nil { - objectMap["tags"] = ap.Tags - } - if ap.AccountProperties != nil { - objectMap["properties"] = ap.AccountProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for AccountPatch struct. -func (ap *AccountPatch) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ap.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ap.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ap.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ap.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ap.Tags = tags - } - case "properties": - if v != nil { - var accountProperties AccountProperties - err = json.Unmarshal(*v, &accountProperties) - if err != nil { - return err - } - ap.AccountProperties = &accountProperties - } - } - } - - return nil -} - -// AccountProperties netApp account properties -type AccountProperties struct { - // ProvisioningState - READ-ONLY; Azure lifecycle management - ProvisioningState *string `json:"provisioningState,omitempty"` - // ActiveDirectories - Active Directories - ActiveDirectories *[]ActiveDirectory `json:"activeDirectories,omitempty"` -} - -// MarshalJSON is the custom marshaler for AccountProperties. -func (ap AccountProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ap.ActiveDirectories != nil { - objectMap["activeDirectories"] = ap.ActiveDirectories - } - return json.Marshal(objectMap) -} - -// AccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type AccountsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(AccountsClient) (Account, error) -} - -// AccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type AccountsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(AccountsClient) (autorest.Response, error) -} - -// ActiveDirectory active Directory -type ActiveDirectory struct { - // ActiveDirectoryID - Id of the Active Directory - ActiveDirectoryID *string `json:"activeDirectoryId,omitempty"` - // Username - Username of Active Directory domain administrator - Username *string `json:"username,omitempty"` - // Password - Plain text password of Active Directory domain administrator - Password *string `json:"password,omitempty"` - // Domain - Name of the Active Directory domain - Domain *string `json:"domain,omitempty"` - // DNS - Comma separated list of DNS server IP addresses (IPv4 only) for the Active Directory domain - DNS *string `json:"dns,omitempty"` - // Status - Status of the Active Directory - Status *string `json:"status,omitempty"` - // SmbServerName - NetBIOS name of the SMB server. This name will be registered as a computer account in the AD and used to mount volumes - SmbServerName *string `json:"smbServerName,omitempty"` - // OrganizationalUnit - The Organizational Unit (OU) within the Windows Active Directory - OrganizationalUnit *string `json:"organizationalUnit,omitempty"` -} - -// AuthorizeRequest authorize request -type AuthorizeRequest struct { - // RemoteVolumeResourceID - Resource id - RemoteVolumeResourceID *string `json:"remoteVolumeResourceId,omitempty"` -} - -// CapacityPool capacity pool resource -type CapacityPool struct { - autorest.Response `json:"-"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // PoolProperties - Capacity pool properties - *PoolProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CapacityPool. -func (cp CapacityPool) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cp.Location != nil { - objectMap["location"] = cp.Location - } - if cp.Tags != nil { - objectMap["tags"] = cp.Tags - } - if cp.PoolProperties != nil { - objectMap["properties"] = cp.PoolProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CapacityPool struct. -func (cp *CapacityPool) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - cp.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - cp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - cp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - cp.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - cp.Tags = tags - } - case "properties": - if v != nil { - var poolProperties PoolProperties - err = json.Unmarshal(*v, &poolProperties) - if err != nil { - return err - } - cp.PoolProperties = &poolProperties - } - } - } - - return nil -} - -// CapacityPoolList list of capacity pool resources -type CapacityPoolList struct { - autorest.Response `json:"-"` - // Value - List of Capacity pools - Value *[]CapacityPool `json:"value,omitempty"` -} - -// CapacityPoolPatch capacity pool patch resource -type CapacityPoolPatch struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // PoolPatchProperties - Capacity pool properties - *PoolPatchProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CapacityPoolPatch. -func (cpp CapacityPoolPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cpp.Location != nil { - objectMap["location"] = cpp.Location - } - if cpp.Tags != nil { - objectMap["tags"] = cpp.Tags - } - if cpp.PoolPatchProperties != nil { - objectMap["properties"] = cpp.PoolPatchProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CapacityPoolPatch struct. -func (cpp *CapacityPoolPatch) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - cpp.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - cpp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - cpp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - cpp.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - cpp.Tags = tags - } - case "properties": - if v != nil { - var poolPatchProperties PoolPatchProperties - err = json.Unmarshal(*v, &poolPatchProperties) - if err != nil { - return err - } - cpp.PoolPatchProperties = &poolPatchProperties - } - } - } - - return nil -} - -// Dimension dimension of blobs, possibly be blob type or access tier. -type Dimension struct { - // Name - Display name of dimension. - Name *string `json:"name,omitempty"` - // DisplayName - Display name of dimension. - DisplayName *string `json:"displayName,omitempty"` -} - -// ExportPolicyRule volume Export Policy Rule -type ExportPolicyRule struct { - // RuleIndex - Order index - RuleIndex *int32 `json:"ruleIndex,omitempty"` - // UnixReadOnly - Read only access - UnixReadOnly *bool `json:"unixReadOnly,omitempty"` - // UnixReadWrite - Read and write access - UnixReadWrite *bool `json:"unixReadWrite,omitempty"` - // Cifs - Allows CIFS protocol - Cifs *bool `json:"cifs,omitempty"` - // Nfsv3 - Allows NFSv3 protocol - Nfsv3 *bool `json:"nfsv3,omitempty"` - // Nfsv41 - Allows NFSv4.1 protocol - Nfsv41 *bool `json:"nfsv41,omitempty"` - // AllowedClients - Client ingress specification as comma separated string with IPv4 CIDRs, IPv4 host addresses and host names - AllowedClients *string `json:"allowedClients,omitempty"` -} - -// MetricSpecification metric specification of operation. -type MetricSpecification struct { - // Name - Name of metric specification. - Name *string `json:"name,omitempty"` - // DisplayName - Display name of metric specification. - DisplayName *string `json:"displayName,omitempty"` - // DisplayDescription - Display description of metric specification. - DisplayDescription *string `json:"displayDescription,omitempty"` - // Unit - Unit could be Bytes or Count. - Unit *string `json:"unit,omitempty"` - // Dimensions - Dimensions of blobs, including blob type and access tier. - Dimensions *[]Dimension `json:"dimensions,omitempty"` - // AggregationType - Aggregation type could be Average. - AggregationType *string `json:"aggregationType,omitempty"` - // FillGapWithZero - The property to decide fill gap with zero or not. - FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` - // Category - The category this metric specification belong to, could be Capacity. - Category *string `json:"category,omitempty"` - // ResourceIDDimensionNameOverride - Account Resource Id. - ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` -} - -// MountTarget mount Target -type MountTarget struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // MountTargetProperties - Mount Target Properties - *MountTargetProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for MountTarget. -func (mt MountTarget) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mt.Location != nil { - objectMap["location"] = mt.Location - } - if mt.Tags != nil { - objectMap["tags"] = mt.Tags - } - if mt.MountTargetProperties != nil { - objectMap["properties"] = mt.MountTargetProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MountTarget struct. -func (mt *MountTarget) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mt.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mt.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mt.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mt.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mt.Tags = tags - } - case "properties": - if v != nil { - var mountTargetProperties MountTargetProperties - err = json.Unmarshal(*v, &mountTargetProperties) - if err != nil { - return err - } - mt.MountTargetProperties = &mountTargetProperties - } - } - } - - return nil -} - -// MountTargetList list of Mount Targets -type MountTargetList struct { - autorest.Response `json:"-"` - // Value - A list of Mount targets - Value *[]MountTarget `json:"value,omitempty"` -} - -// MountTargetProperties mount target properties -type MountTargetProperties struct { - // MountTargetID - READ-ONLY; UUID v4 used to identify the MountTarget - MountTargetID *string `json:"mountTargetId,omitempty"` - // FileSystemID - UUID v4 used to identify the MountTarget - FileSystemID *string `json:"fileSystemId,omitempty"` - // IPAddress - READ-ONLY; The mount target's IPv4 address - IPAddress *string `json:"ipAddress,omitempty"` - // Subnet - The subnet - Subnet *string `json:"subnet,omitempty"` - // StartIP - The start of IPv4 address range to use when creating a new mount target - StartIP *string `json:"startIp,omitempty"` - // EndIP - The end of IPv4 address range to use when creating a new mount target - EndIP *string `json:"endIp,omitempty"` - // Gateway - The gateway of the IPv4 address range to use when creating a new mount target - Gateway *string `json:"gateway,omitempty"` - // Netmask - The netmask of the IPv4 address range to use when creating a new mount target - Netmask *string `json:"netmask,omitempty"` - // SmbServerFqdn - The SMB server's Fully Qualified Domain Name, FQDN - SmbServerFqdn *string `json:"smbServerFqdn,omitempty"` - // ProvisioningState - READ-ONLY; Azure lifecycle management - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// MarshalJSON is the custom marshaler for MountTargetProperties. -func (mtp MountTargetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mtp.FileSystemID != nil { - objectMap["fileSystemId"] = mtp.FileSystemID - } - if mtp.Subnet != nil { - objectMap["subnet"] = mtp.Subnet - } - if mtp.StartIP != nil { - objectMap["startIp"] = mtp.StartIP - } - if mtp.EndIP != nil { - objectMap["endIp"] = mtp.EndIP - } - if mtp.Gateway != nil { - objectMap["gateway"] = mtp.Gateway - } - if mtp.Netmask != nil { - objectMap["netmask"] = mtp.Netmask - } - if mtp.SmbServerFqdn != nil { - objectMap["smbServerFqdn"] = mtp.SmbServerFqdn - } - return json.Marshal(objectMap) -} - -// Operation microsoft.NetApp REST API operation definition. -type Operation struct { - // Name - Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - Display metadata associated with the operation. - Display *OperationDisplay `json:"display,omitempty"` - // Origin - The origin of operations. - Origin *string `json:"origin,omitempty"` - // OperationProperties - Properties of operation, include metric specifications. - *OperationProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if o.Name != nil { - objectMap["name"] = o.Name - } - if o.Display != nil { - objectMap["display"] = o.Display - } - if o.Origin != nil { - objectMap["origin"] = o.Origin - } - if o.OperationProperties != nil { - objectMap["properties"] = o.OperationProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Operation struct. -func (o *Operation) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - o.Name = &name - } - case "display": - if v != nil { - var display OperationDisplay - err = json.Unmarshal(*v, &display) - if err != nil { - return err - } - o.Display = &display - } - case "origin": - if v != nil { - var origin string - err = json.Unmarshal(*v, &origin) - if err != nil { - return err - } - o.Origin = &origin - } - case "properties": - if v != nil { - var operationProperties OperationProperties - err = json.Unmarshal(*v, &operationProperties) - if err != nil { - return err - } - o.OperationProperties = &operationProperties - } - } - } - - return nil -} - -// OperationDisplay display metadata associated with the operation. -type OperationDisplay struct { - // Provider - Service provider: Microsoft NetApp. - Provider *string `json:"provider,omitempty"` - // Resource - Resource on which the operation is performed etc. - Resource *string `json:"resource,omitempty"` - // Operation - Type of operation: get, read, delete, etc. - Operation *string `json:"operation,omitempty"` - // Description - Operation description. - Description *string `json:"description,omitempty"` -} - -// OperationListResult result of the request to list Cloud Volume operations. It contains a list of -// operations and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - List of Storage operations supported by the Storage resource provider. - Value *[]Operation `json:"value,omitempty"` -} - -// OperationProperties properties of operation, include metric specifications. -type OperationProperties struct { - // ServiceSpecification - One property of operation, include metric specifications. - ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` -} - -// PoolPatchProperties patchable pool properties -type PoolPatchProperties struct { - // Size - Provisioned size of the pool (in bytes). Allowed values are in 4TiB chunks (value must be multiply of 4398046511104). - Size *int64 `json:"size,omitempty"` - // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' - ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` -} - -// PoolProperties pool properties -type PoolProperties struct { - // PoolID - READ-ONLY; UUID v4 used to identify the Pool - PoolID *string `json:"poolId,omitempty"` - // Size - Provisioned size of the pool (in bytes). Allowed values are in 4TiB chunks (value must be multiply of 4398046511104). - Size *int64 `json:"size,omitempty"` - // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' - ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` - // ProvisioningState - READ-ONLY; Azure lifecycle management - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// MarshalJSON is the custom marshaler for PoolProperties. -func (pp PoolProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pp.Size != nil { - objectMap["size"] = pp.Size - } - if pp.ServiceLevel != "" { - objectMap["serviceLevel"] = pp.ServiceLevel - } - return json.Marshal(objectMap) -} - -// PoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type PoolsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PoolsClient) (CapacityPool, error) -} - -// PoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type PoolsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PoolsClient) (autorest.Response, error) -} - -// ReplicationObject replication properties -type ReplicationObject struct { - // ReplicationID - Id - ReplicationID *string `json:"replicationId,omitempty"` - // EndpointType - Indicates whether the local volume is the source or destination for the Volume Replication. Possible values include: 'Src', 'Dst' - EndpointType EndpointType `json:"endpointType,omitempty"` - // ReplicationSchedule - Schedule. Possible values include: '10minutely', 'Hourly', 'Daily' - ReplicationSchedule ReplicationSchedule `json:"replicationSchedule,omitempty"` - // RemoteVolumeResourceID - The resource ID of the remote volume. - RemoteVolumeResourceID *string `json:"remoteVolumeResourceId,omitempty"` - // RemoteVolumeRegion - The remote region for the other end of the Volume Replication. - RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` -} - -// ReplicationStatus replication status -type ReplicationStatus struct { - autorest.Response `json:"-"` - // Healthy - Replication health check - Healthy *bool `json:"healthy,omitempty"` - // RelationshipStatus - Status of the mirror relationship. Possible values include: 'Idle', 'Transferring' - RelationshipStatus RelationshipStatus `json:"relationshipStatus,omitempty"` - // MirrorState - The status of the replication. Possible values include: 'Uninitialized', 'Mirrored', 'Broken' - MirrorState MirrorState `json:"mirrorState,omitempty"` - // TotalProgress - The progress of the replication - TotalProgress *string `json:"totalProgress,omitempty"` - // ErrorMessage - Displays error message if the replication is in an error state - ErrorMessage *string `json:"errorMessage,omitempty"` -} - -// ResourceNameAvailability information regarding availability of a resource name. -type ResourceNameAvailability struct { - autorest.Response `json:"-"` - // IsAvailable - true indicates name is valid and available. false indicates the name is invalid, unavailable, or both. - IsAvailable *bool `json:"isAvailable,omitempty"` - // Reason - Invalid indicates the name provided does not match Azure App Service naming requirements. AlreadyExists indicates that the name is already in use and is therefore unavailable. Possible values include: 'Invalid', 'AlreadyExists' - Reason InAvailabilityReasonType `json:"reason,omitempty"` - // Message - If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that resource name is already in use, and direct them to select a different name. - Message *string `json:"message,omitempty"` -} - -// ResourceNameAvailabilityRequest resource name availability request content. -type ResourceNameAvailabilityRequest struct { - // Name - Resource name to verify. - Name *string `json:"name,omitempty"` - // Type - Resource type used for verification. Possible values include: 'MicrosoftNetAppnetAppAccounts', 'MicrosoftNetAppnetAppAccountscapacityPools', 'MicrosoftNetAppnetAppAccountscapacityPoolsvolumes', 'MicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots' - Type CheckNameResourceTypes `json:"type,omitempty"` - // ResourceGroup - Resource group name. - ResourceGroup *string `json:"resourceGroup,omitempty"` -} - -// ServiceSpecification one property of operation, include metric specifications. -type ServiceSpecification struct { - // MetricSpecifications - Metric specifications of operation. - MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` -} - -// Snapshot snapshot of a Volume -type Snapshot struct { - autorest.Response `json:"-"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // SnapshotProperties - Snapshot Properties - *SnapshotProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for Snapshot. -func (s Snapshot) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if s.Location != nil { - objectMap["location"] = s.Location - } - if s.Tags != nil { - objectMap["tags"] = s.Tags - } - if s.SnapshotProperties != nil { - objectMap["properties"] = s.SnapshotProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Snapshot struct. -func (s *Snapshot) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - s.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - s.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - s.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - s.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - s.Tags = tags - } - case "properties": - if v != nil { - var snapshotProperties SnapshotProperties - err = json.Unmarshal(*v, &snapshotProperties) - if err != nil { - return err - } - s.SnapshotProperties = &snapshotProperties - } - } - } - - return nil -} - -// SnapshotPatch snapshot patch -type SnapshotPatch struct { - // Tags - Resource tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SnapshotPatch. -func (sp SnapshotPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sp.Tags != nil { - objectMap["tags"] = sp.Tags - } - return json.Marshal(objectMap) -} - -// SnapshotProperties snapshot properties -type SnapshotProperties struct { - // SnapshotID - READ-ONLY; UUID v4 used to identify the Snapshot - SnapshotID *string `json:"snapshotId,omitempty"` - // FileSystemID - UUID v4 used to identify the FileSystem - FileSystemID *string `json:"fileSystemId,omitempty"` - // Created - READ-ONLY; The creation date of the snapshot - Created *date.Time `json:"created,omitempty"` - // ProvisioningState - READ-ONLY; Azure lifecycle management - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// MarshalJSON is the custom marshaler for SnapshotProperties. -func (sp SnapshotProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sp.FileSystemID != nil { - objectMap["fileSystemId"] = sp.FileSystemID - } - return json.Marshal(objectMap) -} - -// SnapshotsCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type SnapshotsCreateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SnapshotsClient) (Snapshot, error) -} - -// SnapshotsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type SnapshotsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SnapshotsClient) (autorest.Response, error) -} - -// SnapshotsList list of Snapshots -type SnapshotsList struct { - autorest.Response `json:"-"` - // Value - A list of Snapshots - Value *[]Snapshot `json:"value,omitempty"` -} - -// Volume volume resource -type Volume struct { - autorest.Response `json:"-"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // VolumeProperties - Volume properties - *VolumeProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for Volume. -func (vVar Volume) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if vVar.Location != nil { - objectMap["location"] = vVar.Location - } - if vVar.Tags != nil { - objectMap["tags"] = vVar.Tags - } - if vVar.VolumeProperties != nil { - objectMap["properties"] = vVar.VolumeProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Volume struct. -func (vVar *Volume) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - vVar.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - vVar.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - vVar.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - vVar.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - vVar.Tags = tags - } - case "properties": - if v != nil { - var volumeProperties VolumeProperties - err = json.Unmarshal(*v, &volumeProperties) - if err != nil { - return err - } - vVar.VolumeProperties = &volumeProperties - } - } - } - - return nil -} - -// VolumeList list of volume resources -type VolumeList struct { - autorest.Response `json:"-"` - // Value - List of volumes - Value *[]Volume `json:"value,omitempty"` -} - -// VolumePatch volume patch resource -type VolumePatch struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // VolumePatchProperties - Patchable volume properties - *VolumePatchProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for VolumePatch. -func (vp VolumePatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if vp.Location != nil { - objectMap["location"] = vp.Location - } - if vp.Tags != nil { - objectMap["tags"] = vp.Tags - } - if vp.VolumePatchProperties != nil { - objectMap["properties"] = vp.VolumePatchProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for VolumePatch struct. -func (vp *VolumePatch) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - vp.Location = &location - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - vp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - vp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - vp.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - vp.Tags = tags - } - case "properties": - if v != nil { - var volumePatchProperties VolumePatchProperties - err = json.Unmarshal(*v, &volumePatchProperties) - if err != nil { - return err - } - vp.VolumePatchProperties = &volumePatchProperties - } - } - } - - return nil -} - -// VolumePatchProperties patchable volume properties -type VolumePatchProperties struct { - // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' - ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` - // UsageThreshold - Maximum storage quota allowed for a file system in bytes. This is a soft quota used for alerting only. Minimum size is 100 GiB. Upper limit is 100TiB. Specified in bytes. - UsageThreshold *int64 `json:"usageThreshold,omitempty"` - // ExportPolicy - Set of export policy rules - ExportPolicy *VolumePatchPropertiesExportPolicy `json:"exportPolicy,omitempty"` -} - -// VolumePatchPropertiesExportPolicy set of export policy rules -type VolumePatchPropertiesExportPolicy struct { - // Rules - Export policy rule - Rules *[]ExportPolicyRule `json:"rules,omitempty"` -} - -// VolumeProperties volume properties -type VolumeProperties struct { - // FileSystemID - READ-ONLY; Unique FileSystem Identifier. - FileSystemID *string `json:"fileSystemId,omitempty"` - // CreationToken - A unique file path for the volume. Used when creating mount targets - CreationToken *string `json:"creationToken,omitempty"` - // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' - ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` - // UsageThreshold - Maximum storage quota allowed for a file system in bytes. This is a soft quota used for alerting only. Minimum size is 100 GiB. Upper limit is 100TiB. Specified in bytes. - UsageThreshold *int64 `json:"usageThreshold,omitempty"` - // ExportPolicy - Set of export policy rules - ExportPolicy *VolumePropertiesExportPolicy `json:"exportPolicy,omitempty"` - // ProtocolTypes - Set of protocol types - ProtocolTypes *[]string `json:"protocolTypes,omitempty"` - // ProvisioningState - READ-ONLY; Azure lifecycle management - ProvisioningState *string `json:"provisioningState,omitempty"` - // SnapshotID - UUID v4 or resource identifier used to identify the Snapshot. - SnapshotID *string `json:"snapshotId,omitempty"` - // BaremetalTenantID - READ-ONLY; Unique Baremetal Tenant Identifier. - BaremetalTenantID *string `json:"baremetalTenantId,omitempty"` - // SubnetID - The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes - SubnetID *string `json:"subnetId,omitempty"` - // MountTargets - List of mount targets - MountTargets *[]MountTargetProperties `json:"mountTargets,omitempty"` - // VolumeType - What type of volume is this - VolumeType *string `json:"volumeType,omitempty"` - // DataProtection - DataProtection type volumes include an object containing details of the replication - DataProtection *VolumePropertiesDataProtection `json:"dataProtection,omitempty"` - // IsRestoring - Restoring - IsRestoring *bool `json:"isRestoring,omitempty"` -} - -// MarshalJSON is the custom marshaler for VolumeProperties. -func (vp VolumeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if vp.CreationToken != nil { - objectMap["creationToken"] = vp.CreationToken - } - if vp.ServiceLevel != "" { - objectMap["serviceLevel"] = vp.ServiceLevel - } - if vp.UsageThreshold != nil { - objectMap["usageThreshold"] = vp.UsageThreshold - } - if vp.ExportPolicy != nil { - objectMap["exportPolicy"] = vp.ExportPolicy - } - if vp.ProtocolTypes != nil { - objectMap["protocolTypes"] = vp.ProtocolTypes - } - if vp.SnapshotID != nil { - objectMap["snapshotId"] = vp.SnapshotID - } - if vp.SubnetID != nil { - objectMap["subnetId"] = vp.SubnetID - } - if vp.MountTargets != nil { - objectMap["mountTargets"] = vp.MountTargets - } - if vp.VolumeType != nil { - objectMap["volumeType"] = vp.VolumeType - } - if vp.DataProtection != nil { - objectMap["dataProtection"] = vp.DataProtection - } - if vp.IsRestoring != nil { - objectMap["isRestoring"] = vp.IsRestoring - } - return json.Marshal(objectMap) -} - -// VolumePropertiesDataProtection dataProtection type volumes include an object containing details of the -// replication -type VolumePropertiesDataProtection struct { - // Replication - Replication properties - Replication *ReplicationObject `json:"replication,omitempty"` -} - -// VolumePropertiesExportPolicy set of export policy rules -type VolumePropertiesExportPolicy struct { - // Rules - Export policy rule - Rules *[]ExportPolicyRule `json:"rules,omitempty"` -} - -// VolumesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type VolumesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(VolumesClient) (Volume, error) -} - -// VolumesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type VolumesDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(VolumesClient) (autorest.Response, error) -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/CHANGELOG.md new file mode 100644 index 000000000000..e9164e5864bc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/b08824e05817297a4b2874d8db5e6fc8c29349c9//specification/netapp/resource-manager/readme.md tag: `package-netapp-2020-09-01` + +Code generator @microsoft.azure/autorest.go@2.1.171 + + diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accountbackups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accountbackups.go new file mode 100644 index 000000000000..75ae8ff956b9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accountbackups.go @@ -0,0 +1,313 @@ +package netapp + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountBackupsClient is the microsoft NetApp Azure Resource Provider specification +type AccountBackupsClient struct { + BaseClient +} + +// NewAccountBackupsClient creates an instance of the AccountBackupsClient client. +func NewAccountBackupsClient(subscriptionID string) AccountBackupsClient { + return NewAccountBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountBackupsClientWithBaseURI creates an instance of the AccountBackupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAccountBackupsClientWithBaseURI(baseURI string, subscriptionID string) AccountBackupsClient { + return AccountBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete Backup for a Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupName - the name of the backup +func (client AccountBackupsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, backupName string) (result AccountBackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.AccountBackupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountBackupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountBackupsClient) DeleteSender(req *http.Request) (future AccountBackupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client AccountBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.AccountBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get Backup for a Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupName - the name of the backup +func (client AccountBackupsClient) Get(ctx context.Context, resourceGroupName string, accountName string, backupName string) (result Backup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.AccountBackupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountBackupsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccountBackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountBackupsClient) GetResponder(resp *http.Response) (result Backup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all Backups for a Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +func (client AccountBackupsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result BackupsList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountBackupsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.AccountBackupsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountBackupsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountBackupsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/accountBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AccountBackupsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountBackupsClient) ListResponder(resp *http.Response) (result BackupsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accounts.go similarity index 91% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/accounts.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accounts.go index 6373282c93fd..c2d7333672e9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/accounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/accounts.go @@ -91,7 +91,7 @@ func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, body Ac "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -205,7 +205,7 @@ func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -310,7 +310,7 @@ func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -392,7 +392,7 @@ func (client AccountsClient) ListPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -428,13 +428,13 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL // body - netApp Account object supplied in the body of the operation. // resourceGroupName - the name of the resource group. // accountName - the name of the NetApp account -func (client AccountsClient) Update(ctx context.Context, body AccountPatch, resourceGroupName string, accountName string) (result Account, err error) { +func (client AccountsClient) Update(ctx context.Context, body AccountPatch, resourceGroupName string, accountName string) (result AccountsUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -453,16 +453,9 @@ func (client AccountsClient) Update(ctx context.Context, body AccountPatch, reso return } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "netapp.AccountsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) + result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "netapp.AccountsClient", "Update", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.AccountsClient", "Update", nil, "Failure sending request") return } @@ -477,7 +470,7 @@ func (client AccountsClient) UpdatePreparer(ctx context.Context, body AccountPat "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -497,8 +490,40 @@ func (client AccountsClient) UpdatePreparer(ctx context.Context, body AccountPat // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client AccountsClient) (a Account, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.AccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + a.Response.Response, err = future.GetResult(sender) + if a.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.AccountsUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.UpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.AccountsUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return + } + return } // UpdateResponder handles the response to the Update request. The method always @@ -506,7 +531,7 @@ func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, er func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backuppolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backuppolicies.go new file mode 100644 index 000000000000..f152c54814d6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backuppolicies.go @@ -0,0 +1,525 @@ +package netapp + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BackupPoliciesClient is the microsoft NetApp Azure Resource Provider specification +type BackupPoliciesClient struct { + BaseClient +} + +// NewBackupPoliciesClient creates an instance of the BackupPoliciesClient client. +func NewBackupPoliciesClient(subscriptionID string) BackupPoliciesClient { + return NewBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupPoliciesClientWithBaseURI creates an instance of the BackupPoliciesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupPoliciesClient { + return BackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a backup policy for Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupPolicyName - backup policy Name which uniquely identify backup policy. +// body - backup policy object supplied in the body of the operation. +func (client BackupPoliciesClient) Create(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string, body BackupPolicy) (result BackupPoliciesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupPoliciesClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.BackupPolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupPoliciesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, backupPolicyName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client BackupPoliciesClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string, body BackupPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupPolicyName": autorest.Encode("path", backupPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) CreateSender(req *http.Request) (future BackupPoliciesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client BackupPoliciesClient) (bp BackupPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.BackupPoliciesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + bp.Response.Response, err = future.GetResult(sender) + if bp.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesCreateFuture", "Result", nil, "received nil response and error") + } + if err == nil && bp.Response.Response.StatusCode != http.StatusNoContent { + bp, err = client.CreateResponder(bp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesCreateFuture", "Result", bp.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) CreateResponder(resp *http.Response) (result BackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete backup policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupPolicyName - backup policy Name which uniquely identify backup policy. +func (client BackupPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string) (result BackupPoliciesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupPoliciesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupPoliciesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, backupPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BackupPoliciesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupPolicyName": autorest.Encode("path", backupPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) DeleteSender(req *http.Request) (future BackupPoliciesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client BackupPoliciesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.BackupPoliciesDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a particular backup Policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupPolicyName - backup policy Name which uniquely identify backup policy. +func (client BackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string) (result BackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupPoliciesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, backupPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupPolicyName": autorest.Encode("path", backupPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) GetResponder(resp *http.Response) (result BackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list backup policies for Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +func (client BackupPoliciesClient) List(ctx context.Context, resourceGroupName string, accountName string) (result BackupPoliciesList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupPoliciesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupPoliciesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client BackupPoliciesClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) ListResponder(resp *http.Response) (result BackupPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update patch a backup policy for Netapp Account +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// backupPolicyName - backup policy Name which uniquely identify backup policy. +// body - backup policy object supplied in the body of the operation. +func (client BackupPoliciesClient) Update(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string, body BackupPolicyPatch) (result BackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupPoliciesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupPoliciesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, backupPolicyName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupPoliciesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackupPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, backupPolicyName string, body BackupPolicyPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupPolicyName": autorest.Encode("path", backupPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) UpdateResponder(resp *http.Response) (result BackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backups.go new file mode 100644 index 000000000000..877824f46398 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/backups.go @@ -0,0 +1,591 @@ +package netapp + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BackupsClient is the microsoft NetApp Azure Resource Provider specification +type BackupsClient struct { + BaseClient +} + +// NewBackupsClient creates an instance of the BackupsClient client. +func NewBackupsClient(subscriptionID string) BackupsClient { + return NewBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupsClientWithBaseURI creates an instance of the BackupsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackupsClientWithBaseURI(baseURI string, subscriptionID string) BackupsClient { + return BackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a backup for the volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// backupName - the name of the backup +// body - backup object supplied in the body of the operation. +func (client BackupsClient) Create(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string, body Backup) (result BackupsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.BackupProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "body.BackupProperties.BackupID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.BackupProperties.BackupID", Name: validation.MaxLength, Rule: 36, Chain: nil}, + {Target: "body.BackupProperties.BackupID", Name: validation.MinLength, Rule: 36, Chain: nil}, + {Target: "body.BackupProperties.BackupID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("netapp.BackupsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, poolName, volumeName, backupName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client BackupsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string, body Backup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/backups/{backupName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) CreateSender(req *http.Request) (future BackupsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client BackupsClient) (b Backup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.BackupsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + b.Response.Response, err = future.GetResult(sender) + if b.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsCreateFuture", "Result", nil, "received nil response and error") + } + if err == nil && b.Response.Response.StatusCode != http.StatusNoContent { + b, err = client.CreateResponder(b.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsCreateFuture", "Result", b.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client BackupsClient) CreateResponder(resp *http.Response) (result Backup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a backup of the volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// backupName - the name of the backup +func (client BackupsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string) (result BackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, poolName, volumeName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BackupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/backups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) DeleteSender(req *http.Request) (future BackupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client BackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.BackupsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a particular backup of the volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// backupName - the name of the backup +func (client BackupsClient) Get(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string) (result Backup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, poolName, volumeName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/backups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupsClient) GetResponder(resp *http.Response) (result Backup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all backups for a volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +func (client BackupsClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result BackupsList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, accountName, poolName, volumeName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client BackupsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/backups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BackupsClient) ListResponder(resp *http.Response) (result BackupsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update patch a backup for the volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// backupName - the name of the backup +// body - backup object supplied in the body of the operation. +func (client BackupsClient) Update(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string, body *BackupPatch) (result Backup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.BackupsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, poolName, volumeName, backupName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.BackupsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, backupName string, body *BackupPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "backupName": autorest.Encode("path", backupName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/backups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackupsClient) UpdateResponder(resp *http.Response) (result Backup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/client.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/client.go index b1a502897598..49a8d255514c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/client.go @@ -1,4 +1,4 @@ -// Package netapp implements the Azure ARM Netapp service API version 2019-10-01. +// Package netapp implements the Azure ARM Netapp service API version 2020-09-01. // // Microsoft NetApp Azure Resource Provider specification package netapp diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/enums.go similarity index 60% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/enums.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/enums.go index a200611a25fc..e9c6a3a994d0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/enums.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/enums.go @@ -17,6 +17,27 @@ package netapp // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// ActiveDirectoryStatus enumerates the values for active directory status. +type ActiveDirectoryStatus string + +const ( + // Created Active Directory created but not in use + Created ActiveDirectoryStatus = "Created" + // Deleted Active Directory Deleted + Deleted ActiveDirectoryStatus = "Deleted" + // Error Error with the Active Directory + Error ActiveDirectoryStatus = "Error" + // InUse Active Directory in use by SMB Volume + InUse ActiveDirectoryStatus = "InUse" + // Updating Active Directory Updating + Updating ActiveDirectoryStatus = "Updating" +) + +// PossibleActiveDirectoryStatusValues returns an array of possible values for the ActiveDirectoryStatus const type. +func PossibleActiveDirectoryStatusValues() []ActiveDirectoryStatus { + return []ActiveDirectoryStatus{Created, Deleted, Error, InUse, Updating} +} + // CheckNameResourceTypes enumerates the values for check name resource types. type CheckNameResourceTypes string @@ -36,6 +57,25 @@ func PossibleCheckNameResourceTypesValues() []CheckNameResourceTypes { return []CheckNameResourceTypes{MicrosoftNetAppnetAppAccounts, MicrosoftNetAppnetAppAccountscapacityPools, MicrosoftNetAppnetAppAccountscapacityPoolsvolumes, MicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots} } +// CheckQuotaNameResourceTypes enumerates the values for check quota name resource types. +type CheckQuotaNameResourceTypes string + +const ( + // CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccounts ... + CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccounts CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts" + // CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPools ... + CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPools CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools" + // CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumes ... + CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumes CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes" + // CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots ... + CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots CheckQuotaNameResourceTypes = "Microsoft.NetApp/netAppAccounts/capacityPools/volumes/snapshots" +) + +// PossibleCheckQuotaNameResourceTypesValues returns an array of possible values for the CheckQuotaNameResourceTypes const type. +func PossibleCheckQuotaNameResourceTypesValues() []CheckQuotaNameResourceTypes { + return []CheckQuotaNameResourceTypes{CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccounts, CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPools, CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumes, CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots} +} + // EndpointType enumerates the values for endpoint type. type EndpointType string @@ -83,6 +123,21 @@ func PossibleMirrorStateValues() []MirrorState { return []MirrorState{Broken, Mirrored, Uninitialized} } +// QosType enumerates the values for qos type. +type QosType string + +const ( + // Auto qos type Auto + Auto QosType = "Auto" + // Manual qos type Manual + Manual QosType = "Manual" +) + +// PossibleQosTypeValues returns an array of possible values for the QosType const type. +func PossibleQosTypeValues() []QosType { + return []QosType{Auto, Manual} +} + // RelationshipStatus enumerates the values for relationship status. type RelationshipStatus string @@ -115,6 +170,21 @@ func PossibleReplicationScheduleValues() []ReplicationSchedule { return []ReplicationSchedule{OneZerominutely, Daily, Hourly} } +// SecurityStyle enumerates the values for security style. +type SecurityStyle string + +const ( + // Ntfs ... + Ntfs SecurityStyle = "ntfs" + // Unix ... + Unix SecurityStyle = "unix" +) + +// PossibleSecurityStyleValues returns an array of possible values for the SecurityStyle const type. +func PossibleSecurityStyleValues() []SecurityStyle { + return []SecurityStyle{Ntfs, Unix} +} + // ServiceLevel enumerates the values for service level. type ServiceLevel string diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/models.go new file mode 100644 index 000000000000..3416742fa5d6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/models.go @@ -0,0 +1,2873 @@ +package netapp + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp" + +// Account netApp account resource +type Account struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AccountProperties - NetApp Account properties + *AccountProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.Location != nil { + objectMap["location"] = a.Location + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + case "properties": + if v != nil { + var accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + } + } + + return nil +} + +// AccountBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountBackupsClient) (autorest.Response, error) +} + +// AccountList list of NetApp account resources +type AccountList struct { + autorest.Response `json:"-"` + // Value - Multiple NetApp accounts + Value *[]Account `json:"value,omitempty"` +} + +// AccountPatch netApp account patch resource +type AccountPatch struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AccountProperties - NetApp Account properties + *AccountProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountPatch. +func (ap AccountPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.Location != nil { + objectMap["location"] = ap.Location + } + if ap.Tags != nil { + objectMap["tags"] = ap.Tags + } + if ap.AccountProperties != nil { + objectMap["properties"] = ap.AccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountPatch struct. +func (ap *AccountPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ap.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ap.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ap.Tags = tags + } + case "properties": + if v != nil { + var accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + ap.AccountProperties = &accountProperties + } + } + } + + return nil +} + +// AccountProperties netApp account properties +type AccountProperties struct { + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` + // ActiveDirectories - Active Directories + ActiveDirectories *[]ActiveDirectory `json:"activeDirectories,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountProperties. +func (ap AccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.ActiveDirectories != nil { + objectMap["activeDirectories"] = ap.ActiveDirectories + } + return json.Marshal(objectMap) +} + +// AccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (Account, error) +} + +// AccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (autorest.Response, error) +} + +// AccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (Account, error) +} + +// ActiveDirectory active Directory +type ActiveDirectory struct { + // ActiveDirectoryID - Id of the Active Directory + ActiveDirectoryID *string `json:"activeDirectoryId,omitempty"` + // Username - Username of Active Directory domain administrator + Username *string `json:"username,omitempty"` + // Password - Plain text password of Active Directory domain administrator, value is masked in the response + Password *string `json:"password,omitempty"` + // Domain - Name of the Active Directory domain + Domain *string `json:"domain,omitempty"` + // DNS - Comma separated list of DNS server IP addresses (IPv4 only) for the Active Directory domain + DNS *string `json:"dns,omitempty"` + // Status - READ-ONLY; Status of the Active Directory. Possible values include: 'Created', 'InUse', 'Deleted', 'Error', 'Updating' + Status ActiveDirectoryStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Any details in regards to the Status of the Active Directory + StatusDetails *string `json:"statusDetails,omitempty"` + // SmbServerName - NetBIOS name of the SMB server. This name will be registered as a computer account in the AD and used to mount volumes + SmbServerName *string `json:"smbServerName,omitempty"` + // OrganizationalUnit - The Organizational Unit (OU) within the Windows Active Directory + OrganizationalUnit *string `json:"organizationalUnit,omitempty"` + // Site - The Active Directory site the service will limit Domain Controller discovery to + Site *string `json:"site,omitempty"` + // BackupOperators - Users to be added to the Built-in Backup Operator active directory group. A list of unique usernames without domain specifier + BackupOperators *[]string `json:"backupOperators,omitempty"` + // KdcIP - kdc server IP addresses for the active directory machine. This optional parameter is used only while creating kerberos volume. + KdcIP *string `json:"kdcIP,omitempty"` + // AdName - Name of the active directory machine. This optional parameter is used only while creating kerberos volume + AdName *string `json:"adName,omitempty"` + // ServerRootCACertificate - When LDAP over SSL/TLS is enabled, the LDAP client is required to have base64 encoded Active Directory Certificate Service's self-signed root CA certificate, this optional parameter is used only for dual protocol with LDAP user-mapping volumes. + ServerRootCACertificate *string `json:"serverRootCACertificate,omitempty"` + // AesEncryption - If enabled, AES encryption will be enabled for SMB communication. + AesEncryption *bool `json:"aesEncryption,omitempty"` + // LdapSigning - Specifies whether or not the LDAP traffic needs to be signed. + LdapSigning *bool `json:"ldapSigning,omitempty"` + // SecurityOperators - Domain Users in the Active directory to be given SeSecurityPrivilege privilege (Needed for SMB Continuously available shares for SQL). A list of unique usernames without domain specifier + SecurityOperators *[]string `json:"securityOperators,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActiveDirectory. +func (ad ActiveDirectory) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ad.ActiveDirectoryID != nil { + objectMap["activeDirectoryId"] = ad.ActiveDirectoryID + } + if ad.Username != nil { + objectMap["username"] = ad.Username + } + if ad.Password != nil { + objectMap["password"] = ad.Password + } + if ad.Domain != nil { + objectMap["domain"] = ad.Domain + } + if ad.DNS != nil { + objectMap["dns"] = ad.DNS + } + if ad.SmbServerName != nil { + objectMap["smbServerName"] = ad.SmbServerName + } + if ad.OrganizationalUnit != nil { + objectMap["organizationalUnit"] = ad.OrganizationalUnit + } + if ad.Site != nil { + objectMap["site"] = ad.Site + } + if ad.BackupOperators != nil { + objectMap["backupOperators"] = ad.BackupOperators + } + if ad.KdcIP != nil { + objectMap["kdcIP"] = ad.KdcIP + } + if ad.AdName != nil { + objectMap["adName"] = ad.AdName + } + if ad.ServerRootCACertificate != nil { + objectMap["serverRootCACertificate"] = ad.ServerRootCACertificate + } + if ad.AesEncryption != nil { + objectMap["aesEncryption"] = ad.AesEncryption + } + if ad.LdapSigning != nil { + objectMap["ldapSigning"] = ad.LdapSigning + } + if ad.SecurityOperators != nil { + objectMap["securityOperators"] = ad.SecurityOperators + } + return json.Marshal(objectMap) +} + +// AuthorizeRequest authorize request +type AuthorizeRequest struct { + // RemoteVolumeResourceID - Resource id of the remote volume + RemoteVolumeResourceID *string `json:"remoteVolumeResourceId,omitempty"` +} + +// Backup backup of a Volume +type Backup struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // BackupProperties - Backup Properties + *BackupProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if b.Location != nil { + objectMap["location"] = b.Location + } + if b.BackupProperties != nil { + objectMap["properties"] = b.BackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Backup struct. +func (b *Backup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + b.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + b.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + b.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + b.Type = &typeVar + } + case "properties": + if v != nil { + var backupProperties BackupProperties + err = json.Unmarshal(*v, &backupProperties) + if err != nil { + return err + } + b.BackupProperties = &backupProperties + } + } + } + + return nil +} + +// BackupPatch backup patch +type BackupPatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // BackupProperties - Backup Properties + *BackupProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupPatch. +func (bp BackupPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bp.Tags != nil { + objectMap["tags"] = bp.Tags + } + if bp.BackupProperties != nil { + objectMap["properties"] = bp.BackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupPatch struct. +func (bp *BackupPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + bp.Tags = tags + } + case "properties": + if v != nil { + var backupProperties BackupProperties + err = json.Unmarshal(*v, &backupProperties) + if err != nil { + return err + } + bp.BackupProperties = &backupProperties + } + } + } + + return nil +} + +// BackupPoliciesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type BackupPoliciesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupPoliciesClient) (BackupPolicy, error) +} + +// BackupPoliciesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type BackupPoliciesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupPoliciesClient) (autorest.Response, error) +} + +// BackupPoliciesList list of Backup Policies +type BackupPoliciesList struct { + autorest.Response `json:"-"` + // Value - A list of backup policies + Value *[]BackupPolicy `json:"value,omitempty"` +} + +// BackupPolicy backup policy information +type BackupPolicy struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // BackupPolicyProperties - Backup policy Properties + *BackupPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupPolicy. +func (bp BackupPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bp.Location != nil { + objectMap["location"] = bp.Location + } + if bp.Tags != nil { + objectMap["tags"] = bp.Tags + } + if bp.BackupPolicyProperties != nil { + objectMap["properties"] = bp.BackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupPolicy struct. +func (bp *BackupPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + bp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + bp.Tags = tags + } + case "properties": + if v != nil { + var backupPolicyProperties BackupPolicyProperties + err = json.Unmarshal(*v, &backupPolicyProperties) + if err != nil { + return err + } + bp.BackupPolicyProperties = &backupPolicyProperties + } + } + } + + return nil +} + +// BackupPolicyDetails backup policy properties +type BackupPolicyDetails struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // BackupPolicyProperties - Backup policy Properties + *BackupPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupPolicyDetails. +func (bpd BackupPolicyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bpd.Location != nil { + objectMap["location"] = bpd.Location + } + if bpd.Tags != nil { + objectMap["tags"] = bpd.Tags + } + if bpd.BackupPolicyProperties != nil { + objectMap["properties"] = bpd.BackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupPolicyDetails struct. +func (bpd *BackupPolicyDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + bpd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bpd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bpd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bpd.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + bpd.Tags = tags + } + case "properties": + if v != nil { + var backupPolicyProperties BackupPolicyProperties + err = json.Unmarshal(*v, &backupPolicyProperties) + if err != nil { + return err + } + bpd.BackupPolicyProperties = &backupPolicyProperties + } + } + } + + return nil +} + +// BackupPolicyPatch backup policy Details for create and update +type BackupPolicyPatch struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // BackupPolicyProperties - Backup policy Properties + *BackupPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupPolicyPatch. +func (bpp BackupPolicyPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bpp.Location != nil { + objectMap["location"] = bpp.Location + } + if bpp.Tags != nil { + objectMap["tags"] = bpp.Tags + } + if bpp.BackupPolicyProperties != nil { + objectMap["properties"] = bpp.BackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupPolicyPatch struct. +func (bpp *BackupPolicyPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + bpp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bpp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bpp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bpp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + bpp.Tags = tags + } + case "properties": + if v != nil { + var backupPolicyProperties BackupPolicyProperties + err = json.Unmarshal(*v, &backupPolicyProperties) + if err != nil { + return err + } + bpp.BackupPolicyProperties = &backupPolicyProperties + } + } + } + + return nil +} + +// BackupPolicyProperties backup policy properties +type BackupPolicyProperties struct { + // Name - READ-ONLY; Name of backup policy + Name *string `json:"name,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` + // DailyBackupsToKeep - Daily backups count to keep + DailyBackupsToKeep *int32 `json:"dailyBackupsToKeep,omitempty"` + // WeeklyBackupsToKeep - Weekly backups count to keep + WeeklyBackupsToKeep *int32 `json:"weeklyBackupsToKeep,omitempty"` + // MonthlyBackupsToKeep - Monthly backups count to keep + MonthlyBackupsToKeep *int32 `json:"monthlyBackupsToKeep,omitempty"` + // YearlyBackupsToKeep - Yearly backups count to keep + YearlyBackupsToKeep *int32 `json:"yearlyBackupsToKeep,omitempty"` + // VolumesAssigned - Volumes using current backup policy + VolumesAssigned *int32 `json:"volumesAssigned,omitempty"` + // Enabled - The property to decide policy is enabled or not + Enabled *bool `json:"enabled,omitempty"` + // VolumeBackups - A list of volumes assigned to this policy + VolumeBackups *[]VolumeBackups `json:"volumeBackups,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupPolicyProperties. +func (bpp BackupPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bpp.DailyBackupsToKeep != nil { + objectMap["dailyBackupsToKeep"] = bpp.DailyBackupsToKeep + } + if bpp.WeeklyBackupsToKeep != nil { + objectMap["weeklyBackupsToKeep"] = bpp.WeeklyBackupsToKeep + } + if bpp.MonthlyBackupsToKeep != nil { + objectMap["monthlyBackupsToKeep"] = bpp.MonthlyBackupsToKeep + } + if bpp.YearlyBackupsToKeep != nil { + objectMap["yearlyBackupsToKeep"] = bpp.YearlyBackupsToKeep + } + if bpp.VolumesAssigned != nil { + objectMap["volumesAssigned"] = bpp.VolumesAssigned + } + if bpp.Enabled != nil { + objectMap["enabled"] = bpp.Enabled + } + if bpp.VolumeBackups != nil { + objectMap["volumeBackups"] = bpp.VolumeBackups + } + return json.Marshal(objectMap) +} + +// BackupProperties backup properties +type BackupProperties struct { + // BackupID - READ-ONLY; UUID v4 used to identify the Backup + BackupID *string `json:"backupId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the backup + CreationDate *date.Time `json:"creationDate,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` + // Size - READ-ONLY; Size of backup + Size *int64 `json:"size,omitempty"` + // Label - Label for backup + Label *string `json:"label,omitempty"` + // BackupType - READ-ONLY; Type of backup adhoc or scheduled + BackupType *string `json:"backupType,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupProperties. +func (bp BackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bp.Label != nil { + objectMap["label"] = bp.Label + } + return json.Marshal(objectMap) +} + +// BackupsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type BackupsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupsClient) (Backup, error) +} + +// BackupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type BackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupsClient) (autorest.Response, error) +} + +// BackupsList list of Backups +type BackupsList struct { + autorest.Response `json:"-"` + // Value - A list of Backups + Value *[]Backup `json:"value,omitempty"` +} + +// BreakReplicationRequest break replication request +type BreakReplicationRequest struct { + // ForceBreakReplication - If replication is in status transferring and you want to force break the replication, set to true + ForceBreakReplication *bool `json:"forceBreakReplication,omitempty"` +} + +// CapacityPool capacity pool resource +type CapacityPool struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // PoolProperties - Capacity pool properties + *PoolProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapacityPool. +func (cp CapacityPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Location != nil { + objectMap["location"] = cp.Location + } + if cp.Tags != nil { + objectMap["tags"] = cp.Tags + } + if cp.PoolProperties != nil { + objectMap["properties"] = cp.PoolProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CapacityPool struct. +func (cp *CapacityPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + cp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cp.Tags = tags + } + case "properties": + if v != nil { + var poolProperties PoolProperties + err = json.Unmarshal(*v, &poolProperties) + if err != nil { + return err + } + cp.PoolProperties = &poolProperties + } + } + } + + return nil +} + +// CapacityPoolList list of capacity pool resources +type CapacityPoolList struct { + autorest.Response `json:"-"` + // Value - List of Capacity pools + Value *[]CapacityPool `json:"value,omitempty"` +} + +// CapacityPoolPatch capacity pool patch resource +type CapacityPoolPatch struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // PoolPatchProperties - Capacity pool properties + *PoolPatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapacityPoolPatch. +func (cpp CapacityPoolPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpp.Location != nil { + objectMap["location"] = cpp.Location + } + if cpp.Tags != nil { + objectMap["tags"] = cpp.Tags + } + if cpp.PoolPatchProperties != nil { + objectMap["properties"] = cpp.PoolPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CapacityPoolPatch struct. +func (cpp *CapacityPoolPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + cpp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cpp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cpp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cpp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cpp.Tags = tags + } + case "properties": + if v != nil { + var poolPatchProperties PoolPatchProperties + err = json.Unmarshal(*v, &poolPatchProperties) + if err != nil { + return err + } + cpp.PoolPatchProperties = &poolPatchProperties + } + } + } + + return nil +} + +// CheckAvailabilityResponse information regarding availability of a resource. +type CheckAvailabilityResponse struct { + autorest.Response `json:"-"` + // IsAvailable - true indicates name is valid and available. false indicates the name is invalid, unavailable, or both. + IsAvailable *bool `json:"isAvailable,omitempty"` + // Reason - Invalid indicates the name provided does not match Azure App Service naming requirements. AlreadyExists indicates that the name is already in use and is therefore unavailable. Possible values include: 'Invalid', 'AlreadyExists' + Reason InAvailabilityReasonType `json:"reason,omitempty"` + // Message - If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that resource name is already in use, and direct them to select a different name. + Message *string `json:"message,omitempty"` +} + +// DailySchedule daily Schedule properties +type DailySchedule struct { + // SnapshotsToKeep - Daily snapshot count to keep + SnapshotsToKeep *int32 `json:"snapshotsToKeep,omitempty"` + // Hour - Indicates which hour in UTC timezone a snapshot should be taken + Hour *int32 `json:"hour,omitempty"` + // Minute - Indicates which minute snapshot should be taken + Minute *int32 `json:"minute,omitempty"` + // UsedBytes - Resource size in bytes, current storage usage for the volume in bytes + UsedBytes *int64 `json:"usedBytes,omitempty"` +} + +// Dimension dimension of blobs, possibly be blob type or access tier. +type Dimension struct { + // Name - Display name of dimension. + Name *string `json:"name,omitempty"` + // DisplayName - Display name of dimension. + DisplayName *string `json:"displayName,omitempty"` +} + +// ExportPolicyRule volume Export Policy Rule +type ExportPolicyRule struct { + // RuleIndex - Order index + RuleIndex *int32 `json:"ruleIndex,omitempty"` + // UnixReadOnly - Read only access + UnixReadOnly *bool `json:"unixReadOnly,omitempty"` + // UnixReadWrite - Read and write access + UnixReadWrite *bool `json:"unixReadWrite,omitempty"` + // Kerberos5ReadOnly - Kerberos5 Read only access. To be use with swagger version 2020-05-01 or later + Kerberos5ReadOnly *bool `json:"kerberos5ReadOnly,omitempty"` + // Kerberos5ReadWrite - Kerberos5 Read and write access. To be use with swagger version 2020-05-01 or later + Kerberos5ReadWrite *bool `json:"kerberos5ReadWrite,omitempty"` + // Kerberos5iReadOnly - Kerberos5i Read only access. To be use with swagger version 2020-05-01 or later + Kerberos5iReadOnly *bool `json:"kerberos5iReadOnly,omitempty"` + // Kerberos5iReadWrite - Kerberos5i Read and write access. To be use with swagger version 2020-05-01 or later + Kerberos5iReadWrite *bool `json:"kerberos5iReadWrite,omitempty"` + // Kerberos5pReadOnly - Kerberos5p Read only access. To be use with swagger version 2020-05-01 or later + Kerberos5pReadOnly *bool `json:"kerberos5pReadOnly,omitempty"` + // Kerberos5pReadWrite - Kerberos5p Read and write access. To be use with swagger version 2020-05-01 or later + Kerberos5pReadWrite *bool `json:"kerberos5pReadWrite,omitempty"` + // Cifs - Allows CIFS protocol + Cifs *bool `json:"cifs,omitempty"` + // Nfsv3 - Allows NFSv3 protocol. Enable only for NFSv3 type volumes + Nfsv3 *bool `json:"nfsv3,omitempty"` + // Nfsv41 - Allows NFSv4.1 protocol. Enable only for NFSv4.1 type volumes + Nfsv41 *bool `json:"nfsv41,omitempty"` + // AllowedClients - Client ingress specification as comma separated string with IPv4 CIDRs, IPv4 host addresses and host names + AllowedClients *string `json:"allowedClients,omitempty"` + // HasRootAccess - Has root access to volume + HasRootAccess *bool `json:"hasRootAccess,omitempty"` +} + +// HourlySchedule hourly Schedule properties +type HourlySchedule struct { + // SnapshotsToKeep - Hourly snapshot count to keep + SnapshotsToKeep *int32 `json:"snapshotsToKeep,omitempty"` + // Minute - Indicates which minute snapshot should be taken + Minute *int32 `json:"minute,omitempty"` + // UsedBytes - Resource size in bytes, current storage usage for the volume in bytes + UsedBytes *int64 `json:"usedBytes,omitempty"` +} + +// MetricSpecification metric specification of operation. +type MetricSpecification struct { + // Name - Name of metric specification. + Name *string `json:"name,omitempty"` + // DisplayName - Display name of metric specification. + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Display description of metric specification. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - Unit could be Bytes or Count. + Unit *string `json:"unit,omitempty"` + // Dimensions - Dimensions of blobs, including blob type and access tier. + Dimensions *[]Dimension `json:"dimensions,omitempty"` + // AggregationType - Aggregation type could be Average. + AggregationType *string `json:"aggregationType,omitempty"` + // FillGapWithZero - The property to decide fill gap with zero or not. + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + // Category - The category this metric specification belong to, could be Capacity. + Category *string `json:"category,omitempty"` + // ResourceIDDimensionNameOverride - Account Resource Id. + ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` +} + +// MonthlySchedule monthly Schedule properties +type MonthlySchedule struct { + // SnapshotsToKeep - Monthly snapshot count to keep + SnapshotsToKeep *int32 `json:"snapshotsToKeep,omitempty"` + // DaysOfMonth - Indicates which days of the month snapshot should be taken. A comma delimited string. + DaysOfMonth *string `json:"daysOfMonth,omitempty"` + // Hour - Indicates which hour in UTC timezone a snapshot should be taken + Hour *int32 `json:"hour,omitempty"` + // Minute - Indicates which minute snapshot should be taken + Minute *int32 `json:"minute,omitempty"` + // UsedBytes - Resource size in bytes, current storage usage for the volume in bytes + UsedBytes *int64 `json:"usedBytes,omitempty"` +} + +// MountTarget mount Target +type MountTarget struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // MountTargetProperties - Mount Target Properties + *MountTargetProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MountTarget. +func (mt MountTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mt.Location != nil { + objectMap["location"] = mt.Location + } + if mt.Tags != nil { + objectMap["tags"] = mt.Tags + } + if mt.MountTargetProperties != nil { + objectMap["properties"] = mt.MountTargetProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MountTarget struct. +func (mt *MountTarget) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mt.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mt.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mt.Tags = tags + } + case "properties": + if v != nil { + var mountTargetProperties MountTargetProperties + err = json.Unmarshal(*v, &mountTargetProperties) + if err != nil { + return err + } + mt.MountTargetProperties = &mountTargetProperties + } + } + } + + return nil +} + +// MountTargetProperties mount target properties +type MountTargetProperties struct { + // MountTargetID - READ-ONLY; UUID v4 used to identify the MountTarget + MountTargetID *string `json:"mountTargetId,omitempty"` + // FileSystemID - UUID v4 used to identify the MountTarget + FileSystemID *string `json:"fileSystemId,omitempty"` + // IPAddress - READ-ONLY; The mount target's IPv4 address + IPAddress *string `json:"ipAddress,omitempty"` + // SmbServerFqdn - The SMB server's Fully Qualified Domain Name, FQDN + SmbServerFqdn *string `json:"smbServerFqdn,omitempty"` +} + +// MarshalJSON is the custom marshaler for MountTargetProperties. +func (mtp MountTargetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mtp.FileSystemID != nil { + objectMap["fileSystemId"] = mtp.FileSystemID + } + if mtp.SmbServerFqdn != nil { + objectMap["smbServerFqdn"] = mtp.SmbServerFqdn + } + return json.Marshal(objectMap) +} + +// Operation microsoft.NetApp REST API operation definition. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The origin of operations. + Origin *string `json:"origin,omitempty"` + // OperationProperties - Properties of operation, include metric specifications. + *OperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Origin != nil { + objectMap["origin"] = o.Origin + } + if o.OperationProperties != nil { + objectMap["properties"] = o.OperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Operation struct. +func (o *Operation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + o.Name = &name + } + case "display": + if v != nil { + var display OperationDisplay + err = json.Unmarshal(*v, &display) + if err != nil { + return err + } + o.Display = &display + } + case "origin": + if v != nil { + var origin string + err = json.Unmarshal(*v, &origin) + if err != nil { + return err + } + o.Origin = &origin + } + case "properties": + if v != nil { + var operationProperties OperationProperties + err = json.Unmarshal(*v, &operationProperties) + if err != nil { + return err + } + o.OperationProperties = &operationProperties + } + } + } + + return nil +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft NetApp. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed etc. + Resource *string `json:"resource,omitempty"` + // Operation - Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Operation description. + Description *string `json:"description,omitempty"` +} + +// OperationListResult result of the request to list Cloud Volume operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Storage operations supported by the Storage resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// OperationProperties properties of operation, include metric specifications. +type OperationProperties struct { + // ServiceSpecification - One property of operation, include metric specifications. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PoolChangeRequest pool change request +type PoolChangeRequest struct { + // NewPoolResourceID - Resource id of the pool to move volume to + NewPoolResourceID *string `json:"newPoolResourceId,omitempty"` +} + +// PoolPatchProperties patchable pool properties +type PoolPatchProperties struct { + // Size - Provisioned size of the pool (in bytes). Allowed values are in 4TiB chunks (value must be multiply of 4398046511104). + Size *int64 `json:"size,omitempty"` + // QosType - The qos type of the pool. Possible values include: 'Auto', 'Manual' + QosType QosType `json:"qosType,omitempty"` +} + +// PoolProperties pool properties +type PoolProperties struct { + // PoolID - READ-ONLY; UUID v4 used to identify the Pool + PoolID *string `json:"poolId,omitempty"` + // Size - Provisioned size of the pool (in bytes). Allowed values are in 4TiB chunks (value must be multiply of 4398046511104). + Size *int64 `json:"size,omitempty"` + // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' + ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` + // TotalThroughputMibps - READ-ONLY; Total throughput of pool in Mibps + TotalThroughputMibps *float64 `json:"totalThroughputMibps,omitempty"` + // UtilizedThroughputMibps - READ-ONLY; Utilized throughput of pool in Mibps + UtilizedThroughputMibps *float64 `json:"utilizedThroughputMibps,omitempty"` + // QosType - The qos type of the pool. Possible values include: 'Auto', 'Manual' + QosType QosType `json:"qosType,omitempty"` +} + +// MarshalJSON is the custom marshaler for PoolProperties. +func (pp PoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pp.Size != nil { + objectMap["size"] = pp.Size + } + if pp.ServiceLevel != "" { + objectMap["serviceLevel"] = pp.ServiceLevel + } + if pp.QosType != "" { + objectMap["qosType"] = pp.QosType + } + return json.Marshal(objectMap) +} + +// PoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PoolsClient) (CapacityPool, error) +} + +// PoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type PoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PoolsClient) (autorest.Response, error) +} + +// PoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type PoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PoolsClient) (CapacityPool, error) +} + +// QuotaAvailabilityRequest quota availability request content. +type QuotaAvailabilityRequest struct { + // Name - Name of the resource to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. Possible values include: 'CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccounts', 'CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPools', 'CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumes', 'CheckQuotaNameResourceTypesMicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots' + Type CheckQuotaNameResourceTypes `json:"type,omitempty"` + // ResourceGroup - Resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty"` +} + +// ReplicationObject replication properties +type ReplicationObject struct { + // ReplicationID - Id + ReplicationID *string `json:"replicationId,omitempty"` + // EndpointType - Indicates whether the local volume is the source or destination for the Volume Replication. Possible values include: 'Src', 'Dst' + EndpointType EndpointType `json:"endpointType,omitempty"` + // ReplicationSchedule - Schedule. Possible values include: '10minutely', 'Hourly', 'Daily' + ReplicationSchedule ReplicationSchedule `json:"replicationSchedule,omitempty"` + // RemoteVolumeResourceID - The resource ID of the remote volume. + RemoteVolumeResourceID *string `json:"remoteVolumeResourceId,omitempty"` + // RemoteVolumeRegion - The remote region for the other end of the Volume Replication. + RemoteVolumeRegion *string `json:"remoteVolumeRegion,omitempty"` +} + +// ReplicationStatus replication status +type ReplicationStatus struct { + autorest.Response `json:"-"` + // Healthy - Replication health check + Healthy *bool `json:"healthy,omitempty"` + // RelationshipStatus - Status of the mirror relationship. Possible values include: 'Idle', 'Transferring' + RelationshipStatus RelationshipStatus `json:"relationshipStatus,omitempty"` + // MirrorState - The status of the replication. Possible values include: 'Uninitialized', 'Mirrored', 'Broken' + MirrorState MirrorState `json:"mirrorState,omitempty"` + // TotalProgress - The progress of the replication + TotalProgress *string `json:"totalProgress,omitempty"` + // ErrorMessage - Displays error message if the replication is in an error state + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// ResourceNameAvailabilityRequest resource name availability request content. +type ResourceNameAvailabilityRequest struct { + // Name - Resource name to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. Possible values include: 'MicrosoftNetAppnetAppAccounts', 'MicrosoftNetAppnetAppAccountscapacityPools', 'MicrosoftNetAppnetAppAccountscapacityPoolsvolumes', 'MicrosoftNetAppnetAppAccountscapacityPoolsvolumessnapshots' + Type CheckNameResourceTypes `json:"type,omitempty"` + // ResourceGroup - Resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty"` +} + +// ServiceSpecification one property of operation, include metric specifications. +type ServiceSpecification struct { + // MetricSpecifications - Metric specifications of operation. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// Snapshot snapshot of a Volume +type Snapshot struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // SnapshotProperties - Snapshot Properties + *SnapshotProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Snapshot. +func (s Snapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.SnapshotProperties != nil { + objectMap["properties"] = s.SnapshotProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Snapshot struct. +func (s *Snapshot) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + case "properties": + if v != nil { + var snapshotProperties SnapshotProperties + err = json.Unmarshal(*v, &snapshotProperties) + if err != nil { + return err + } + s.SnapshotProperties = &snapshotProperties + } + } + } + + return nil +} + +// SnapshotPoliciesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SnapshotPoliciesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SnapshotPoliciesClient) (autorest.Response, error) +} + +// SnapshotPoliciesList list of Snapshot Policies +type SnapshotPoliciesList struct { + autorest.Response `json:"-"` + // Value - A list of snapshot policies + Value *[]SnapshotPolicy `json:"value,omitempty"` +} + +// SnapshotPolicy snapshot policy information +type SnapshotPolicy struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // SnapshotPolicyProperties - Snapshot policy Properties + *SnapshotPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SnapshotPolicy. +func (sp SnapshotPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.Location != nil { + objectMap["location"] = sp.Location + } + if sp.Tags != nil { + objectMap["tags"] = sp.Tags + } + if sp.SnapshotPolicyProperties != nil { + objectMap["properties"] = sp.SnapshotPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SnapshotPolicy struct. +func (sp *SnapshotPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sp.Tags = tags + } + case "properties": + if v != nil { + var snapshotPolicyProperties SnapshotPolicyProperties + err = json.Unmarshal(*v, &snapshotPolicyProperties) + if err != nil { + return err + } + sp.SnapshotPolicyProperties = &snapshotPolicyProperties + } + } + } + + return nil +} + +// SnapshotPolicyDetails snapshot policy properties +type SnapshotPolicyDetails struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // SnapshotPolicyProperties - Snapshot policy Properties + *SnapshotPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SnapshotPolicyDetails. +func (spd SnapshotPolicyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spd.Location != nil { + objectMap["location"] = spd.Location + } + if spd.Tags != nil { + objectMap["tags"] = spd.Tags + } + if spd.SnapshotPolicyProperties != nil { + objectMap["properties"] = spd.SnapshotPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SnapshotPolicyDetails struct. +func (spd *SnapshotPolicyDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + spd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + spd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + spd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + spd.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spd.Tags = tags + } + case "properties": + if v != nil { + var snapshotPolicyProperties SnapshotPolicyProperties + err = json.Unmarshal(*v, &snapshotPolicyProperties) + if err != nil { + return err + } + spd.SnapshotPolicyProperties = &snapshotPolicyProperties + } + } + } + + return nil +} + +// SnapshotPolicyPatch snapshot policy Details for create and update +type SnapshotPolicyPatch struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // SnapshotPolicyProperties - Snapshot Policy properties + *SnapshotPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SnapshotPolicyPatch. +func (spp SnapshotPolicyPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spp.Location != nil { + objectMap["location"] = spp.Location + } + if spp.Tags != nil { + objectMap["tags"] = spp.Tags + } + if spp.SnapshotPolicyProperties != nil { + objectMap["properties"] = spp.SnapshotPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SnapshotPolicyPatch struct. +func (spp *SnapshotPolicyPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + spp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + spp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + spp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + spp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spp.Tags = tags + } + case "properties": + if v != nil { + var snapshotPolicyProperties SnapshotPolicyProperties + err = json.Unmarshal(*v, &snapshotPolicyProperties) + if err != nil { + return err + } + spp.SnapshotPolicyProperties = &snapshotPolicyProperties + } + } + } + + return nil +} + +// SnapshotPolicyProperties snapshot policy properties +type SnapshotPolicyProperties struct { + // Name - READ-ONLY; Snapshot policy name + Name *string `json:"name,omitempty"` + // HourlySchedule - Schedule for hourly snapshots + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + // DailySchedule - Schedule for daily snapshots + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + // WeeklySchedule - Schedule for weekly snapshots + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` + // MonthlySchedule - Schedule for monthly snapshots + MonthlySchedule *MonthlySchedule `json:"monthlySchedule,omitempty"` + // Enabled - The property to decide policy is enabled or not + Enabled *bool `json:"enabled,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for SnapshotPolicyProperties. +func (spp SnapshotPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spp.HourlySchedule != nil { + objectMap["hourlySchedule"] = spp.HourlySchedule + } + if spp.DailySchedule != nil { + objectMap["dailySchedule"] = spp.DailySchedule + } + if spp.WeeklySchedule != nil { + objectMap["weeklySchedule"] = spp.WeeklySchedule + } + if spp.MonthlySchedule != nil { + objectMap["monthlySchedule"] = spp.MonthlySchedule + } + if spp.Enabled != nil { + objectMap["enabled"] = spp.Enabled + } + return json.Marshal(objectMap) +} + +// SnapshotPolicyVolumeList volumes associated with snapshot policy +type SnapshotPolicyVolumeList struct { + autorest.Response `json:"-"` + // Value - List of volumes + Value *[]interface{} `json:"value,omitempty"` +} + +// SnapshotProperties snapshot properties +type SnapshotProperties struct { + // SnapshotID - READ-ONLY; UUID v4 used to identify the Snapshot + SnapshotID *string `json:"snapshotId,omitempty"` + // Created - READ-ONLY; The creation date of the snapshot + Created *date.Time `json:"created,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// SnapshotsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SnapshotsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SnapshotsClient) (Snapshot, error) +} + +// SnapshotsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SnapshotsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SnapshotsClient) (autorest.Response, error) +} + +// SnapshotsList list of Snapshots +type SnapshotsList struct { + autorest.Response `json:"-"` + // Value - A list of Snapshots + Value *[]Snapshot `json:"value,omitempty"` +} + +// SnapshotsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SnapshotsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SnapshotsClient) (Snapshot, error) +} + +// Vault vault information +type Vault struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // VaultProperties - Vault Properties + *VaultProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Vault. +func (vVar Vault) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vVar.Location != nil { + objectMap["location"] = vVar.Location + } + if vVar.VaultProperties != nil { + objectMap["properties"] = vVar.VaultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Vault struct. +func (vVar *Vault) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vVar.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vVar.Type = &typeVar + } + case "properties": + if v != nil { + var vaultProperties VaultProperties + err = json.Unmarshal(*v, &vaultProperties) + if err != nil { + return err + } + vVar.VaultProperties = &vaultProperties + } + } + } + + return nil +} + +// VaultList list of Vaults +type VaultList struct { + autorest.Response `json:"-"` + // Value - A list of vaults + Value *[]Vault `json:"value,omitempty"` +} + +// VaultProperties vault properties +type VaultProperties struct { + // VaultName - Vault Name + VaultName *string `json:"vaultName,omitempty"` +} + +// Volume volume resource +type Volume struct { + autorest.Response `json:"-"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // VolumeProperties - Volume properties + *VolumeProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Volume. +func (vVar Volume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vVar.Location != nil { + objectMap["location"] = vVar.Location + } + if vVar.Tags != nil { + objectMap["tags"] = vVar.Tags + } + if vVar.VolumeProperties != nil { + objectMap["properties"] = vVar.VolumeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Volume struct. +func (vVar *Volume) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vVar.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vVar.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vVar.Tags = tags + } + case "properties": + if v != nil { + var volumeProperties VolumeProperties + err = json.Unmarshal(*v, &volumeProperties) + if err != nil { + return err + } + vVar.VolumeProperties = &volumeProperties + } + } + } + + return nil +} + +// VolumeBackupProperties volume Backup Properties +type VolumeBackupProperties struct { + // BackupPolicyID - Backup Policy Resource ID + BackupPolicyID *string `json:"backupPolicyId,omitempty"` + // PolicyEnforced - Policy Enforced + PolicyEnforced *bool `json:"policyEnforced,omitempty"` + // VaultID - Vault Resource ID + VaultID *string `json:"vaultId,omitempty"` + // BackupEnabled - Backup Enabled + BackupEnabled *bool `json:"backupEnabled,omitempty"` +} + +// VolumeBackups volume details using the backup policy +type VolumeBackups struct { + // VolumeName - Volume name + VolumeName *string `json:"volumeName,omitempty"` + // BackupsCount - Total count of backups for volume + BackupsCount *int32 `json:"backupsCount,omitempty"` + // PolicyEnabled - Policy enabled + PolicyEnabled *bool `json:"policyEnabled,omitempty"` +} + +// VolumeList list of volume resources +type VolumeList struct { + autorest.Response `json:"-"` + // Value - List of volumes + Value *[]Volume `json:"value,omitempty"` + // NextLink - URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// VolumeListIterator provides access to a complete listing of Volume values. +type VolumeListIterator struct { + i int + page VolumeListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VolumeListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VolumeListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VolumeListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VolumeListIterator) Response() VolumeList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VolumeListIterator) Value() Volume { + if !iter.page.NotDone() { + return Volume{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VolumeListIterator type. +func NewVolumeListIterator(page VolumeListPage) VolumeListIterator { + return VolumeListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vl VolumeList) IsEmpty() bool { + return vl.Value == nil || len(*vl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vl VolumeList) hasNextLink() bool { + return vl.NextLink != nil && len(*vl.NextLink) != 0 +} + +// volumeListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vl VolumeList) volumeListPreparer(ctx context.Context) (*http.Request, error) { + if !vl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vl.NextLink))) +} + +// VolumeListPage contains a page of Volume values. +type VolumeListPage struct { + fn func(context.Context, VolumeList) (VolumeList, error) + vl VolumeList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VolumeListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vl) + if err != nil { + return err + } + page.vl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *VolumeListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VolumeListPage) NotDone() bool { + return !page.vl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VolumeListPage) Response() VolumeList { + return page.vl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VolumeListPage) Values() []Volume { + if page.vl.IsEmpty() { + return nil + } + return *page.vl.Value +} + +// Creates a new instance of the VolumeListPage type. +func NewVolumeListPage(cur VolumeList, getNextPage func(context.Context, VolumeList) (VolumeList, error)) VolumeListPage { + return VolumeListPage{ + fn: getNextPage, + vl: cur, + } +} + +// VolumePatch volume patch resource +type VolumePatch struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // VolumePatchProperties - Patchable volume properties + *VolumePatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VolumePatch. +func (vp VolumePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vp.Location != nil { + objectMap["location"] = vp.Location + } + if vp.Tags != nil { + objectMap["tags"] = vp.Tags + } + if vp.VolumePatchProperties != nil { + objectMap["properties"] = vp.VolumePatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VolumePatch struct. +func (vp *VolumePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vp.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vp.Tags = tags + } + case "properties": + if v != nil { + var volumePatchProperties VolumePatchProperties + err = json.Unmarshal(*v, &volumePatchProperties) + if err != nil { + return err + } + vp.VolumePatchProperties = &volumePatchProperties + } + } + } + + return nil +} + +// VolumePatchProperties patchable volume properties +type VolumePatchProperties struct { + // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' + ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` + // UsageThreshold - Maximum storage quota allowed for a file system in bytes. This is a soft quota used for alerting only. Minimum size is 100 GiB. Upper limit is 100TiB. Specified in bytes. + UsageThreshold *int64 `json:"usageThreshold,omitempty"` + // ExportPolicy - Set of export policy rules + ExportPolicy *VolumePatchPropertiesExportPolicy `json:"exportPolicy,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` + // DataProtection - DataProtection type volumes include an object containing details of the replication + DataProtection *VolumePatchPropertiesDataProtection `json:"dataProtection,omitempty"` +} + +// VolumePatchPropertiesDataProtection dataProtection type volumes include an object containing details of +// the replication +type VolumePatchPropertiesDataProtection struct { + // Backup - Backup Properties + Backup *VolumeBackupProperties `json:"backup,omitempty"` +} + +// VolumePatchPropertiesExportPolicy set of export policy rules +type VolumePatchPropertiesExportPolicy struct { + // Rules - Export policy rule + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} + +// VolumeProperties volume properties +type VolumeProperties struct { + // FileSystemID - READ-ONLY; Unique FileSystem Identifier. + FileSystemID *string `json:"fileSystemId,omitempty"` + // CreationToken - A unique file path for the volume. Used when creating mount targets + CreationToken *string `json:"creationToken,omitempty"` + // ServiceLevel - The service level of the file system. Possible values include: 'Standard', 'Premium', 'Ultra' + ServiceLevel ServiceLevel `json:"serviceLevel,omitempty"` + // UsageThreshold - Maximum storage quota allowed for a file system in bytes. This is a soft quota used for alerting only. Minimum size is 100 GiB. Upper limit is 100TiB. Specified in bytes. + UsageThreshold *int64 `json:"usageThreshold,omitempty"` + // ExportPolicy - Set of export policy rules + ExportPolicy *VolumePropertiesExportPolicy `json:"exportPolicy,omitempty"` + // ProtocolTypes - Set of protocol types + ProtocolTypes *[]string `json:"protocolTypes,omitempty"` + // ProvisioningState - READ-ONLY; Azure lifecycle management + ProvisioningState *string `json:"provisioningState,omitempty"` + // SnapshotID - UUID v4 or resource identifier used to identify the Snapshot. + SnapshotID *string `json:"snapshotId,omitempty"` + // BackupID - UUID v4 or resource identifier used to identify the Backup. + BackupID *string `json:"backupId,omitempty"` + // BaremetalTenantID - READ-ONLY; Unique Baremetal Tenant Identifier. + BaremetalTenantID *string `json:"baremetalTenantId,omitempty"` + // SubnetID - The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes + SubnetID *string `json:"subnetId,omitempty"` + // MountTargets - List of mount targets + MountTargets *[]MountTargetProperties `json:"mountTargets,omitempty"` + // VolumeType - What type of volume is this + VolumeType *string `json:"volumeType,omitempty"` + // DataProtection - DataProtection type volumes include an object containing details of the replication + DataProtection *VolumePropertiesDataProtection `json:"dataProtection,omitempty"` + // IsRestoring - Restoring + IsRestoring *bool `json:"isRestoring,omitempty"` + // SnapshotDirectoryVisible - If enabled (true) the volume will contain a read-only .snapshot directory which provides access to each of the volume's snapshots (default to true). + SnapshotDirectoryVisible *bool `json:"snapshotDirectoryVisible,omitempty"` + // KerberosEnabled - Describe if a volume is KerberosEnabled. To be use with swagger version 2020-05-01 or later + KerberosEnabled *bool `json:"kerberosEnabled,omitempty"` + // SecurityStyle - The security style of volume. Possible values include: 'Ntfs', 'Unix' + SecurityStyle SecurityStyle `json:"securityStyle,omitempty"` + // SmbEncryption - Enables encryption for in-flight smb3 data. Only applicable for SMB/DualProtocol volume. To be used with swagger version 2020-08-01 or later + SmbEncryption *bool `json:"smbEncryption,omitempty"` + // SmbContinuouslyAvailable - Enables continuously available share property for smb volume. Only applicable for SMB volume + SmbContinuouslyAvailable *bool `json:"smbContinuouslyAvailable,omitempty"` + ThroughputMibps *float64 `json:"throughputMibps,omitempty"` +} + +// MarshalJSON is the custom marshaler for VolumeProperties. +func (vp VolumeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vp.CreationToken != nil { + objectMap["creationToken"] = vp.CreationToken + } + if vp.ServiceLevel != "" { + objectMap["serviceLevel"] = vp.ServiceLevel + } + if vp.UsageThreshold != nil { + objectMap["usageThreshold"] = vp.UsageThreshold + } + if vp.ExportPolicy != nil { + objectMap["exportPolicy"] = vp.ExportPolicy + } + if vp.ProtocolTypes != nil { + objectMap["protocolTypes"] = vp.ProtocolTypes + } + if vp.SnapshotID != nil { + objectMap["snapshotId"] = vp.SnapshotID + } + if vp.BackupID != nil { + objectMap["backupId"] = vp.BackupID + } + if vp.SubnetID != nil { + objectMap["subnetId"] = vp.SubnetID + } + if vp.MountTargets != nil { + objectMap["mountTargets"] = vp.MountTargets + } + if vp.VolumeType != nil { + objectMap["volumeType"] = vp.VolumeType + } + if vp.DataProtection != nil { + objectMap["dataProtection"] = vp.DataProtection + } + if vp.IsRestoring != nil { + objectMap["isRestoring"] = vp.IsRestoring + } + if vp.SnapshotDirectoryVisible != nil { + objectMap["snapshotDirectoryVisible"] = vp.SnapshotDirectoryVisible + } + if vp.KerberosEnabled != nil { + objectMap["kerberosEnabled"] = vp.KerberosEnabled + } + if vp.SecurityStyle != "" { + objectMap["securityStyle"] = vp.SecurityStyle + } + if vp.SmbEncryption != nil { + objectMap["smbEncryption"] = vp.SmbEncryption + } + if vp.SmbContinuouslyAvailable != nil { + objectMap["smbContinuouslyAvailable"] = vp.SmbContinuouslyAvailable + } + if vp.ThroughputMibps != nil { + objectMap["throughputMibps"] = vp.ThroughputMibps + } + return json.Marshal(objectMap) +} + +// VolumePropertiesDataProtection dataProtection type volumes include an object containing details of the +// replication +type VolumePropertiesDataProtection struct { + // Backup - Backup Properties + Backup *VolumeBackupProperties `json:"backup,omitempty"` + // Replication - Replication properties + Replication *ReplicationObject `json:"replication,omitempty"` + // Snapshot - Snapshot properties. + Snapshot *VolumeSnapshotProperties `json:"snapshot,omitempty"` +} + +// VolumePropertiesExportPolicy set of export policy rules +type VolumePropertiesExportPolicy struct { + // Rules - Export policy rule + Rules *[]ExportPolicyRule `json:"rules,omitempty"` +} + +// VolumeRevert revert a volume to the snapshot +type VolumeRevert struct { + // SnapshotID - Resource id of the snapshot + SnapshotID *string `json:"snapshotId,omitempty"` +} + +// VolumesAuthorizeReplicationFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VolumesAuthorizeReplicationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesBreakReplicationFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesBreakReplicationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (Volume, error) +} + +// VolumesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesDeleteReplicationFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VolumesDeleteReplicationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumeSnapshotProperties volume Snapshot Properties +type VolumeSnapshotProperties struct { + // SnapshotPolicyID - Snapshot Policy ResourceId + SnapshotPolicyID *string `json:"snapshotPolicyId,omitempty"` +} + +// VolumesPoolChangeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesPoolChangeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesReInitializeReplicationFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VolumesReInitializeReplicationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesResyncReplicationFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VolumesResyncReplicationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesRevertFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesRevertFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (autorest.Response, error) +} + +// VolumesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VolumesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VolumesClient) (Volume, error) +} + +// WeeklySchedule weekly Schedule properties, make a snapshot every week at a specific day or days +type WeeklySchedule struct { + // SnapshotsToKeep - Weekly snapshot count to keep + SnapshotsToKeep *int32 `json:"snapshotsToKeep,omitempty"` + // Day - Indicates which weekdays snapshot should be taken, accepts a comma separated list of week day names in english + Day *string `json:"day,omitempty"` + // Hour - Indicates which hour in UTC timezone a snapshot should be taken + Hour *int32 `json:"hour,omitempty"` + // Minute - Indicates which minute snapshot should be taken + Minute *int32 `json:"minute,omitempty"` + // UsedBytes - Resource size in bytes, current storage usage for the volume in bytes + UsedBytes *int64 `json:"usedBytes,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/operations.go index f38f39d36d66..a13d96316a7c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/operations.go @@ -77,7 +77,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/pools.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/pools.go similarity index 86% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/pools.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/pools.go index 103ed643244e..0d3e829cf035 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/pools.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/pools.go @@ -76,7 +76,11 @@ func (client PoolsClient) CreateOrUpdate(ctx context.Context, body CapacityPool, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.PoolsClient", "CreateOrUpdate", err.Error()) } @@ -104,7 +108,7 @@ func (client PoolsClient) CreateOrUpdatePreparer(ctx context.Context, body Capac "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -192,7 +196,11 @@ func (client PoolsClient) Delete(ctx context.Context, resourceGroupName string, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.PoolsClient", "Delete", err.Error()) } @@ -220,7 +228,7 @@ func (client PoolsClient) DeletePreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -292,7 +300,11 @@ func (client PoolsClient) Get(ctx context.Context, resourceGroupName string, acc {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.PoolsClient", "Get", err.Error()) } @@ -327,7 +339,7 @@ func (client PoolsClient) GetPreparer(ctx context.Context, resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -411,7 +423,7 @@ func (client PoolsClient) ListPreparer(ctx context.Context, resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -448,13 +460,13 @@ func (client PoolsClient) ListResponder(resp *http.Response) (result CapacityPoo // resourceGroupName - the name of the resource group. // accountName - the name of the NetApp account // poolName - the name of the capacity pool -func (client PoolsClient) Update(ctx context.Context, body CapacityPoolPatch, resourceGroupName string, accountName string, poolName string) (result CapacityPool, err error) { +func (client PoolsClient) Update(ctx context.Context, body CapacityPoolPatch, resourceGroupName string, accountName string, poolName string) (result PoolsUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/PoolsClient.Update") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -463,7 +475,11 @@ func (client PoolsClient) Update(ctx context.Context, body CapacityPoolPatch, re {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.PoolsClient", "Update", err.Error()) } @@ -473,16 +489,9 @@ func (client PoolsClient) Update(ctx context.Context, body CapacityPoolPatch, re return } - resp, err := client.UpdateSender(req) + result, err = client.UpdateSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "netapp.PoolsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.PoolsClient", "Update", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.PoolsClient", "Update", nil, "Failure sending request") return } @@ -498,7 +507,7 @@ func (client PoolsClient) UpdatePreparer(ctx context.Context, body CapacityPoolP "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -518,8 +527,40 @@ func (client PoolsClient) UpdatePreparer(ctx context.Context, body CapacityPoolP // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client PoolsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client PoolsClient) UpdateSender(req *http.Request) (future PoolsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client PoolsClient) (cp CapacityPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.PoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.PoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + cp.Response.Response, err = future.GetResult(sender) + if cp.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.PoolsUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && cp.Response.Response.StatusCode != http.StatusNoContent { + cp, err = client.UpdateResponder(cp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.PoolsUpdateFuture", "Result", cp.Response.Response, "Failure responding to request") + } + } + return + } + return } // UpdateResponder handles the response to the Update request. The method always diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/resource.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/resource.go similarity index 69% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/resource.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/resource.go index 2a70d1b57168..adaac8588708 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/resource.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/resource.go @@ -46,7 +46,7 @@ func NewResourceClientWithBaseURI(baseURI string, subscriptionID string) Resourc // Parameters: // body - file path availability request. // location - the location -func (client ResourceClient) CheckFilePathAvailability(ctx context.Context, body ResourceNameAvailabilityRequest, location string) (result ResourceNameAvailability, err error) { +func (client ResourceClient) CheckFilePathAvailability(ctx context.Context, body ResourceNameAvailabilityRequest, location string) (result CheckAvailabilityResponse, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ResourceClient.CheckFilePathAvailability") defer func() { @@ -93,7 +93,7 @@ func (client ResourceClient) CheckFilePathAvailabilityPreparer(ctx context.Conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -116,7 +116,7 @@ func (client ResourceClient) CheckFilePathAvailabilitySender(req *http.Request) // CheckFilePathAvailabilityResponder handles the response to the CheckFilePathAvailability request. The method always // closes the http.Response Body. -func (client ResourceClient) CheckFilePathAvailabilityResponder(resp *http.Response) (result ResourceNameAvailability, err error) { +func (client ResourceClient) CheckFilePathAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResponse, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), @@ -130,7 +130,7 @@ func (client ResourceClient) CheckFilePathAvailabilityResponder(resp *http.Respo // Parameters: // body - name availability request. // location - the location -func (client ResourceClient) CheckNameAvailability(ctx context.Context, body ResourceNameAvailabilityRequest, location string) (result ResourceNameAvailability, err error) { +func (client ResourceClient) CheckNameAvailability(ctx context.Context, body ResourceNameAvailabilityRequest, location string) (result CheckAvailabilityResponse, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ResourceClient.CheckNameAvailability") defer func() { @@ -177,7 +177,7 @@ func (client ResourceClient) CheckNameAvailabilityPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -200,7 +200,91 @@ func (client ResourceClient) CheckNameAvailabilitySender(req *http.Request) (*ht // CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always // closes the http.Response Body. -func (client ResourceClient) CheckNameAvailabilityResponder(resp *http.Response) (result ResourceNameAvailability, err error) { +func (client ResourceClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckQuotaAvailability check if a quota is available. +// Parameters: +// body - quota availability request. +// location - the location +func (client ResourceClient) CheckQuotaAvailability(ctx context.Context, body QuotaAvailabilityRequest, location string) (result CheckAvailabilityResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceClient.CheckQuotaAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.ResourceGroup", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.ResourceClient", "CheckQuotaAvailability", err.Error()) + } + + req, err := client.CheckQuotaAvailabilityPreparer(ctx, body, location) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.ResourceClient", "CheckQuotaAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckQuotaAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.ResourceClient", "CheckQuotaAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckQuotaAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.ResourceClient", "CheckQuotaAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckQuotaAvailabilityPreparer prepares the CheckQuotaAvailability request. +func (client ResourceClient) CheckQuotaAvailabilityPreparer(ctx context.Context, body QuotaAvailabilityRequest, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkQuotaAvailability", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckQuotaAvailabilitySender sends the CheckQuotaAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceClient) CheckQuotaAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckQuotaAvailabilityResponder handles the response to the CheckQuotaAvailability request. The method always +// closes the http.Response Body. +func (client ResourceClient) CheckQuotaAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResponse, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshotpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshotpolicies.go new file mode 100644 index 000000000000..bbd9fc2f0a30 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshotpolicies.go @@ -0,0 +1,587 @@ +package netapp + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SnapshotPoliciesClient is the microsoft NetApp Azure Resource Provider specification +type SnapshotPoliciesClient struct { + BaseClient +} + +// NewSnapshotPoliciesClient creates an instance of the SnapshotPoliciesClient client. +func NewSnapshotPoliciesClient(subscriptionID string) SnapshotPoliciesClient { + return NewSnapshotPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSnapshotPoliciesClientWithBaseURI creates an instance of the SnapshotPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSnapshotPoliciesClientWithBaseURI(baseURI string, subscriptionID string) SnapshotPoliciesClient { + return SnapshotPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a snapshot policy +// Parameters: +// body - snapshot policy object supplied in the body of the operation. +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// snapshotPolicyName - the name of the snapshot policy target +func (client SnapshotPoliciesClient) Create(ctx context.Context, body SnapshotPolicy, resourceGroupName string, accountName string, snapshotPolicyName string) (result SnapshotPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.SnapshotPolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, body, resourceGroupName, accountName, snapshotPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SnapshotPoliciesClient) CreatePreparer(ctx context.Context, body SnapshotPolicy, resourceGroupName string, accountName string, snapshotPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "snapshotPolicyName": autorest.Encode("path", snapshotPolicyName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) CreateResponder(resp *http.Response) (result SnapshotPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete snapshot policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// snapshotPolicyName - the name of the snapshot policy target +func (client SnapshotPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (result SnapshotPoliciesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, snapshotPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SnapshotPoliciesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "snapshotPolicyName": autorest.Encode("path", snapshotPolicyName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) DeleteSender(req *http.Request) (future SnapshotPoliciesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SnapshotPoliciesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.SnapshotPoliciesDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a snapshot Policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// snapshotPolicyName - the name of the snapshot policy target +func (client SnapshotPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (result SnapshotPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, snapshotPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SnapshotPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "snapshotPolicyName": autorest.Encode("path", snapshotPolicyName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) GetResponder(resp *http.Response) (result SnapshotPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list snapshot policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +func (client SnapshotPoliciesClient) List(ctx context.Context, resourceGroupName string, accountName string) (result SnapshotPoliciesList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client SnapshotPoliciesClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) ListResponder(resp *http.Response) (result SnapshotPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListVolumes get volumes associated with snapshot policy +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// snapshotPolicyName - the name of the snapshot policy target +func (client SnapshotPoliciesClient) ListVolumes(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (result SnapshotPolicyVolumeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.ListVolumes") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "ListVolumes", err.Error()) + } + + req, err := client.ListVolumesPreparer(ctx, resourceGroupName, accountName, snapshotPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "ListVolumes", nil, "Failure preparing request") + return + } + + resp, err := client.ListVolumesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "ListVolumes", resp, "Failure sending request") + return + } + + result, err = client.ListVolumesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "ListVolumes", resp, "Failure responding to request") + return + } + + return +} + +// ListVolumesPreparer prepares the ListVolumes request. +func (client SnapshotPoliciesClient) ListVolumesPreparer(ctx context.Context, resourceGroupName string, accountName string, snapshotPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "snapshotPolicyName": autorest.Encode("path", snapshotPolicyName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}/listVolumes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListVolumesSender sends the ListVolumes request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) ListVolumesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListVolumesResponder handles the response to the ListVolumes request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) ListVolumesResponder(resp *http.Response) (result SnapshotPolicyVolumeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update patch a snapshot policy +// Parameters: +// body - snapshot policy object supplied in the body of the operation. +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// snapshotPolicyName - the name of the snapshot policy target +func (client SnapshotPoliciesClient) Update(ctx context.Context, body SnapshotPolicyPatch, resourceGroupName string, accountName string, snapshotPolicyName string) (result SnapshotPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotPoliciesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.SnapshotPoliciesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, body, resourceGroupName, accountName, snapshotPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotPoliciesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SnapshotPoliciesClient) UpdatePreparer(ctx context.Context, body SnapshotPolicyPatch, resourceGroupName string, accountName string, snapshotPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "snapshotPolicyName": autorest.Encode("path", snapshotPolicyName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SnapshotPoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SnapshotPoliciesClient) UpdateResponder(resp *http.Response) (result SnapshotPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/snapshots.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshots.go similarity index 79% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/snapshots.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshots.go index 08577b48c33f..1e79b5d9d7e4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/snapshots.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/snapshots.go @@ -70,16 +70,19 @@ func (client SnapshotsClient) Create(ctx context.Context, body Snapshot, resourc {Target: "body.SnapshotProperties.SnapshotID", Name: validation.MinLength, Rule: 36, Chain: nil}, {Target: "body.SnapshotProperties.SnapshotID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil}, }}, - {Target: "body.SnapshotProperties.FileSystemID", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "body.SnapshotProperties.FileSystemID", Name: validation.MaxLength, Rule: 36, Chain: nil}, - {Target: "body.SnapshotProperties.FileSystemID", Name: validation.MinLength, Rule: 36, Chain: nil}, - {Target: "body.SnapshotProperties.FileSystemID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil}, - }}, }}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.SnapshotsClient", "Create", err.Error()) } @@ -109,7 +112,7 @@ func (client SnapshotsClient) CreatePreparer(ctx context.Context, body Snapshot, "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -199,7 +202,15 @@ func (client SnapshotsClient) Delete(ctx context.Context, resourceGroupName stri {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.SnapshotsClient", "Delete", err.Error()) } @@ -229,7 +240,7 @@ func (client SnapshotsClient) DeletePreparer(ctx context.Context, resourceGroupN "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -303,7 +314,15 @@ func (client SnapshotsClient) Get(ctx context.Context, resourceGroupName string, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.SnapshotsClient", "Get", err.Error()) } @@ -340,7 +359,7 @@ func (client SnapshotsClient) GetPreparer(ctx context.Context, resourceGroupName "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -392,7 +411,15 @@ func (client SnapshotsClient) List(ctx context.Context, resourceGroupName string {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.SnapshotsClient", "List", err.Error()) } @@ -428,7 +455,7 @@ func (client SnapshotsClient) ListPreparer(ctx context.Context, resourceGroupNam "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -467,13 +494,13 @@ func (client SnapshotsClient) ListResponder(resp *http.Response) (result Snapsho // poolName - the name of the capacity pool // volumeName - the name of the volume // snapshotName - the name of the mount target -func (client SnapshotsClient) Update(ctx context.Context, body SnapshotPatch, resourceGroupName string, accountName string, poolName string, volumeName string, snapshotName string) (result Snapshot, err error) { +func (client SnapshotsClient) Update(ctx context.Context, body interface{}, resourceGroupName string, accountName string, poolName string, volumeName string, snapshotName string) (result SnapshotsUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Update") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -482,7 +509,15 @@ func (client SnapshotsClient) Update(ctx context.Context, body SnapshotPatch, re {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.SnapshotsClient", "Update", err.Error()) } @@ -492,16 +527,9 @@ func (client SnapshotsClient) Update(ctx context.Context, body SnapshotPatch, re return } - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "netapp.SnapshotsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) + result, err = client.UpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "netapp.SnapshotsClient", "Update", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.SnapshotsClient", "Update", nil, "Failure sending request") return } @@ -509,7 +537,7 @@ func (client SnapshotsClient) Update(ctx context.Context, body SnapshotPatch, re } // UpdatePreparer prepares the Update request. -func (client SnapshotsClient) UpdatePreparer(ctx context.Context, body SnapshotPatch, resourceGroupName string, accountName string, poolName string, volumeName string, snapshotName string) (*http.Request, error) { +func (client SnapshotsClient) UpdatePreparer(ctx context.Context, body interface{}, resourceGroupName string, accountName string, poolName string, volumeName string, snapshotName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "poolName": autorest.Encode("path", poolName), @@ -519,7 +547,7 @@ func (client SnapshotsClient) UpdatePreparer(ctx context.Context, body SnapshotP "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -536,8 +564,40 @@ func (client SnapshotsClient) UpdatePreparer(ctx context.Context, body SnapshotP // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client SnapshotsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client SnapshotsClient) UpdateSender(req *http.Request) (future SnapshotsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client SnapshotsClient) (s Snapshot, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.SnapshotsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + s.Response.Response, err = future.GetResult(sender) + if s.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotsUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.SnapshotsUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return + } + return } // UpdateResponder handles the response to the Update request. The method always diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/mounttargets.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/vaults.go similarity index 59% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/mounttargets.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/vaults.go index f9da6653491e..0bc9873f8719 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/mounttargets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/vaults.go @@ -26,31 +26,29 @@ import ( "net/http" ) -// MountTargetsClient is the microsoft NetApp Azure Resource Provider specification -type MountTargetsClient struct { +// VaultsClient is the microsoft NetApp Azure Resource Provider specification +type VaultsClient struct { BaseClient } -// NewMountTargetsClient creates an instance of the MountTargetsClient client. -func NewMountTargetsClient(subscriptionID string) MountTargetsClient { - return NewMountTargetsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewVaultsClient creates an instance of the VaultsClient client. +func NewVaultsClient(subscriptionID string) VaultsClient { + return NewVaultsClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewMountTargetsClientWithBaseURI creates an instance of the MountTargetsClient client using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewMountTargetsClientWithBaseURI(baseURI string, subscriptionID string) MountTargetsClient { - return MountTargetsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewVaultsClientWithBaseURI creates an instance of the VaultsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVaultsClientWithBaseURI(baseURI string, subscriptionID string) VaultsClient { + return VaultsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// List list all mount targets associated with the volume +// List list vaults for a Netapp Account // Parameters: // resourceGroupName - the name of the resource group. // accountName - the name of the NetApp account -// poolName - the name of the capacity pool -// volumeName - the name of the volume -func (client MountTargetsClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result MountTargetList, err error) { +func (client VaultsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result VaultList, err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MountTargetsClient.List") + ctx = tracing.StartSpan(ctx, fqdn+"/VaultsClient.List") defer func() { sc := -1 if result.Response.Response != nil { @@ -64,25 +62,25 @@ func (client MountTargetsClient) List(ctx context.Context, resourceGroupName str Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("netapp.MountTargetsClient", "List", err.Error()) + return result, validation.NewError("netapp.VaultsClient", "List", err.Error()) } - req, err := client.ListPreparer(ctx, resourceGroupName, accountName, poolName, volumeName) + req, err := client.ListPreparer(ctx, resourceGroupName, accountName) if err != nil { - err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "netapp.VaultsClient", "List", nil, "Failure preparing request") return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "netapp.VaultsClient", "List", resp, "Failure sending request") return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VaultsClient", "List", resp, "Failure responding to request") return } @@ -90,16 +88,14 @@ func (client MountTargetsClient) List(ctx context.Context, resourceGroupName str } // ListPreparer prepares the List request. -func (client MountTargetsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) { +func (client VaultsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), - "poolName": autorest.Encode("path", poolName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -107,20 +103,20 @@ func (client MountTargetsClient) ListPreparer(ctx context.Context, resourceGroup preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/mountTargets", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/vaults", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client MountTargetsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client VaultsClient) ListSender(req *http.Request) (*http.Response, error) { return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client MountTargetsClient) ListResponder(resp *http.Response) (result MountTargetList, err error) { +func (client VaultsClient) ListResponder(resp *http.Response) (result VaultList, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/version.go index cb462fa061d5..bf1f71594c55 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " netapp/2019-10-01" + return "Azure-SDK-For-Go/" + Version() + " netapp/2020-09-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/volumes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/volumes.go similarity index 56% rename from vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/volumes.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/volumes.go index a61d9d0521e0..88e308de53ab 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp/volumes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp/volumes.go @@ -49,13 +49,13 @@ func NewVolumesClientWithBaseURI(baseURI string, subscriptionID string) VolumesC // poolName - the name of the capacity pool // volumeName - the name of the volume // body - authorize request object supplied in the body of the operation. -func (client VolumesClient) AuthorizeReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body AuthorizeRequest) (result autorest.Response, err error) { +func (client VolumesClient) AuthorizeReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body AuthorizeRequest) (result VolumesAuthorizeReplicationFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.AuthorizeReplication") defer func() { sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -64,7 +64,15 @@ func (client VolumesClient) AuthorizeReplication(ctx context.Context, resourceGr {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "AuthorizeReplication", err.Error()) } @@ -74,16 +82,9 @@ func (client VolumesClient) AuthorizeReplication(ctx context.Context, resourceGr return } - resp, err := client.AuthorizeReplicationSender(req) + result, err = client.AuthorizeReplicationSender(req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "AuthorizeReplication", resp, "Failure sending request") - return - } - - result, err = client.AuthorizeReplicationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "AuthorizeReplication", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "AuthorizeReplication", nil, "Failure sending request") return } @@ -100,7 +101,7 @@ func (client VolumesClient) AuthorizeReplicationPreparer(ctx context.Context, re "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -117,8 +118,30 @@ func (client VolumesClient) AuthorizeReplicationPreparer(ctx context.Context, re // AuthorizeReplicationSender sends the AuthorizeReplication request. The method will close the // http.Response Body if it receives an error. -func (client VolumesClient) AuthorizeReplicationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client VolumesClient) AuthorizeReplicationSender(req *http.Request) (future VolumesAuthorizeReplicationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesAuthorizeReplicationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesAuthorizeReplicationFuture") + return + } + ar.Response = future.Response() + return + } + return } // AuthorizeReplicationResponder handles the response to the AuthorizeReplication request. The method always @@ -138,13 +161,14 @@ func (client VolumesClient) AuthorizeReplicationResponder(resp *http.Response) ( // accountName - the name of the NetApp account // poolName - the name of the capacity pool // volumeName - the name of the volume -func (client VolumesClient) BreakReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result autorest.Response, err error) { +// body - optional body to force break the replication. +func (client VolumesClient) BreakReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body *BreakReplicationRequest) (result VolumesBreakReplicationFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.BreakReplication") defer func() { sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -153,26 +177,27 @@ func (client VolumesClient) BreakReplication(ctx context.Context, resourceGroupN {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "BreakReplication", err.Error()) } - req, err := client.BreakReplicationPreparer(ctx, resourceGroupName, accountName, poolName, volumeName) + req, err := client.BreakReplicationPreparer(ctx, resourceGroupName, accountName, poolName, volumeName, body) if err != nil { err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "BreakReplication", nil, "Failure preparing request") return } - resp, err := client.BreakReplicationSender(req) + result, err = client.BreakReplicationSender(req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "BreakReplication", resp, "Failure sending request") - return - } - - result, err = client.BreakReplicationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "BreakReplication", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "BreakReplication", nil, "Failure sending request") return } @@ -180,7 +205,7 @@ func (client VolumesClient) BreakReplication(ctx context.Context, resourceGroupN } // BreakReplicationPreparer prepares the BreakReplication request. -func (client VolumesClient) BreakReplicationPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) { +func (client VolumesClient) BreakReplicationPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body *BreakReplicationRequest) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "poolName": autorest.Encode("path", poolName), @@ -189,23 +214,50 @@ func (client VolumesClient) BreakReplicationPreparer(ctx context.Context, resour "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakReplication", pathParameters), autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // BreakReplicationSender sends the BreakReplication request. The method will close the // http.Response Body if it receives an error. -func (client VolumesClient) BreakReplicationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client VolumesClient) BreakReplicationSender(req *http.Request) (future VolumesBreakReplicationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesBreakReplicationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesBreakReplicationFuture") + return + } + ar.Response = future.Response() + return + } + return } // BreakReplicationResponder handles the response to the BreakReplication request. The method always @@ -246,7 +298,11 @@ func (client VolumesClient) CreateOrUpdate(ctx context.Context, body Volume, res {Target: "body.VolumeProperties.FileSystemID", Name: validation.MinLength, Rule: 36, Chain: nil}, {Target: "body.VolumeProperties.FileSystemID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil}, }}, - {Target: "body.VolumeProperties.CreationToken", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.VolumeProperties.CreationToken", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "body.VolumeProperties.CreationToken", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "body.VolumeProperties.CreationToken", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "body.VolumeProperties.CreationToken", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-]{0,79}$`, Chain: nil}, + }}, {Target: "body.VolumeProperties.UsageThreshold", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "body.VolumeProperties.UsageThreshold", Name: validation.InclusiveMaximum, Rule: int64(109951162777600), Chain: nil}, {Target: "body.VolumeProperties.UsageThreshold", Name: validation.InclusiveMinimum, Rule: int64(107374182400), Chain: nil}, @@ -256,21 +312,34 @@ func (client VolumesClient) CreateOrUpdate(ctx context.Context, body Volume, res {Target: "body.VolumeProperties.SnapshotID", Name: validation.MinLength, Rule: 36, Chain: nil}, {Target: "body.VolumeProperties.SnapshotID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\?([^\/]*[\/])*)([^\/]+)$`, Chain: nil}, }}, - {Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.MaxLength, Rule: 36, Chain: nil}, - {Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.MinLength, Rule: 36, Chain: nil}, - {Target: "body.VolumeProperties.BaremetalTenantID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$`, Chain: nil}, + {Target: "body.VolumeProperties.BackupID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.VolumeProperties.BackupID", Name: validation.MaxLength, Rule: 36, Chain: nil}, + {Target: "body.VolumeProperties.BackupID", Name: validation.MinLength, Rule: 36, Chain: nil}, + {Target: "body.VolumeProperties.BackupID", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\?([^\/]*[\/])*)([^\/]+)$`, Chain: nil}, }}, {Target: "body.VolumeProperties.SubnetID", Name: validation.Null, Rule: true, Chain: nil}, {Target: "body.VolumeProperties.DataProtection", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "body.VolumeProperties.DataProtection.Replication", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "body.VolumeProperties.DataProtection.Replication.RemoteVolumeResourceID", Name: validation.Null, Rule: true, Chain: nil}}}, }}, + {Target: "body.VolumeProperties.ThroughputMibps", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.VolumeProperties.ThroughputMibps", Name: validation.InclusiveMaximum, Rule: float64(4500), Chain: nil}, + {Target: "body.VolumeProperties.ThroughputMibps", Name: validation.InclusiveMinimum, Rule: float64(1), Chain: nil}, + {Target: "body.VolumeProperties.ThroughputMibps", Name: validation.MultipleOf, Rule: 0.001, Chain: nil}, + }}, }}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "CreateOrUpdate", err.Error()) } @@ -299,7 +368,7 @@ func (client VolumesClient) CreateOrUpdatePreparer(ctx context.Context, body Vol "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -388,7 +457,15 @@ func (client VolumesClient) Delete(ctx context.Context, resourceGroupName string {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "Delete", err.Error()) } @@ -417,7 +494,7 @@ func (client VolumesClient) DeletePreparer(ctx context.Context, resourceGroupNam "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -476,13 +553,13 @@ func (client VolumesClient) DeleteResponder(resp *http.Response) (result autores // accountName - the name of the NetApp account // poolName - the name of the capacity pool // volumeName - the name of the volume -func (client VolumesClient) DeleteReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result autorest.Response, err error) { +func (client VolumesClient) DeleteReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesDeleteReplicationFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.DeleteReplication") defer func() { sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -491,7 +568,15 @@ func (client VolumesClient) DeleteReplication(ctx context.Context, resourceGroup {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "DeleteReplication", err.Error()) } @@ -501,16 +586,9 @@ func (client VolumesClient) DeleteReplication(ctx context.Context, resourceGroup return } - resp, err := client.DeleteReplicationSender(req) + result, err = client.DeleteReplicationSender(req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "DeleteReplication", resp, "Failure sending request") - return - } - - result, err = client.DeleteReplicationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "DeleteReplication", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "DeleteReplication", nil, "Failure sending request") return } @@ -527,7 +605,7 @@ func (client VolumesClient) DeleteReplicationPreparer(ctx context.Context, resou "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -542,8 +620,30 @@ func (client VolumesClient) DeleteReplicationPreparer(ctx context.Context, resou // DeleteReplicationSender sends the DeleteReplication request. The method will close the // http.Response Body if it receives an error. -func (client VolumesClient) DeleteReplicationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client VolumesClient) DeleteReplicationSender(req *http.Request) (future VolumesDeleteReplicationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesDeleteReplicationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesDeleteReplicationFuture") + return + } + ar.Response = future.Response() + return + } + return } // DeleteReplicationResponder handles the response to the DeleteReplication request. The method always @@ -578,7 +678,15 @@ func (client VolumesClient) Get(ctx context.Context, resourceGroupName string, a {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "Get", err.Error()) } @@ -614,7 +722,7 @@ func (client VolumesClient) GetPreparer(ctx context.Context, resourceGroupName s "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -650,13 +758,13 @@ func (client VolumesClient) GetResponder(resp *http.Response) (result Volume, er // resourceGroupName - the name of the resource group. // accountName - the name of the NetApp account // poolName - the name of the capacity pool -func (client VolumesClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string) (result VolumeList, err error) { +func (client VolumesClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string) (result VolumeListPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.List") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.vl.Response.Response != nil { + sc = result.vl.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -665,10 +773,15 @@ func (client VolumesClient) List(ctx context.Context, resourceGroupName string, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "List", err.Error()) } + result.fn = client.listNextResults req, err := client.ListPreparer(ctx, resourceGroupName, accountName, poolName) if err != nil { err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", nil, "Failure preparing request") @@ -677,16 +790,20 @@ func (client VolumesClient) List(ctx context.Context, resourceGroupName string, resp, err := client.ListSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.vl.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", resp, "Failure sending request") return } - result, err = client.ListResponder(resp) + result.vl, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "List", resp, "Failure responding to request") return } + if result.vl.hasNextLink() && result.vl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } return } @@ -700,7 +817,7 @@ func (client VolumesClient) ListPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -731,6 +848,268 @@ func (client VolumesClient) ListResponder(resp *http.Response) (result VolumeLis return } +// listNextResults retrieves the next set of results, if any. +func (client VolumesClient) listNextResults(ctx context.Context, lastResults VolumeList) (result VolumeList, err error) { + req, err := lastResults.volumeListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "netapp.VolumesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "netapp.VolumesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client VolumesClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, poolName string) (result VolumeListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, accountName, poolName) + return +} + +// PoolChange moves volume to another pool +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// body - move volume to the pool supplied in the body of the operation. +func (client VolumesClient) PoolChange(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body PoolChangeRequest) (result VolumesPoolChangeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.PoolChange") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.NewPoolResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.VolumesClient", "PoolChange", err.Error()) + } + + req, err := client.PoolChangePreparer(ctx, resourceGroupName, accountName, poolName, volumeName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "PoolChange", nil, "Failure preparing request") + return + } + + result, err = client.PoolChangeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "PoolChange", nil, "Failure sending request") + return + } + + return +} + +// PoolChangePreparer prepares the PoolChange request. +func (client VolumesClient) PoolChangePreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body PoolChangeRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/poolChange", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PoolChangeSender sends the PoolChange request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) PoolChangeSender(req *http.Request) (future VolumesPoolChangeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesPoolChangeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesPoolChangeFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// PoolChangeResponder handles the response to the PoolChange request. The method always +// closes the http.Response Body. +func (client VolumesClient) PoolChangeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ReInitializeReplication re-Initializes the replication connection on the destination volume +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +func (client VolumesClient) ReInitializeReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesReInitializeReplicationFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ReInitializeReplication") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.VolumesClient", "ReInitializeReplication", err.Error()) + } + + req, err := client.ReInitializeReplicationPreparer(ctx, resourceGroupName, accountName, poolName, volumeName) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "ReInitializeReplication", nil, "Failure preparing request") + return + } + + result, err = client.ReInitializeReplicationSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "ReInitializeReplication", nil, "Failure sending request") + return + } + + return +} + +// ReInitializeReplicationPreparer prepares the ReInitializeReplication request. +func (client VolumesClient) ReInitializeReplicationPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reinitializeReplication", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReInitializeReplicationSender sends the ReInitializeReplication request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) ReInitializeReplicationSender(req *http.Request) (future VolumesReInitializeReplicationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesReInitializeReplicationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesReInitializeReplicationFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// ReInitializeReplicationResponder handles the response to the ReInitializeReplication request. The method always +// closes the http.Response Body. +func (client VolumesClient) ReInitializeReplicationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + // ReplicationStatusMethod get the status of the replication // Parameters: // resourceGroupName - the name of the resource group. @@ -752,7 +1131,15 @@ func (client VolumesClient) ReplicationStatusMethod(ctx context.Context, resourc {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "ReplicationStatusMethod", err.Error()) } @@ -788,7 +1175,7 @@ func (client VolumesClient) ReplicationStatusMethodPreparer(ctx context.Context, "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -820,19 +1207,19 @@ func (client VolumesClient) ReplicationStatusMethodResponder(resp *http.Response } // ResyncReplication resync the connection on the destination volume. If the operation is ran on the source volume it -// will reverse-resync the connection and sync from source to destination. +// will reverse-resync the connection and sync from destination to source. // Parameters: // resourceGroupName - the name of the resource group. // accountName - the name of the NetApp account // poolName - the name of the capacity pool // volumeName - the name of the volume -func (client VolumesClient) ResyncReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result autorest.Response, err error) { +func (client VolumesClient) ResyncReplication(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesResyncReplicationFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.ResyncReplication") defer func() { sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -841,7 +1228,15 @@ func (client VolumesClient) ResyncReplication(ctx context.Context, resourceGroup {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "ResyncReplication", err.Error()) } @@ -851,16 +1246,9 @@ func (client VolumesClient) ResyncReplication(ctx context.Context, resourceGroup return } - resp, err := client.ResyncReplicationSender(req) + result, err = client.ResyncReplicationSender(req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "ResyncReplication", resp, "Failure sending request") - return - } - - result, err = client.ResyncReplicationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "ResyncReplication", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "ResyncReplication", nil, "Failure sending request") return } @@ -877,7 +1265,7 @@ func (client VolumesClient) ResyncReplicationPreparer(ctx context.Context, resou "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -892,8 +1280,30 @@ func (client VolumesClient) ResyncReplicationPreparer(ctx context.Context, resou // ResyncReplicationSender sends the ResyncReplication request. The method will close the // http.Response Body if it receives an error. -func (client VolumesClient) ResyncReplicationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client VolumesClient) ResyncReplicationSender(req *http.Request) (future VolumesResyncReplicationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesResyncReplicationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesResyncReplicationFuture") + return + } + ar.Response = future.Response() + return + } + return } // ResyncReplicationResponder handles the response to the ResyncReplication request. The method always @@ -907,6 +1317,119 @@ func (client VolumesClient) ResyncReplicationResponder(resp *http.Response) (res return } +// Revert revert a volume to the snapshot specified in the body +// Parameters: +// resourceGroupName - the name of the resource group. +// accountName - the name of the NetApp account +// poolName - the name of the capacity pool +// volumeName - the name of the volume +// body - object for snapshot to revert supplied in the body of the operation. +func (client VolumesClient) Revert(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body VolumeRevert) (result VolumesRevertFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Revert") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("netapp.VolumesClient", "Revert", err.Error()) + } + + req, err := client.RevertPreparer(ctx, resourceGroupName, accountName, poolName, volumeName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Revert", nil, "Failure preparing request") + return + } + + result, err = client.RevertSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Revert", nil, "Failure sending request") + return + } + + return +} + +// RevertPreparer prepares the Revert request. +func (client VolumesClient) RevertPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string, body VolumeRevert) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "poolName": autorest.Encode("path", poolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeName": autorest.Encode("path", volumeName), + } + + const APIVersion = "2020-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revert", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevertSender sends the Revert request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) RevertSender(req *http.Request) (future VolumesRevertFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesRevertFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesRevertFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// RevertResponder handles the response to the Revert request. The method always +// closes the http.Response Body. +func (client VolumesClient) RevertResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + // Update patch the specified volume // Parameters: // body - volume object supplied in the body of the operation. @@ -914,13 +1437,13 @@ func (client VolumesClient) ResyncReplicationResponder(resp *http.Response) (res // accountName - the name of the NetApp account // poolName - the name of the capacity pool // volumeName - the name of the volume -func (client VolumesClient) Update(ctx context.Context, body VolumePatch, resourceGroupName string, accountName string, poolName string, volumeName string) (result Volume, err error) { +func (client VolumesClient) Update(ctx context.Context, body VolumePatch, resourceGroupName string, accountName string, poolName string, volumeName string) (result VolumesUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/VolumesClient.Update") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -929,7 +1452,15 @@ func (client VolumesClient) Update(ctx context.Context, body VolumePatch, resour {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: poolName, + Constraints: []validation.Constraint{{Target: "poolName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "poolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "poolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}, + {TargetValue: volumeName, + Constraints: []validation.Constraint{{Target: "volumeName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "volumeName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "volumeName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$`, Chain: nil}}}}); err != nil { return result, validation.NewError("netapp.VolumesClient", "Update", err.Error()) } @@ -939,16 +1470,9 @@ func (client VolumesClient) Update(ctx context.Context, body VolumePatch, resour return } - resp, err := client.UpdateSender(req) + result, err = client.UpdateSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "netapp.VolumesClient", "Update", nil, "Failure sending request") return } @@ -965,7 +1489,7 @@ func (client VolumesClient) UpdatePreparer(ctx context.Context, body VolumePatch "volumeName": autorest.Encode("path", volumeName), } - const APIVersion = "2019-10-01" + const APIVersion = "2020-09-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -985,8 +1509,40 @@ func (client VolumesClient) UpdatePreparer(ctx context.Context, body VolumePatch // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client VolumesClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client VolumesClient) UpdateSender(req *http.Request) (future VolumesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client VolumesClient) (vVar Volume, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("netapp.VolumesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + vVar.Response.Response, err = future.GetResult(sender) + if vVar.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && vVar.Response.Response.StatusCode != http.StatusNoContent { + vVar, err = client.UpdateResponder(vVar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "netapp.VolumesUpdateFuture", "Result", vVar.Response.Response, "Failure responding to request") + } + } + return + } + return } // UpdateResponder handles the response to the Update request. The method always diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cbf737e8a90..de4ffabce43f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -56,7 +56,7 @@ github.com/Azure/azure-sdk-for-go/services/marketplaceordering/mgmt/2015-06-01/m github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2020-05-01/media github.com/Azure/azure-sdk-for-go/services/msi/mgmt/2018-11-30/msi github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2020-01-01/mysql -github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2019-10-01/netapp +github.com/Azure/azure-sdk-for-go/services/netapp/mgmt/2020-09-01/netapp github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-05-01/network github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2017-04-01/notificationhubs diff --git a/website/docs/r/netapp_snapshot.html.markdown b/website/docs/r/netapp_snapshot.html.markdown index a54e11bcc2d7..11eea30e6a45 100644 --- a/website/docs/r/netapp_snapshot.html.markdown +++ b/website/docs/r/netapp_snapshot.html.markdown @@ -94,8 +94,6 @@ The following arguments are supported: * `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -* `tags` - (Optional) A mapping of tags to assign to the resource. - --- ## Attributes Reference diff --git a/website/docs/r/netapp_volume.html.markdown b/website/docs/r/netapp_volume.html.markdown index 86c14443f259..692d63557172 100644 --- a/website/docs/r/netapp_volume.html.markdown +++ b/website/docs/r/netapp_volume.html.markdown @@ -71,6 +71,15 @@ resource "azurerm_netapp_volume" "example" { subnet_id = azurerm_subnet.example.id protocols = ["NFSv4.1"] storage_quota_in_gb = 100 + + # Following section is only required if deploying a data protection volume (secondary) + # to enable Cross-Region Replication feature + data_protection_replication { + endpoint_type = "dst" + remote_volume_location = azurerm_resource_group.example_primary.location + remote_volume_resource_id = azurerm_netapp_volume.example_primary.id + replication_frequency = "_10minutely" + } } ``` @@ -126,6 +135,24 @@ An `export_policy_rule` block supports the following: --- +An `data_protection_replication` is used when enabling the Cross-Region Replication (CRR) data protection option by deploying two Azure NetApp Files Volumes, one to be a primary volume and the other one will be the secondary, the secondary will have this block and will reference the primary volume, each volume must be in a supported [region pair](https://docs.microsoft.com/en-us/azure/azure-netapp-files/cross-region-replication-introduction#supported-region-pairs) and it supports the following: + +* `endpoint_type` - (Optional) The endpoint type, default value is `dst` for destination. + +* `remote_volume_location` - (Required) Primary volume's location. + +* `remote_volume_resource_id` - (Required) Primary volume's resource id. + +* `replication_frequency` - (Required) Replication frequency, supported values are '10minutes', 'hourly', 'daily', values are case sensitive. + +A full example of the `data_protection_replication` attribute can be found in [the `./examples/netapp/volume_crr` directory within the Github Repository](https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/netapp/volume_crr) + +-> **NOTE:** `data_protection_replication` Is currently in Preview on an opt-in basis. To use it, please refer to [Cross-region replication of Azure NetApp Files volumes](https://docs.microsoft.com/en-us/azure/azure-netapp-files/cross-region-replication-introduction). + +~> **NOTE:** `data_protection_replication` can be defined only once per secondary volume, adding a second instance of it is not supported. + +--- + ## Attributes Reference The following attributes are exported: