From 881259ee780f75380c6d262a5114b5effd52d243 Mon Sep 17 00:00:00 2001 From: yupwei68 Date: Wed, 5 Aug 2020 16:52:45 +0800 Subject: [PATCH 01/23] update --- azurerm/internal/clients/client.go | 3 + .../avs/avs_private_clouds_data_source.go | 61 + .../avs/avs_private_clouds_resource.go | 630 ++++++ .../internal/services/avs/client/client.go | 33 + .../services/avs/parse/avs_authorizations.go | 32 + .../avs/parse/avs_authorizations_test.go | 77 + .../services/avs/parse/avs_clusters.go | 33 + .../services/avs/parse/avs_clusters_test.go | 77 + .../avs/parse/avs_hcx_enterprise_sites.go | 33 + .../parse/avs_hcx_enterprise_sites_test.go | 77 + .../services/avs/parse/avs_private_clouds.go | 29 + .../avs/parse/avs_private_clouds_test.go | 72 + azurerm/internal/services/avs/registration.go | 37 + .../avs_private_clouds_data_source_test.go | 36 + .../tests/avs_private_clouds_resource_test.go | 363 ++++ .../docs/d/avs_authorizations.html.markdown | 47 + .../website/docs/d/avs_clusters.html.markdown | 47 + .../d/avs_hcx_enterprise_sites.html.markdown | 47 + .../docs/d/avs_private_clouds.html.markdown | 48 + .../docs/r/avs_authorizations.html.markdown | 78 + .../website/docs/r/avs_clusters.html.markdown | 93 + .../r/avs_hcx_enterprise_sites.html.markdown | 76 + .../docs/r/avs_private_clouds.html.markdown | 159 ++ .../avs/mgmt/2020-03-20/avs/authorizations.go | 432 ++++ .../mgmt/2020-03-20/avs/avsapi/interfaces.go | 89 + .../avs/mgmt/2020-03-20/avs/client.go | 52 + .../avs/mgmt/2020-03-20/avs/clusters.go | 526 +++++ .../mgmt/2020-03-20/avs/hcxenterprisesites.go | 433 ++++ .../avs/mgmt/2020-03-20/avs/locations.go | 201 ++ .../avs/mgmt/2020-03-20/avs/models.go | 1770 +++++++++++++++++ .../avs/mgmt/2020-03-20/avs/operations.go | 149 ++ .../avs/mgmt/2020-03-20/avs/privateclouds.go | 719 +++++++ .../avs/mgmt/2020-03-20/avs/version.go | 30 + 33 files changed, 6589 insertions(+) create mode 100644 azurerm/internal/services/avs/avs_private_clouds_data_source.go create mode 100644 azurerm/internal/services/avs/avs_private_clouds_resource.go create mode 100644 azurerm/internal/services/avs/client/client.go create mode 100644 azurerm/internal/services/avs/parse/avs_authorizations.go create mode 100644 azurerm/internal/services/avs/parse/avs_authorizations_test.go create mode 100644 azurerm/internal/services/avs/parse/avs_clusters.go create mode 100644 azurerm/internal/services/avs/parse/avs_clusters_test.go create mode 100644 azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go create mode 100644 azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go create mode 100644 azurerm/internal/services/avs/parse/avs_private_clouds.go create mode 100644 azurerm/internal/services/avs/parse/avs_private_clouds_test.go create mode 100644 azurerm/internal/services/avs/registration.go create mode 100644 azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go create mode 100644 azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go create mode 100644 azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown create mode 100644 azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 97e9f9678029..714449ba8780 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -14,6 +14,7 @@ import ( appPlatform "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appplatform/client" authorization "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/authorization/client" automation "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/automation/client" + avs "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/client" batch "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/batch/client" blueprints "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/blueprints/client" bot "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/bot/client" @@ -99,6 +100,7 @@ type Client struct { AppPlatform *appPlatform.Client Authorization *authorization.Client Automation *automation.Client + Avs *avs.Client Batch *batch.Client Blueprints *blueprints.Client Bot *bot.Client @@ -185,6 +187,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.AppPlatform = appPlatform.NewClient(o) client.Authorization = authorization.NewClient(o) client.Automation = automation.NewClient(o) + client.Avs = avs.NewClient(o) client.Batch = batch.NewClient(o) client.Blueprints = blueprints.NewClient(o) client.Bot = bot.NewClient(o) diff --git a/azurerm/internal/services/avs/avs_private_clouds_data_source.go b/azurerm/internal/services/avs/avs_private_clouds_data_source.go new file mode 100644 index 000000000000..f17087e87cf8 --- /dev/null +++ b/azurerm/internal/services/avs/avs_private_clouds_data_source.go @@ -0,0 +1,61 @@ +package avs + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "time" +) +func dataSourceAvsPrivateCloud() *schema.Resource { + return &schema.Resource{ + Read: dataSourceArmAvsPrivateCloudRead, + + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(5 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + + "location": azure.SchemaLocationForDataSource(), + + "tags": tags.SchemaDataSource(), + }, + } +} + +func dataSourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + resp, err :=client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Avs PrivateCloud %q does not exist", name) + } + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + if resp.ID == nil || *resp.ID== "" { + return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*resp.ID) + d.Set("name", name) + d.Set("resource_group_name", resourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + return tags.FlattenAndSet(d, resp.Tags) +} diff --git a/azurerm/internal/services/avs/avs_private_clouds_resource.go b/azurerm/internal/services/avs/avs_private_clouds_resource.go new file mode 100644 index 000000000000..a8fa54c1bf00 --- /dev/null +++ b/azurerm/internal/services/avs/avs_private_clouds_resource.go @@ -0,0 +1,630 @@ +package avs + +import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "log" + "time" +) +func resourceArmAvsPrivateCloud() *schema.Resource { + return &schema.Resource{ + Create: resourceArmAvsPrivateCloudCreate, + Read: resourceArmAvsPrivateCloudRead, + Update: resourceArmAvsPrivateCloudUpdate, + Delete: resourceArmAvsPrivateCloudDelete, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.AvsPrivateCloudID(id) + return err + }), + + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "sku": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + }, + }, + + "management_cluster": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_size": { + Type: schema.TypeInt, + Required: true, + }, + + "cluster_id": { + Type: schema.TypeInt, + Computed: true, + }, + + "hosts": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + + "network_block": { + Type: schema.TypeString, + Required: true, + }, + + "circuit": { + Type: schema.TypeList, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "express_route_id": { + Type: schema.TypeString, + Computed: true, + }, + + "express_route_private_peering_id": { + Type: schema.TypeString, + Computed: true, + }, + + "primary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + + "secondary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "identity_source": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + + "alias": { + Type: schema.TypeString, + Optional: true, + }, + + "base_group_dn": { + Type: schema.TypeString, + Optional: true, + }, + + "base_user_dn": { + Type: schema.TypeString, + Optional: true, + }, + + "domain": { + Type: schema.TypeString, + Optional: true, + }, + + "password": { + Type: schema.TypeString, + Optional: true, + }, + + "primary_server": { + Type: schema.TypeString, + Optional: true, + }, + + "secondary_server": { + Type: schema.TypeString, + Optional: true, + }, + + "ssl": { + Type: schema.TypeBool, + Optional: true, + }, + + "username": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + + "internet": { + Type: schema.TypeBool, + Optional: true, + }, + + "nsxt_password": { + Type: schema.TypeString, + Optional: true, + }, + + "vcenter_password": { + Type: schema.TypeString, + Optional: true, + }, + + "endpoint": { + Type: schema.TypeList, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "hcx_cloud_manager": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_manager": { + Type: schema.TypeString, + Computed: true, + }, + + "vcsa": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "management_network": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "provisioning_network": { + Type: schema.TypeString, + Computed: true, + }, + + "type": { + Type: schema.TypeString, + Computed: true, + }, + + "vcenter_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "vmotion_network": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tags.Schema(), + }, + } +} +func resourceArmAvsPrivateCloudCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + existing, err :=client.Get(ctx, resourceGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for present of existing Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + } + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_avs_private_cloud", *existing.ID) + } + + internet := avs.Disabled + if d.Get("internet").(bool) { + internet = avs.Enabled + } + + privateCloud := avs.PrivateCloud{ + Location: utils.String(location.Normalize(d.Get("location").(string))), + Sku: expandArmPrivateCloudSku(d.Get("sku").([]interface{})), + PrivateCloudProperties: &avs.PrivateCloudProperties{ + ManagementCluster: expandArmPrivateCloudManagementCluster(d.Get("management_cluster").([]interface{})), + NetworkBlock: utils.String(d.Get("network_block").(string)), + IdentitySources: expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()), + Internet: internet, + NsxtPassword: utils.String(d.Get("nsxt_password").(string)), + VcenterPassword: utils.String(d.Get("vcenter_password").(string)), + }, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + future, err :=client.CreateOrUpdate(ctx, resourceGroup, name, privateCloud) + if err != nil { + return fmt.Errorf("creating Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on creating future for Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + resp, err :=client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if resp.ID == nil || *resp.ID== "" { + return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*resp.ID) + return resourceArmAvsPrivateCloudRead(d, meta) +} + +func resourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + resp, err :=client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] avs %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil + } + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + if props := resp.PrivateCloudProperties; props != nil { + if err := d.Set("management_cluster", flattenArmPrivateCloudManagementCluster(props.ManagementCluster)); err != nil { + return fmt.Errorf("setting `management_cluster`: %+v", err) + } + d.Set("network_block", props.NetworkBlock) + if err := d.Set("circuit", flattenArmPrivateCloudCircuit(props.Circuit)); err != nil { + return fmt.Errorf("setting `circuit`: %+v", err) + } + if err := d.Set("identity_source", flattenArmPrivateCloudIdentitySourceArray(props.IdentitySources)); err != nil { + return fmt.Errorf("setting `identity_source`: %+v", err) + } + d.Set("internet", props.Internet==avs.Enabled) + d.Set("nsxt_password", props.NsxtPassword) + d.Set("vcenter_password", props.VcenterPassword) + if err := d.Set("endpoint", flattenArmPrivateCloudEndpoints(props.Endpoints)); err != nil { + return fmt.Errorf("setting `endpoint`: %+v", err) + } + d.Set("management_network", props.ManagementNetwork) + d.Set("nsxt_certificate_thumbprint", props.NsxtCertificateThumbprint) + d.Set("provisioning_network", props.ProvisioningNetwork) + d.Set("vcenter_certificate_thumbprint", props.VcenterCertificateThumbprint) + d.Set("vmotion_network", props.VmotionNetwork) + } + if err := d.Set("sku", flattenArmPrivateCloudSku(resp.Sku)); err != nil { + return fmt.Errorf("setting `sku`: %+v", err) + } + d.Set("type", resp.Type) + return tags.FlattenAndSet(d, resp.Tags) +} + +func resourceArmAvsPrivateCloudUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + privateCloudUpdate := avs.PrivateCloudUpdate{ + PrivateCloudUpdateProperties: &avs.PrivateCloudUpdateProperties{ + }, + } + if d.HasChange("management_cluster") { + privateCloudUpdate.PrivateCloudUpdateProperties.ManagementCluster = expandArmPrivateCloudManagementCluster(d.Get("management_cluster").([]interface{})) + } + if d.HasChange("internet") { + internet := avs.Disabled + if d.Get("internet").(bool) { + internet = avs.Enabled + } + privateCloudUpdate.PrivateCloudUpdateProperties.Internet = internet + } + if d.HasChange("identity_source") { + privateCloudUpdate.PrivateCloudUpdateProperties.IdentitySources = expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()) + } + if d.HasChange("tags") { + privateCloudUpdate.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) + } + + future, err :=client.Update(ctx, id.ResourceGroup, id.Name, privateCloudUpdate) + if err != nil { + return fmt.Errorf("updating Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on updating future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + return resourceArmAvsPrivateCloudRead(d, meta) +} + +func resourceArmAvsPrivateCloudDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + future, err :=client.Delete(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("deleting Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on deleting future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + return nil +} + +func expandArmPrivateCloudSku(input []interface{}) *avs.Sku { + if len(input) == 0 { + return nil + } + v := input[0].(map[string]interface{}) + return &avs.Sku{ + Name: utils.String(v["name"].(string)), + } +} + +func expandArmPrivateCloudManagementCluster(input []interface{}) *avs.ManagementCluster { + if len(input) == 0 { + return nil + } + v := input[0].(map[string]interface{}) + return &avs.ManagementCluster{ + ClusterSize: utils.Int32(int32(v["cluster_size"].(int))), + } +} + +func expandArmPrivateCloudIdentitySourceArray(input []interface{}) *[]avs.IdentitySource { + results := make([]avs.IdentitySource, 0) + for _, item := range input { + v := item.(map[string]interface{}) + sSL := avs.SslEnumDisabled + if v["ssl"].(bool) { + sSL = avs.SslEnumEnabled + } + result := avs.IdentitySource{ + Name: utils.String(v["name"].(string)), + Alias: utils.String(v["alias"].(string)), + Domain: utils.String(v["domain"].(string)), + BaseUserDN: utils.String(v["base_user_dn"].(string)), + BaseGroupDN: utils.String(v["base_group_dn"].(string)), + PrimaryServer: utils.String(v["primary_server"].(string)), + SecondaryServer: utils.String(v["secondary_server"].(string)), + Ssl: sSL, + Username: utils.String(v["username"].(string)), + Password: utils.String(v["password"].(string)), + } + results = append(results, result) + } + return &results +} + +func flattenArmPrivateCloudManagementCluster(input *avs.ManagementCluster) []interface{} { + if input == nil { + return make([]interface{}, 0) + } + + var clusterSize int32 + if input.ClusterSize != nil { + clusterSize = *input.ClusterSize + } + var clusterId int32 + if input.ClusterID != nil { + clusterId = *input.ClusterID + } + return []interface{}{ + map[string]interface{}{ + "cluster_size": clusterSize, + "cluster_id": clusterId, + "hosts": utils.FlattenStringSlice(input.Hosts), + }, + } +} + +func flattenArmPrivateCloudCircuit(input *avs.Circuit) []interface{} { + if input == nil { + return make([]interface{}, 0) + } + + var expressRouteId string + if input.ExpressRouteID != nil { + expressRouteId = *input.ExpressRouteID + } + var expressRoutePrivatePeeringId string + if input.ExpressRoutePrivatePeeringID != nil { + expressRoutePrivatePeeringId = *input.ExpressRoutePrivatePeeringID + } + var primarySubnet string + if input.PrimarySubnet != nil { + primarySubnet = *input.PrimarySubnet + } + var secondarySubnet string + if input.SecondarySubnet != nil { + secondarySubnet = *input.SecondarySubnet + } + return []interface{}{ + map[string]interface{}{ + "express_route_id": expressRouteId, + "express_route_private_peering_id": expressRoutePrivatePeeringId, + "primary_subnet": primarySubnet, + "secondary_subnet": secondarySubnet, + }, + } +} + +func flattenArmPrivateCloudIdentitySourceArray(input *[]avs.IdentitySource) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, item := range *input { + var name string + if item.Name != nil { + name = *item.Name + } + var alias string + if item.Alias != nil { + alias = *item.Alias + } + var baseGroupDn string + if item.BaseGroupDN != nil { + baseGroupDn = *item.BaseGroupDN + } + var baseUserDn string + if item.BaseUserDN != nil { + baseUserDn = *item.BaseUserDN + } + var domain string + if item.Domain != nil { + domain = *item.Domain + } + var password string + if item.Password != nil { + password = *item.Password + } + var primaryServer string + if item.PrimaryServer != nil { + primaryServer = *item.PrimaryServer + } + var secondaryServer string + if item.SecondaryServer != nil { + secondaryServer = *item.SecondaryServer + } + sSL := item.Ssl==avs.SslEnumEnabled + var username string + if item.Username != nil { + username = *item.Username + } + v := map[string]interface{}{ + "name": name, + "alias": alias, + "base_group_dn": baseGroupDn, + "base_user_dn": baseUserDn, + "domain": domain, + "password": password, + "primary_server": primaryServer, + "secondary_server": secondaryServer, + "ssl": sSL, + "username": username, + } + results = append(results, v) + } + return results +} + +func flattenArmPrivateCloudEndpoints(input *avs.Endpoints) []interface{} { + if input == nil { + return make([]interface{}, 0) + } + + var hcxCloudManager string + if input.HcxCloudManager != nil { + hcxCloudManager = *input.HcxCloudManager + } + var nsxtManager string + if input.NsxtManager != nil { + nsxtManager = *input.NsxtManager + } + var vcsa string + if input.Vcsa != nil { + vcsa = *input.Vcsa + } + return []interface{}{ + map[string]interface{}{ + "hcx_cloud_manager": hcxCloudManager, + "nsxt_manager": nsxtManager, + "vcsa": vcsa, + }, + } +} + +func flattenArmPrivateCloudSku(input *avs.Sku) []interface{} { + if input == nil { + return make([]interface{}, 0) + } + + var name string + if input.Name != nil { + name = *input.Name + } + return []interface{}{ + map[string]interface{}{ + "name": name, + }, + } +} diff --git a/azurerm/internal/services/avs/client/client.go b/azurerm/internal/services/avs/client/client.go new file mode 100644 index 000000000000..dff68a01c8c5 --- /dev/null +++ b/azurerm/internal/services/avs/client/client.go @@ -0,0 +1,33 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) +type Client struct { + PrivateCloudClient *avs.PrivateCloudsClient + ClusterClient *avs.ClustersClient + HcxEnterpriseSiteClient *avs.HcxEnterpriseSitesClient + AuthorizationClient *avs.AuthorizationsClient +} + +func NewClient(o *common.ClientOptions) *Client { + privateCloudClient := avs.NewPrivateCloudsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&privateCloudClient.Client, o.ResourceManagerAuthorizer) + + clusterClient := avs.NewClustersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&clusterClient.Client, o.ResourceManagerAuthorizer) + + hcxEnterpriseSiteClient := avs.NewHcxEnterpriseSitesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&hcxEnterpriseSiteClient.Client, o.ResourceManagerAuthorizer) + + authorizationClient := avs.NewAuthorizationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&authorizationClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + PrivateCloudClient: &privateCloudClient, + ClusterClient: &clusterClient, + HcxEnterpriseSiteClient: &hcxEnterpriseSiteClient, + AuthorizationClient: &authorizationClient, + } +} diff --git a/azurerm/internal/services/avs/parse/avs_authorizations.go b/azurerm/internal/services/avs/parse/avs_authorizations.go new file mode 100644 index 000000000000..2a731776e466 --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_authorizations.go @@ -0,0 +1,32 @@ +package parse +import ( + "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) +type AvsAuthorizationId struct { + ResourceGroup string + PrivateCloudName string + Name string +} + +func AvsAuthorizationID(input string) (*AvsAuthorizationId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing avsAuthorization ID %q: %+v", input, err) + } + + avsAuthorization := AvsAuthorizationId{ + ResourceGroup: id.ResourceGroup, + } + if avsAuthorization.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { + return nil, err + } + if avsAuthorization.Name, err = id.PopSegment("authorizations"); err != nil { + return nil, err + } + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &avsAuthorization, nil +} diff --git a/azurerm/internal/services/avs/parse/avs_authorizations_test.go b/azurerm/internal/services/avs/parse/avs_authorizations_test.go new file mode 100644 index 000000000000..92aa90a0119c --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_authorizations_test.go @@ -0,0 +1,77 @@ +package parse + +import ( + "testing" +) + +func TestAvsAuthorizationID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *AvsAuthorizationId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing Authorization Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations", + Expected: nil, + }, + { + Name: "avs Authorization ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/authorization1", + Expected: &AvsAuthorizationId{ + ResourceGroup:"resourceGroup1", + PrivateCloudName:"privateCloud1", + Name:"authorization1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/Authorizations/authorization1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) + + actual, err := AvsAuthorizationID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + + if actual.PrivateCloudName != v.Expected.PrivateCloudName { + t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/avs/parse/avs_clusters.go b/azurerm/internal/services/avs/parse/avs_clusters.go new file mode 100644 index 000000000000..baa1b08c9e4d --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_clusters.go @@ -0,0 +1,33 @@ +package parse + +import ( + "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) +type AvsClusterId struct { + ResourceGroup string + PrivateCloudName string + Name string +} + +func AvsClusterID(input string) (*AvsClusterId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing avsCluster ID %q: %+v", input, err) + } + + avsCluster := AvsClusterId{ + ResourceGroup: id.ResourceGroup, + } + if avsCluster.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { + return nil, err + } + if avsCluster.Name, err = id.PopSegment("clusters"); err != nil { + return nil, err + } + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &avsCluster, nil +} diff --git a/azurerm/internal/services/avs/parse/avs_clusters_test.go b/azurerm/internal/services/avs/parse/avs_clusters_test.go new file mode 100644 index 000000000000..15ad350cdf91 --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_clusters_test.go @@ -0,0 +1,77 @@ +package parse + +import ( + "testing" +) + +func TestAvsClusterID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *AvsClusterId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing Cluster Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters", + Expected: nil, + }, + { + Name: "avs Cluster ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters/cluster1", + Expected: &AvsClusterId{ + ResourceGroup:"resourceGroup1", + PrivateCloudName:"privateCloud1", + Name:"cluster1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/Clusters/cluster1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) + + actual, err := AvsClusterID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + + if actual.PrivateCloudName != v.Expected.PrivateCloudName { + t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go new file mode 100644 index 000000000000..a6dbc043d15a --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go @@ -0,0 +1,33 @@ +package parse + +import ( + "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) +type AvsHcxEnterpriseSiteId struct { + ResourceGroup string + PrivateCloudName string + Name string +} + +func AvsHcxEnterpriseSiteID(input string) (*AvsHcxEnterpriseSiteId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing avsHcxEnterpriseSite ID %q: %+v", input, err) + } + + avsHcxEnterpriseSite := AvsHcxEnterpriseSiteId{ + ResourceGroup: id.ResourceGroup, + } + if avsHcxEnterpriseSite.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { + return nil, err + } + if avsHcxEnterpriseSite.Name, err = id.PopSegment("hcxEnterpriseSites"); err != nil { + return nil, err + } + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &avsHcxEnterpriseSite, nil +} diff --git a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go new file mode 100644 index 000000000000..446154273fe2 --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go @@ -0,0 +1,77 @@ +package parse + +import ( + "testing" +) + +func TestAvsHcxEnterpriseSiteID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *AvsHcxEnterpriseSiteId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing HcxEnterpriseSite Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites", + Expected: nil, + }, + { + Name: "avs HcxEnterpriseSite ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites/hcxEnterpriseSite1", + Expected: &AvsHcxEnterpriseSiteId{ + ResourceGroup:"resourceGroup1", + PrivateCloudName:"privateCloud1", + Name:"hcxEnterpriseSite1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/HcxEnterpriseSites/hcxEnterpriseSite1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) + + actual, err := AvsHcxEnterpriseSiteID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + + if actual.PrivateCloudName != v.Expected.PrivateCloudName { + t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/avs/parse/avs_private_clouds.go b/azurerm/internal/services/avs/parse/avs_private_clouds.go new file mode 100644 index 000000000000..631f7e3367fb --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_private_clouds.go @@ -0,0 +1,29 @@ +package parse + +import ( + "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) +type AvsPrivateCloudId struct { + ResourceGroup string + Name string +} + +func AvsPrivateCloudID(input string) (*AvsPrivateCloudId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing avsPrivateCloud ID %q: %+v", input, err) + } + + avsPrivateCloud := AvsPrivateCloudId{ + ResourceGroup: id.ResourceGroup, + } + if avsPrivateCloud.Name, err = id.PopSegment("privateClouds"); err != nil { + return nil, err + } + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &avsPrivateCloud, nil +} diff --git a/azurerm/internal/services/avs/parse/avs_private_clouds_test.go b/azurerm/internal/services/avs/parse/avs_private_clouds_test.go new file mode 100644 index 000000000000..aae5c201712b --- /dev/null +++ b/azurerm/internal/services/avs/parse/avs_private_clouds_test.go @@ -0,0 +1,72 @@ +package parse + +import ( + "testing" +) + +func TestAvsPrivateCloudID(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *AvsPrivateCloudId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing PrivateCloud Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds", + Expected: nil, + }, + { + Name: "avs PrivateCloud ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1", + Expected: &AvsPrivateCloudId{ + ResourceGroup:"resourceGroup1", + Name:"privateCloud1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/PrivateClouds/privateCloud1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) + + actual, err := AvsPrivateCloudID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/avs/registration.go b/azurerm/internal/services/avs/registration.go new file mode 100644 index 000000000000..265fd5bdcb7a --- /dev/null +++ b/azurerm/internal/services/avs/registration.go @@ -0,0 +1,37 @@ +package avs + +import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + +type Registration struct{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Avs" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Avs", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_avs_private_cloud": dataSourceAvsPrivateCloud(), + "azurerm_avs_cluster": dataSourceAvsCluster(), + "azurerm_avs_hcx_enterprise_site": dataSourceAvsHcxEnterpriseSite(), + "azurerm_avs_authorization": dataSourceAvsAuthorization(), + } +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_avs_private_cloud": resourceArmAvsPrivateCloud(), + "azurerm_avs_cluster": resourceArmAvsCluster(), + "azurerm_avs_hcx_enterprise_site": resourceArmAvsHcxEnterpriseSite(), + "azurerm_avs_authorization": resourceArmAvsAuthorization(), + } +} diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go new file mode 100644 index 000000000000..d84a4baa121a --- /dev/null +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go @@ -0,0 +1,36 @@ +package tests + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "testing" +) +func TestAccDataSourceAzureRMavsPrivateCloud_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + }, + }) +} + +func testAccDataSourceavsPrivateCloud_basic(data acceptance.TestData) string { + config := testAccAzureRMavsPrivateCloud_basic(data) + return fmt.Sprintf(` +%s + +data "azurerm_avs_private_cloud" "test" { + name = azurerm_avs_private_cloud.test.name + resource_group_name = azurerm_avs_private_cloud.test.resource_group_name +} +`, config) +} diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go new file mode 100644 index 000000000000..7450e4db545f --- /dev/null +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go @@ -0,0 +1,363 @@ +package tests + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "testing" +) + +func TestAccAzureRMavsPrivateCloud_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMavsPrivateCloud_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.RequiresImportErrorStep(testAccAzureRMavsPrivateCloud_requiresImport), + }, + }) +} + +func TestAccAzureRMavsPrivateCloud_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMavsPrivateCloud_updateManagementCluster(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_updateManagementCluster(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMavsPrivateCloud_updateIdentitySources(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_updateIdentitySources(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func testCheckAzureRMavsPrivateCloudExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("avs PrivateCloud not found: %s", resourceName) + } + id, err := parse.AvsPrivateCloudID(rs.Primary.ID) + if err != nil { + return err + } + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("bad: Avs PrivateCloud %q does not exist", id.Name) + } + return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) + } + return nil + } +} + +func testCheckAzureRMavsPrivateCloudDestroy(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_avs_private_cloud" { + continue + } + id, err := parse.AvsPrivateCloudID(rs.Primary.ID) + if err != nil { + return err + } + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) + } + } + return nil + } + return nil +} + +func testAccAzureRMavsPrivateCloud_template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-avs-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func testAccAzureRMavsPrivateCloud_basic(data acceptance.TestData) string { + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_avs_private_cloud" "test" { + name = "acctest-apc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku { + name = "av36" + } + + management_cluster { + cluster_size = 4 + } + network_block = "192.168.48.0/22" +} +`, template, data.RandomInteger) +} + +func testAccAzureRMavsPrivateCloud_requiresImport(data acceptance.TestData) string { + config := testAccAzureRMavsPrivateCloud_basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_avs_private_cloud" "import" { + name = azurerm_avs_private_cloud.test.name + resource_group_name = azurerm_avs_private_cloud.test.resource_group_name + location = azurerm_avs_private_cloud.test.location + sku { + name = azurerm_avs_private_cloud.test.sku.name + } + management_cluster { + cluster_size = azurerm_avs_private_cloud.test.management_cluster.cluster_size + } + network_block = azurerm_avs_private_cloud.test.network_block +} +`, config) +} + +func testAccAzureRMavsPrivateCloud_complete(data acceptance.TestData) string { + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_avs_private_cloud" "test" { + name = "acctest-apc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku { + name = "AV36" + } + + management_cluster { + cluster_size = 4 + } + network_block = "192.168.48.0/22" + identity_source { + name = "" + alias = "" + base_group_dn = "" + base_user_dn = "" + domain = "" + password = "" + primary_server = "" + secondary_server = "" + ssl = false + username = "" + } + internet = false + nsxt_password = "" + vcenter_password = "" + tags = { + ENV = "Test" + } +} +`, template, data.RandomInteger) +} + +func testAccAzureRMavsPrivateCloud_updateManagementCluster(data acceptance.TestData) string { + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_avs_private_cloud" "test" { + name = "acctest-apc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku { + name = "AV36" + } + + management_cluster { + cluster_size = 4 + } + network_block = "192.168.48.0/22" + identity_source { + name = "" + alias = "" + base_group_dn = "" + base_user_dn = "" + domain = "" + password = "" + primary_server = "" + secondary_server = "" + ssl = false + username = "" + } + internet = false + nsxt_password = "" + vcenter_password = "" + tags = { + ENV = "Test" + } +} +`, template, data.RandomInteger) +} + +func testAccAzureRMavsPrivateCloud_updateIdentitySources(data acceptance.TestData) string { + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_avs_private_cloud" "test" { + name = "acctest-apc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku { + name = "AV36" + } + + management_cluster { + cluster_size = 4 + } + network_block = "192.168.48.0/22" + identity_source { + name = "" + alias = "" + base_group_dn = "" + base_user_dn = "" + domain = "" + password = "" + primary_server = "" + secondary_server = "" + ssl = false + username = "" + } + internet = false + nsxt_password = "" + vcenter_password = "" + tags = { + ENV = "Test" + } +} +`, template, data.RandomInteger) +} diff --git a/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown new file mode 100644 index 000000000000..6f2c6e9881d6 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown @@ -0,0 +1,47 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: Data Source: azurerm_avs_authorization" +description: |- + Gets information about an existing avs Authorization. +--- + +# Data Source: azurerm_avs_authorization + +Use this data source to access information about an existing avs Authorization. + +## Example Usage + +```hcl +data "azurerm_avs_authorization" "example" { + name = "example-authorization" + resource_group_name = "example-resource-group" + private_cloud_name = "existing" +} + +output "id" { + value = data.azurerm_avs_authorization.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of this avs Authorization. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs Authorization exists. + +* `private_cloud_name` - (Required) Name of the private cloud. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs Authorization. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the avs Authorization. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown new file mode 100644 index 000000000000..de1690c15cf9 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown @@ -0,0 +1,47 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: Data Source: azurerm_avs_cluster" +description: |- + Gets information about an existing avs Cluster. +--- + +# Data Source: azurerm_avs_cluster + +Use this data source to access information about an existing avs Cluster. + +## Example Usage + +```hcl +data "azurerm_avs_cluster" "example" { + name = "example-cluster" + resource_group_name = "example-resource-group" + private_cloud_name = "existing" +} + +output "id" { + value = data.azurerm_avs_cluster.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of this avs Cluster. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs Cluster exists. + +* `private_cloud_name` - (Required) Name of the private cloud. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs Cluster. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the avs Cluster. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown new file mode 100644 index 000000000000..6e18f0e9d375 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown @@ -0,0 +1,47 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: Data Source: azurerm_avs_hcx_enterprise_site" +description: |- + Gets information about an existing avs HcxEnterpriseSite. +--- + +# Data Source: azurerm_avs_hcx_enterprise_site + +Use this data source to access information about an existing avs HcxEnterpriseSite. + +## Example Usage + +```hcl +data "azurerm_avs_hcx_enterprise_site" "example" { + name = "example-hcxenterprisesite" + resource_group_name = "example-resource-group" + private_cloud_name = "existing" +} + +output "id" { + value = data.azurerm_avs_hcx_enterprise_site.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of this avs HcxEnterpriseSite. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs HcxEnterpriseSite exists. + +* `private_cloud_name` - (Required) Name of the private cloud. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs HcxEnterpriseSite. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the avs HcxEnterpriseSite. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown new file mode 100644 index 000000000000..38b17d1338ac --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown @@ -0,0 +1,48 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: Data Source: azurerm_avs_private_cloud" +description: |- + Gets information about an existing avs PrivateCloud. +--- + +# Data Source: azurerm_avs_private_cloud + +Use this data source to access information about an existing avs PrivateCloud. + +## Example Usage + +```hcl +data "azurerm_avs_private_cloud" "example" { + name = "example-privatecloud" + resource_group_name = "example-resource-group" +} + +output "id" { + value = data.azurerm_avs_private_cloud.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of this avs PrivateCloud. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs PrivateCloud exists. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs PrivateCloud. + +* `location` - The Azure Region where the avs PrivateCloud exists. + +* `tags` - A mapping of tags assigned to the avs PrivateCloud. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the avs PrivateCloud. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown new file mode 100644 index 000000000000..d098815c1b57 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown @@ -0,0 +1,78 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_avs_authorization" +description: |- + Manages a avs Authorization. +--- + +# azurerm_avs_authorization + +Manages a avs Authorization. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_avs_private_cloud" "example" { + name = "example-privatecloud" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + sku { + name = "example-privatecloud" + } + + management_cluster { + cluster_size = 42 + } + network_block = "" +} + +resource "azurerm_avs_authorization" "example" { + name = "example-authorization" + resource_group_name = azurerm_resource_group.example.name + private_cloud_name = azurerm_avs_private_cloud.example.name +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this avs Authorization. Changing this forces a new avs Authorization to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs Authorization should exist. Changing this forces a new avs Authorization to be created. + +* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs Authorization to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs Authorization. + +* `express_route_authorization_id` - The ID of the express_route_authorization. + +* `express_route_authorization_key` - The key of the ExpressRoute Circuit Authorization. + +* `type` - Resource type. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the avs Authorization. +* `read` - (Defaults to 5 minutes) Used when retrieving the avs Authorization. +* `delete` - (Defaults to 30 minutes) Used when deleting the avs Authorization. + +## Import + +avs Authorizations can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_avs_authorization.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/authorization1 +``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown new file mode 100644 index 000000000000..f43b6c80c88d --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown @@ -0,0 +1,93 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_avs_cluster" +description: |- + Manages a avs Cluster. +--- + +# azurerm_avs_cluster + +Manages a avs Cluster. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_avs_private_cloud" "example" { + name = "example-privatecloud" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + sku { + name = "example-privatecloud" + } + + management_cluster { + cluster_size = 42 + } + network_block = "" +} + +resource "azurerm_avs_cluster" "example" { + name = "example-cluster" + resource_group_name = azurerm_resource_group.example.name + private_cloud_name = azurerm_avs_private_cloud.example.name + sku { + name = "example-cluster" + } + cluster_size = 42 +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this avs Cluster. Changing this forces a new avs Cluster to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs Cluster should exist. Changing this forces a new avs Cluster to be created. + +* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs Cluster to be created. + +* `sku` - (Required) A `sku` block as defined below. Changing this forces a new avs Cluster to be created. + +* `cluster_size` - (Required) The cluster size. + +--- + +An `sku` block exports the following: + +* `name` - (Required) The name which should be used for this sku. Changing this forces a new avs Cluster to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs Cluster. + +* `cluster_id` - The ID of the cluster. + +* `hosts` - The hosts. + +* `type` - Resource type. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the avs Cluster. +* `read` - (Defaults to 5 minutes) Used when retrieving the avs Cluster. +* `update` - (Defaults to 30 minutes) Used when updating the avs Cluster. +* `delete` - (Defaults to 30 minutes) Used when deleting the avs Cluster. + +## Import + +avs Clusters can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_avs_cluster.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters/cluster1 +``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown new file mode 100644 index 000000000000..a7102f331b78 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown @@ -0,0 +1,76 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_avs_hcx_enterprise_site" +description: |- + Manages a avs HcxEnterpriseSite. +--- + +# azurerm_avs_hcx_enterprise_site + +Manages a avs HcxEnterpriseSite. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_avs_private_cloud" "example" { + name = "example-privatecloud" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + sku { + name = "example-privatecloud" + } + + management_cluster { + cluster_size = 42 + } + network_block = "" +} + +resource "azurerm_avs_hcx_enterprise_site" "example" { + name = "example-hcxenterprisesite" + resource_group_name = azurerm_resource_group.example.name + private_cloud_name = azurerm_avs_private_cloud.example.name +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this avs HcxEnterpriseSite. Changing this forces a new avs HcxEnterpriseSite to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs HcxEnterpriseSite should exist. Changing this forces a new avs HcxEnterpriseSite to be created. + +* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs HcxEnterpriseSite to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs HcxEnterpriseSite. + +* `activation_key` - The activation key. + +* `type` - Resource type. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the avs HcxEnterpriseSite. +* `read` - (Defaults to 5 minutes) Used when retrieving the avs HcxEnterpriseSite. +* `delete` - (Defaults to 30 minutes) Used when deleting the avs HcxEnterpriseSite. + +## Import + +avs HcxEnterpriseSites can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_avs_hcx_enterprise_site.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites/hcxEnterpriseSite1 +``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown new file mode 100644 index 000000000000..099ec120d789 --- /dev/null +++ b/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown @@ -0,0 +1,159 @@ +--- +subcategory: "Avs" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_avs_private_cloud" +description: |- + Manages a avs PrivateCloud. +--- + +# azurerm_avs_private_cloud + +Manages a avs PrivateCloud. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_avs_private_cloud" "example" { + name = "example-privatecloud" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + sku { + name = "example-privatecloud" + } + + management_cluster { + cluster_size = 42 + } + network_block = "192.168.48.0/22" +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this avs PrivateCloud. Changing this forces a new avs PrivateCloud to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the avs PrivateCloud should exist. Changing this forces a new avs PrivateCloud to be created. + +* `location` - (Required) The Azure Region where the avs PrivateCloud should exist. Changing this forces a new avs PrivateCloud to be created. + +* `sku` - (Required) A `sku` block as defined below. Changing this forces a new avs PrivateCloud to be created. + +* `management_cluster` - (Required) A `management_cluster` block as defined below. + +* `network_block` - (Required) The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22. + +--- + +* `identity_source` - (Optional) A `identity_source` block as defined below. + +* `internet` - (Optional) Connectivity to internet is enabled or disabled. Possible values are "true" and "false" is allowed. + +* `nsxt_password` - (Optional) Optionally, set the NSX-T Manager password when the private cloud is created. + +* `vcenter_password` - (Optional) Optionally, set the vCenter admin password when the private cloud is created. + +* `tags` - (Optional) A mapping of tags which should be assigned to the avs PrivateCloud. + +--- + +An `sku` block exports the following: + +* `name` - (Required) The name which should be used for this sku. Changing this forces a new avs PrivateCloud to be created. + +--- + +An `management_cluster` block exports the following: + +* `cluster_size` - (Required) The cluster size. + +--- + +An `identity_source` block exports the following: + +* `name` - (Optional) The name which should be used for this identity_source. + +* `alias` - (Optional) The domain's NetBIOS name. + +* `base_group_dn` - (Optional) The base distinguished name for groups. + +* `base_user_dn` - (Optional) The base distinguished name for users. + +* `domain` - (Optional) The domain's dns name. + +* `password` - (Optional) The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. + +* `primary_server` - (Optional) Primary server URL. + +* `secondary_server` - (Optional) Secondary server URL. + +* `ssl` - (Optional) Protect LDAP communication using SSL certificate (LDAPS). Possible values are "true" and "false" is allowed. + +* `username` - (Optional) The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the avs PrivateCloud. + +* `circuit` - An ExpressRoute Circuit. A `circuit` block as defined below. + +* `endpoint` - The endpoints. A `endpoint` block as defined below. + +* `management_network` - Network used to access vCenter Server and NSX-T Manager. + +* `nsxt_certificate_thumbprint` - Thumbprint of the NSX-T Manager SSL certificate. + +* `provisioning_network` - Used for virtual machine cold migration, cloning, and snapshot migration. + +* `type` - Resource type. + +* `vcenter_certificate_thumbprint` - Thumbprint of the vCenter Server SSL certificate. + +* `vmotion_network` - Used for live migration of virtual machines. + +--- + +An `circuit` block exports the following: + +* `express_route_id` - The ID of the express_route. + +* `express_route_private_peering_id` - The ID of the express_route_private_peering. + +* `primary_subnet` - CIDR of primary subnet. + +* `secondary_subnet` - CIDR of secondary subnet. + +--- + +An `endpoint` block exports the following: + +* `hcx_cloud_manager` - Endpoint for the HCX Cloud Manager. + +* `nsxt_manager` - Endpoint for the NSX-T Data Center manager. + +* `vcsa` - Endpoint for Virtual Center Server Appliance. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the avs PrivateCloud. +* `read` - (Defaults to 5 minutes) Used when retrieving the avs PrivateCloud. +* `update` - (Defaults to 30 minutes) Used when updating the avs PrivateCloud. +* `delete` - (Defaults to 30 minutes) Used when deleting the avs PrivateCloud. + +## Import + +avs PrivateClouds can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_avs_private_cloud.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1 +``` \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go new file mode 100644 index 000000000000..e8cc967e2088 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go @@ -0,0 +1,432 @@ +package avs + +// 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" +) + +// AuthorizationsClient is the azure VMware Solution API +type AuthorizationsClient struct { + BaseClient +} + +// NewAuthorizationsClient creates an instance of the AuthorizationsClient client. +func NewAuthorizationsClient(subscriptionID string) AuthorizationsClient { + return NewAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAuthorizationsClientWithBaseURI creates an instance of the AuthorizationsClient 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 NewAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationsClient { + return AuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +// authorization - an ExpressRoute Circuit Authorization +func (client AuthorizationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (result AuthorizationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, authorizationName, authorization) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AuthorizationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", pathParameters), + autorest.WithJSON(authorization), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationsClient) CreateOrUpdateSender(req *http.Request) (future AuthorizationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteAuthorization, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result AuthorizationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AuthorizationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) DeleteSender(req *http.Request) (future AuthorizationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result ExpressRouteAuthorization, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AuthorizationsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) 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 AuthorizationsClient) GetResponder(resp *http.Response) (result ExpressRouteAuthorization, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client AuthorizationsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.List") + defer func() { + sc := -1 + if result.eral.Response.Response != nil { + sc = result.eral.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.eral.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure sending request") + return + } + + result.eral, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure responding to request") + } + if result.eral.hasNextLink() && result.eral.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AuthorizationsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations", 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 AuthorizationsClient) 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 AuthorizationsClient) ListResponder(resp *http.Response) (result ExpressRouteAuthorizationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AuthorizationsClient) listNextResults(ctx context.Context, lastResults ExpressRouteAuthorizationList) (result ExpressRouteAuthorizationList, err error) { + req, err := lastResults.expressRouteAuthorizationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "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, "avs.AuthorizationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AuthorizationsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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, privateCloudName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go new file mode 100644 index 000000000000..eb7087c9474a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go @@ -0,0 +1,89 @@ +package avsapi + +// 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/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result avs.OperationListPage, err error) + ListComplete(ctx context.Context) (result avs.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*avs.OperationsClient)(nil) + +// LocationsClientAPI contains the set of methods on the LocationsClient type. +type LocationsClientAPI interface { + CheckQuotaAvailability(ctx context.Context, location string) (result avs.Quota, err error) + CheckTrialAvailability(ctx context.Context, location string) (result avs.Trial, err error) +} + +var _ LocationsClientAPI = (*avs.LocationsClient)(nil) + +// PrivateCloudsClientAPI contains the set of methods on the PrivateCloudsClient type. +type PrivateCloudsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud avs.PrivateCloud) (result avs.PrivateCloudsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloudsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloud, err error) + List(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListIterator, err error) + ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.AdminCredentials, err error) + ListInSubscription(ctx context.Context) (result avs.PrivateCloudListPage, err error) + ListInSubscriptionComplete(ctx context.Context) (result avs.PrivateCloudListIterator, err error) + Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate avs.PrivateCloudUpdate) (result avs.PrivateCloudsUpdateFuture, err error) +} + +var _ PrivateCloudsClientAPI = (*avs.PrivateCloudsClient)(nil) + +// ClustersClientAPI contains the set of methods on the ClustersClient type. +type ClustersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster avs.Cluster) (result avs.ClustersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.ClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.Cluster, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListIterator, err error) + Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate avs.ClusterUpdate) (result avs.ClustersUpdateFuture, err error) +} + +var _ ClustersClientAPI = (*avs.ClustersClient)(nil) + +// HcxEnterpriseSitesClientAPI contains the set of methods on the HcxEnterpriseSitesClient type. +type HcxEnterpriseSitesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (result avs.HcxEnterpriseSite, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result avs.HcxEnterpriseSite, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListIterator, err error) +} + +var _ HcxEnterpriseSitesClientAPI = (*avs.HcxEnterpriseSitesClient)(nil) + +// AuthorizationsClientAPI contains the set of methods on the AuthorizationsClient type. +type AuthorizationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (result avs.AuthorizationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.AuthorizationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.ExpressRouteAuthorization, err error) + List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListIterator, err error) +} + +var _ AuthorizationsClientAPI = (*avs.AuthorizationsClient)(nil) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go new file mode 100644 index 000000000000..f9b3fc4c05b3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go @@ -0,0 +1,52 @@ +// Package avs implements the Azure ARM Avs service API version 2020-03-20. +// +// Azure VMware Solution API +package avs + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Avs + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Avs. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient 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 NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go new file mode 100644 index 000000000000..fb28755b2d24 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go @@ -0,0 +1,526 @@ +package avs + +// 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" +) + +// ClustersClient is the azure VMware Solution API +type ClustersClient struct { + BaseClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient 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 NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// clusterName - name of the cluster in the private cloud +// cluster - a cluster in the private cloud +func (client ClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (result ClustersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, + {TargetValue: cluster, + Constraints: []validation.Constraint{{Target: "cluster.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "cluster.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "cluster.ClusterProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, cluster) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(cluster), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) CreateOrUpdateSender(req *http.Request) (future ClustersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateOrUpdateResponder(resp *http.Response) (result Cluster, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result ClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (future ClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) 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 ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client ClustersClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure responding to request") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ClustersClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters", 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 ClustersClient) 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 ClustersClient) ListResponder(resp *http.Response) (result ClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ClustersClient) listNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ClustersClient", "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, "avs.ClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClustersClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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, privateCloudName) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// clusterUpdate - the cluster properties to be updated +func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (result ClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(clusterUpdate), + 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 ClustersClient) UpdateSender(req *http.Request) (future ClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go new file mode 100644 index 000000000000..f04bbdee504f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go @@ -0,0 +1,433 @@ +package avs + +// 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" +) + +// HcxEnterpriseSitesClient is the azure VMware Solution API +type HcxEnterpriseSitesClient struct { + BaseClient +} + +// NewHcxEnterpriseSitesClient creates an instance of the HcxEnterpriseSitesClient client. +func NewHcxEnterpriseSitesClient(subscriptionID string) HcxEnterpriseSitesClient { + return NewHcxEnterpriseSitesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHcxEnterpriseSitesClientWithBaseURI creates an instance of the HcxEnterpriseSitesClient 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 NewHcxEnterpriseSitesClientWithBaseURI(baseURI string, subscriptionID string) HcxEnterpriseSitesClient { + return HcxEnterpriseSitesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +// hcxEnterpriseSite - the HCX Enterprise Site +func (client HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, hcxEnterpriseSite) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client HcxEnterpriseSitesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", pathParameters), + autorest.WithJSON(hcxEnterpriseSite), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client HcxEnterpriseSitesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client HcxEnterpriseSitesClient) CreateOrUpdateResponder(resp *http.Response) (result HcxEnterpriseSite, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HcxEnterpriseSitesClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HcxEnterpriseSitesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HcxEnterpriseSitesClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) GetResponder(resp *http.Response) (result HcxEnterpriseSite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client HcxEnterpriseSitesClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.List") + defer func() { + sc := -1 + if result.hesl.Response.Response != nil { + sc = result.hesl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.hesl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure sending request") + return + } + + result.hesl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure responding to request") + } + if result.hesl.hasNextLink() && result.hesl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client HcxEnterpriseSitesClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) ListResponder(resp *http.Response) (result HcxEnterpriseSiteList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client HcxEnterpriseSitesClient) listNextResults(ctx context.Context, lastResults HcxEnterpriseSiteList) (result HcxEnterpriseSiteList, err error) { + req, err := lastResults.hcxEnterpriseSiteListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "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, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client HcxEnterpriseSitesClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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, privateCloudName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go new file mode 100644 index 000000000000..1a3f5032a634 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go @@ -0,0 +1,201 @@ +package avs + +// 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" +) + +// LocationsClient is the azure VMware Solution API +type LocationsClient struct { + BaseClient +} + +// NewLocationsClient creates an instance of the LocationsClient client. +func NewLocationsClient(subscriptionID string) LocationsClient { + return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationsClientWithBaseURI creates an instance of the LocationsClient 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 NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckQuotaAvailability return quota for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckQuotaAvailability(ctx context.Context, location string) (result Quota, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckQuotaAvailability", err.Error()) + } + + req, err := client.CheckQuotaAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckQuotaAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckQuotaAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckQuotaAvailabilityPreparer prepares the CheckQuotaAvailability request. +func (client LocationsClient) CheckQuotaAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability", pathParameters), + 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 LocationsClient) 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 LocationsClient) CheckQuotaAvailabilityResponder(resp *http.Response) (result Quota, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckTrialAvailability return trial status for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckTrialAvailability(ctx context.Context, location string) (result Trial, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.CheckTrialAvailability") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckTrialAvailability", err.Error()) + } + + req, err := client.CheckTrialAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckTrialAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckTrialAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckTrialAvailabilityPreparer prepares the CheckTrialAvailability request. +func (client LocationsClient) CheckTrialAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckTrialAvailabilitySender sends the CheckTrialAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) CheckTrialAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckTrialAvailabilityResponder handles the response to the CheckTrialAvailability request. The method always +// closes the http.Response Body. +func (client LocationsClient) CheckTrialAvailabilityResponder(resp *http.Response) (result Trial, 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/avs/mgmt/2020-03-20/avs/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go new file mode 100644 index 000000000000..26c10c261f3a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go @@ -0,0 +1,1770 @@ +package avs + +// 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/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/avs/mgmt/2020-03-20/avs" + +// AdminCredentials administrative credentials for accessing vCenter and NSX-T +type AdminCredentials struct { + autorest.Response `json:"-"` + // NsxtUsername - READ-ONLY; NSX-T Manager username + NsxtUsername *string `json:"nsxtUsername,omitempty"` + // NsxtPassword - READ-ONLY; NSX-T Manager password + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterUsername - READ-ONLY; vCenter admin username + VcenterUsername *string `json:"vcenterUsername,omitempty"` + // VcenterPassword - READ-ONLY; vCenter admin password + VcenterPassword *string `json:"vcenterPassword,omitempty"` +} + +// AuthorizationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AuthorizationsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AuthorizationsCreateOrUpdateFuture) Result(client AuthorizationsClient) (era ExpressRouteAuthorization, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if era.Response.Response, err = future.GetResult(sender); err == nil && era.Response.Response.StatusCode != http.StatusNoContent { + era, err = client.CreateOrUpdateResponder(era.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", era.Response.Response, "Failure responding to request") + } + } + return +} + +// AuthorizationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AuthorizationsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AuthorizationsDeleteFuture) Result(client AuthorizationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Circuit an ExpressRoute Circuit +type Circuit struct { + // PrimarySubnet - READ-ONLY; CIDR of primary subnet + PrimarySubnet *string `json:"primarySubnet,omitempty"` + // SecondarySubnet - READ-ONLY; CIDR of secondary subnet + SecondarySubnet *string `json:"secondarySubnet,omitempty"` + // ExpressRouteID - READ-ONLY; Identifier of the ExpressRoute Circuit (Microsoft Colo only) + ExpressRouteID *string `json:"expressRouteID,omitempty"` + // ExpressRoutePrivatePeeringID - READ-ONLY; ExpressRoute Circuit private peering identifier + ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty"` +} + +// CloudError API error response +type CloudError struct { + // Error - An error returned by the API + Error *ErrorResponse `json:"error,omitempty"` +} + +// Cluster a cluster resource +type Cluster struct { + autorest.Response `json:"-"` + // Sku - The cluster SKU + Sku *Sku `json:"sku,omitempty"` + // ClusterProperties - The properties of a cluster resource + *ClusterProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ClusterList a paged list of clusters +type ClusterList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]Cluster `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterListIterator provides access to a complete listing of Cluster values. +type ClusterListIterator struct { + i int + page ClusterListPage +} + +// 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 *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.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 *ClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClusterListIterator) 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 ClusterListIterator) Response() ClusterList { + 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 ClusterListIterator) Value() Cluster { + if !iter.page.NotDone() { + return Cluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClusterListIterator type. +func NewClusterListIterator(page ClusterListPage) ClusterListIterator { + return ClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ClusterList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ClusterList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// clusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ClusterListPage contains a page of Cluster values. +type ClusterListPage struct { + fn func(context.Context, ClusterList) (ClusterList, error) + cl ClusterList +} + +// 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 *ClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.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.cl) + if err != nil { + return err + } + page.cl = 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 *ClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClusterListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClusterListPage) Response() ClusterList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClusterListPage) Values() []Cluster { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ClusterListPage type. +func NewClusterListPage(getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { + return ClusterListPage{fn: getNextPage} +} + +// ClusterProperties the properties of a cluster +type ClusterProperties struct { + // ProvisioningState - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterProperties. +func (cp ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.ClusterSize != nil { + objectMap["clusterSize"] = cp.ClusterSize + } + return json.Marshal(objectMap) +} + +// ClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersCreateOrUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateOrUpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ClustersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersDeleteFuture) Result(client ClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ClustersUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClusterUpdate an update of a cluster resource +type ClusterUpdate struct { + // ClusterUpdateProperties - The properties of a cluster resource that may be updated + *ClusterUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterUpdate. +func (cu ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cu.ClusterUpdateProperties != nil { + objectMap["properties"] = cu.ClusterUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterUpdate struct. +func (cu *ClusterUpdate) 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 "properties": + if v != nil { + var clusterUpdateProperties ClusterUpdateProperties + err = json.Unmarshal(*v, &clusterUpdateProperties) + if err != nil { + return err + } + cu.ClusterUpdateProperties = &clusterUpdateProperties + } + } + } + + return nil +} + +// ClusterUpdateProperties the properties of a cluster that may be updated +type ClusterUpdateProperties struct { + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// Endpoints endpoint addresses +type Endpoints struct { + // NsxtManager - READ-ONLY; Endpoint for the NSX-T Data Center manager + NsxtManager *string `json:"nsxtManager,omitempty"` + // Vcsa - READ-ONLY; Endpoint for Virtual Center Server Appliance + Vcsa *string `json:"vcsa,omitempty"` + // HcxCloudManager - READ-ONLY; Endpoint for the HCX Cloud Manager + HcxCloudManager *string `json:"hcxCloudManager,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorResponse the resource management error response. +type ErrorResponse struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ExpressRouteAuthorization expressRoute Circuit Authorization +type ExpressRouteAuthorization struct { + autorest.Response `json:"-"` + // ExpressRouteAuthorizationProperties - The properties of an ExpressRoute Circuit Authorization resource + *ExpressRouteAuthorizationProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for ExpressRouteAuthorization. +func (era ExpressRouteAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if era.ExpressRouteAuthorizationProperties != nil { + objectMap["properties"] = era.ExpressRouteAuthorizationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExpressRouteAuthorization struct. +func (era *ExpressRouteAuthorization) 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 "properties": + if v != nil { + var expressRouteAuthorizationProperties ExpressRouteAuthorizationProperties + err = json.Unmarshal(*v, &expressRouteAuthorizationProperties) + if err != nil { + return err + } + era.ExpressRouteAuthorizationProperties = &expressRouteAuthorizationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + era.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + era.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + era.Type = &typeVar + } + } + } + + return nil +} + +// ExpressRouteAuthorizationList a paged list of ExpressRoute Circuit Authorizations +type ExpressRouteAuthorizationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]ExpressRouteAuthorization `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ExpressRouteAuthorizationListIterator provides access to a complete listing of ExpressRouteAuthorization +// values. +type ExpressRouteAuthorizationListIterator struct { + i int + page ExpressRouteAuthorizationListPage +} + +// 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 *ExpressRouteAuthorizationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListIterator.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 *ExpressRouteAuthorizationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExpressRouteAuthorizationListIterator) 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 ExpressRouteAuthorizationListIterator) Response() ExpressRouteAuthorizationList { + 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 ExpressRouteAuthorizationListIterator) Value() ExpressRouteAuthorization { + if !iter.page.NotDone() { + return ExpressRouteAuthorization{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExpressRouteAuthorizationListIterator type. +func NewExpressRouteAuthorizationListIterator(page ExpressRouteAuthorizationListPage) ExpressRouteAuthorizationListIterator { + return ExpressRouteAuthorizationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eral ExpressRouteAuthorizationList) IsEmpty() bool { + return eral.Value == nil || len(*eral.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eral ExpressRouteAuthorizationList) hasNextLink() bool { + return eral.NextLink != nil && len(*eral.NextLink) != 0 +} + +// expressRouteAuthorizationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eral ExpressRouteAuthorizationList) expressRouteAuthorizationListPreparer(ctx context.Context) (*http.Request, error) { + if !eral.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eral.NextLink))) +} + +// ExpressRouteAuthorizationListPage contains a page of ExpressRouteAuthorization values. +type ExpressRouteAuthorizationListPage struct { + fn func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error) + eral ExpressRouteAuthorizationList +} + +// 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 *ExpressRouteAuthorizationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListPage.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.eral) + if err != nil { + return err + } + page.eral = 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 *ExpressRouteAuthorizationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExpressRouteAuthorizationListPage) NotDone() bool { + return !page.eral.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExpressRouteAuthorizationListPage) Response() ExpressRouteAuthorizationList { + return page.eral +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExpressRouteAuthorizationListPage) Values() []ExpressRouteAuthorization { + if page.eral.IsEmpty() { + return nil + } + return *page.eral.Value +} + +// Creates a new instance of the ExpressRouteAuthorizationListPage type. +func NewExpressRouteAuthorizationListPage(getNextPage func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error)) ExpressRouteAuthorizationListPage { + return ExpressRouteAuthorizationListPage{fn: getNextPage} +} + +// ExpressRouteAuthorizationProperties the properties of an ExpressRoute Circuit Authorization resource +type ExpressRouteAuthorizationProperties struct { + // ProvisioningState - READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning. Possible values include: 'ExpressRouteAuthorizationProvisioningStateSucceeded', 'ExpressRouteAuthorizationProvisioningStateFailed', 'ExpressRouteAuthorizationProvisioningStateUpdating' + ProvisioningState ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty"` + // ExpressRouteAuthorizationID - READ-ONLY; The ID of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationID *string `json:"expressRouteAuthorizationId,omitempty"` + // ExpressRouteAuthorizationKey - READ-ONLY; The key of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty"` +} + +// HcxEnterpriseSite an HCX Enterprise Site resource +type HcxEnterpriseSite struct { + autorest.Response `json:"-"` + // HcxEnterpriseSiteProperties - The properties of an HCX Enterprise Site resource + *HcxEnterpriseSiteProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for HcxEnterpriseSite. +func (hes HcxEnterpriseSite) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hes.HcxEnterpriseSiteProperties != nil { + objectMap["properties"] = hes.HcxEnterpriseSiteProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HcxEnterpriseSite struct. +func (hes *HcxEnterpriseSite) 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 "properties": + if v != nil { + var hcxEnterpriseSiteProperties HcxEnterpriseSiteProperties + err = json.Unmarshal(*v, &hcxEnterpriseSiteProperties) + if err != nil { + return err + } + hes.HcxEnterpriseSiteProperties = &hcxEnterpriseSiteProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hes.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hes.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hes.Type = &typeVar + } + } + } + + return nil +} + +// HcxEnterpriseSiteList a paged list of HCX Enterprise Sites +type HcxEnterpriseSiteList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]HcxEnterpriseSite `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// HcxEnterpriseSiteListIterator provides access to a complete listing of HcxEnterpriseSite values. +type HcxEnterpriseSiteListIterator struct { + i int + page HcxEnterpriseSiteListPage +} + +// 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 *HcxEnterpriseSiteListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListIterator.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 *HcxEnterpriseSiteListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HcxEnterpriseSiteListIterator) 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 HcxEnterpriseSiteListIterator) Response() HcxEnterpriseSiteList { + 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 HcxEnterpriseSiteListIterator) Value() HcxEnterpriseSite { + if !iter.page.NotDone() { + return HcxEnterpriseSite{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the HcxEnterpriseSiteListIterator type. +func NewHcxEnterpriseSiteListIterator(page HcxEnterpriseSiteListPage) HcxEnterpriseSiteListIterator { + return HcxEnterpriseSiteListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (hesl HcxEnterpriseSiteList) IsEmpty() bool { + return hesl.Value == nil || len(*hesl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (hesl HcxEnterpriseSiteList) hasNextLink() bool { + return hesl.NextLink != nil && len(*hesl.NextLink) != 0 +} + +// hcxEnterpriseSiteListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hesl HcxEnterpriseSiteList) hcxEnterpriseSiteListPreparer(ctx context.Context) (*http.Request, error) { + if !hesl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hesl.NextLink))) +} + +// HcxEnterpriseSiteListPage contains a page of HcxEnterpriseSite values. +type HcxEnterpriseSiteListPage struct { + fn func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error) + hesl HcxEnterpriseSiteList +} + +// 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 *HcxEnterpriseSiteListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListPage.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.hesl) + if err != nil { + return err + } + page.hesl = 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 *HcxEnterpriseSiteListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HcxEnterpriseSiteListPage) NotDone() bool { + return !page.hesl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HcxEnterpriseSiteListPage) Response() HcxEnterpriseSiteList { + return page.hesl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HcxEnterpriseSiteListPage) Values() []HcxEnterpriseSite { + if page.hesl.IsEmpty() { + return nil + } + return *page.hesl.Value +} + +// Creates a new instance of the HcxEnterpriseSiteListPage type. +func NewHcxEnterpriseSiteListPage(getNextPage func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error)) HcxEnterpriseSiteListPage { + return HcxEnterpriseSiteListPage{fn: getNextPage} +} + +// HcxEnterpriseSiteProperties the properties of an HCX Enterprise Site +type HcxEnterpriseSiteProperties struct { + // ActivationKey - READ-ONLY; The activation key + ActivationKey *string `json:"activationKey,omitempty"` + // Status - READ-ONLY; The status of the HCX Enterprise Site. Possible values include: 'Available', 'Consumed', 'Deactivated', 'Deleted' + Status HcxEnterpriseSiteStatus `json:"status,omitempty"` +} + +// IdentitySource vCenter Single Sign On Identity Source +type IdentitySource struct { + // Name - The name of the identity source + Name *string `json:"name,omitempty"` + // Alias - The domain's NetBIOS name + Alias *string `json:"alias,omitempty"` + // Domain - The domain's dns name + Domain *string `json:"domain,omitempty"` + // BaseUserDN - The base distinguished name for users + BaseUserDN *string `json:"baseUserDN,omitempty"` + // BaseGroupDN - The base distinguished name for groups + BaseGroupDN *string `json:"baseGroupDN,omitempty"` + // PrimaryServer - Primary server URL + PrimaryServer *string `json:"primaryServer,omitempty"` + // SecondaryServer - Secondary server URL + SecondaryServer *string `json:"secondaryServer,omitempty"` + // Ssl - Protect LDAP communication using SSL certificate (LDAPS). Possible values include: 'SslEnumEnabled', 'SslEnumDisabled' + Ssl SslEnum `json:"ssl,omitempty"` + // Username - The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group + Username *string `json:"username,omitempty"` + // Password - The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. + Password *string `json:"password,omitempty"` +} + +// ManagementCluster the properties of a default cluster +type ManagementCluster struct { + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementCluster. +func (mc ManagementCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mc.ClusterSize != nil { + objectMap["clusterSize"] = mc.ClusterSize + } + return json.Marshal(objectMap) +} + +// Operation a REST API operation +type Operation struct { + // Name - READ-ONLY; Name of the operation being performed on this object + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; Contains the localized display information for this operation + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay contains the localized display information for this operation +type OperationDisplay struct { + // Provider - READ-ONLY; Localized friendly form of the resource provider name + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Localized friendly form of the resource type related to this operation + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// OperationList pageable list of operations +type OperationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// 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 *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.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 *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) 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 OperationListIterator) Response() OperationList { + 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 OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// 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 *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.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.ol) + if err != nil { + return err + } + page.ol = 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 *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{fn: getNextPage} +} + +// PrivateCloud a private cloud resource +type PrivateCloud struct { + autorest.Response `json:"-"` + // Sku - The private cloud SKU + Sku *Sku `json:"sku,omitempty"` + // PrivateCloudProperties - The properties of a private cloud resource + *PrivateCloudProperties `json:"properties,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // 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"` +} + +// MarshalJSON is the custom marshaler for PrivateCloud. +func (pc PrivateCloud) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pc.Sku != nil { + objectMap["sku"] = pc.Sku + } + if pc.PrivateCloudProperties != nil { + objectMap["properties"] = pc.PrivateCloudProperties + } + if pc.Location != nil { + objectMap["location"] = pc.Location + } + if pc.Tags != nil { + objectMap["tags"] = pc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloud struct. +func (pc *PrivateCloud) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + pc.Sku = &sku + } + case "properties": + if v != nil { + var privateCloudProperties PrivateCloudProperties + err = json.Unmarshal(*v, &privateCloudProperties) + if err != nil { + return err + } + pc.PrivateCloudProperties = &privateCloudProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + pc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + pc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pc.Type = &typeVar + } + } + } + + return nil +} + +// PrivateCloudList a paged list of private clouds +type PrivateCloudList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]PrivateCloud `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateCloudListIterator provides access to a complete listing of PrivateCloud values. +type PrivateCloudListIterator struct { + i int + page PrivateCloudListPage +} + +// 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 *PrivateCloudListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListIterator.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 *PrivateCloudListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateCloudListIterator) 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 PrivateCloudListIterator) Response() PrivateCloudList { + 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 PrivateCloudListIterator) Value() PrivateCloud { + if !iter.page.NotDone() { + return PrivateCloud{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateCloudListIterator type. +func NewPrivateCloudListIterator(page PrivateCloudListPage) PrivateCloudListIterator { + return PrivateCloudListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pcl PrivateCloudList) IsEmpty() bool { + return pcl.Value == nil || len(*pcl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pcl PrivateCloudList) hasNextLink() bool { + return pcl.NextLink != nil && len(*pcl.NextLink) != 0 +} + +// privateCloudListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pcl PrivateCloudList) privateCloudListPreparer(ctx context.Context) (*http.Request, error) { + if !pcl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pcl.NextLink))) +} + +// PrivateCloudListPage contains a page of PrivateCloud values. +type PrivateCloudListPage struct { + fn func(context.Context, PrivateCloudList) (PrivateCloudList, error) + pcl PrivateCloudList +} + +// 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 *PrivateCloudListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListPage.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.pcl) + if err != nil { + return err + } + page.pcl = 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 *PrivateCloudListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateCloudListPage) NotDone() bool { + return !page.pcl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateCloudListPage) Response() PrivateCloudList { + return page.pcl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateCloudListPage) Values() []PrivateCloud { + if page.pcl.IsEmpty() { + return nil + } + return *page.pcl.Value +} + +// Creates a new instance of the PrivateCloudListPage type. +func NewPrivateCloudListPage(getNextPage func(context.Context, PrivateCloudList) (PrivateCloudList, error)) PrivateCloudListPage { + return PrivateCloudListPage{fn: getNextPage} +} + +// PrivateCloudProperties the properties of a private cloud resource +type PrivateCloudProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'PrivateCloudProvisioningStateSucceeded', 'PrivateCloudProvisioningStateFailed', 'PrivateCloudProvisioningStateCancelled', 'PrivateCloudProvisioningStatePending', 'PrivateCloudProvisioningStateBuilding', 'PrivateCloudProvisioningStateDeleting', 'PrivateCloudProvisioningStateUpdating' + ProvisioningState PrivateCloudProvisioningState `json:"provisioningState,omitempty"` + // Circuit - An ExpressRoute Circuit + Circuit *Circuit `json:"circuit,omitempty"` + // Endpoints - READ-ONLY; The endpoints + Endpoints *Endpoints `json:"endpoints,omitempty"` + // NetworkBlock - The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22 + NetworkBlock *string `json:"networkBlock,omitempty"` + // ManagementNetwork - READ-ONLY; Network used to access vCenter Server and NSX-T Manager + ManagementNetwork *string `json:"managementNetwork,omitempty"` + // ProvisioningNetwork - READ-ONLY; Used for virtual machine cold migration, cloning, and snapshot migration + ProvisioningNetwork *string `json:"provisioningNetwork,omitempty"` + // VmotionNetwork - READ-ONLY; Used for live migration of virtual machines + VmotionNetwork *string `json:"vmotionNetwork,omitempty"` + // VcenterPassword - Optionally, set the vCenter admin password when the private cloud is created + VcenterPassword *string `json:"vcenterPassword,omitempty"` + // NsxtPassword - Optionally, set the NSX-T Manager password when the private cloud is created + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterCertificateThumbprint - READ-ONLY; Thumbprint of the vCenter Server SSL certificate + VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty"` + // NsxtCertificateThumbprint - READ-ONLY; Thumbprint of the NSX-T Manager SSL certificate + NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty"` + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloudProperties. +func (pcp PrivateCloudProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pcp.Circuit != nil { + objectMap["circuit"] = pcp.Circuit + } + if pcp.NetworkBlock != nil { + objectMap["networkBlock"] = pcp.NetworkBlock + } + if pcp.VcenterPassword != nil { + objectMap["vcenterPassword"] = pcp.VcenterPassword + } + if pcp.NsxtPassword != nil { + objectMap["nsxtPassword"] = pcp.NsxtPassword + } + if pcp.ManagementCluster != nil { + objectMap["managementCluster"] = pcp.ManagementCluster + } + if pcp.Internet != "" { + objectMap["internet"] = pcp.Internet + } + if pcp.IdentitySources != nil { + objectMap["identitySources"] = pcp.IdentitySources + } + return json.Marshal(objectMap) +} + +// PrivateCloudsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsCreateOrUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.CreateOrUpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsDeleteFuture) Result(client PrivateCloudsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.UpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudUpdate an update to a private cloud resource +type PrivateCloudUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // PrivateCloudUpdateProperties - The updatable properties of a private cloud resource + *PrivateCloudUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloudUpdate. +func (pcu PrivateCloudUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pcu.Tags != nil { + objectMap["tags"] = pcu.Tags + } + if pcu.PrivateCloudUpdateProperties != nil { + objectMap["properties"] = pcu.PrivateCloudUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloudUpdate struct. +func (pcu *PrivateCloudUpdate) 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 + } + pcu.Tags = tags + } + case "properties": + if v != nil { + var privateCloudUpdateProperties PrivateCloudUpdateProperties + err = json.Unmarshal(*v, &privateCloudUpdateProperties) + if err != nil { + return err + } + pcu.PrivateCloudUpdateProperties = &privateCloudUpdateProperties + } + } + } + + return nil +} + +// PrivateCloudUpdateProperties the properties of a private cloud resource that may be updated +type PrivateCloudUpdateProperties struct { + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// Quota subscription quotas +type Quota struct { + autorest.Response `json:"-"` + // HostsRemaining - READ-ONLY; Remaining hosts quota by sku type + HostsRemaining map[string]*int32 `json:"hostsRemaining"` + // QuotaEnabled - READ-ONLY; Host quota is active for current subscription. Possible values include: 'QuotaEnabledEnabled', 'QuotaEnabledDisabled' + QuotaEnabled QuotaEnabled `json:"quotaEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for Quota. +func (q Quota) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource the core properties of ARM resources +type Resource struct { + // 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"` +} + +// Sku the resource model definition representing SKU +type Sku struct { + // Name - The name of the SKU. + Name *string `json:"name,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // 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"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// Trial subscription trial availability +type Trial struct { + autorest.Response `json:"-"` + // Status - READ-ONLY; Trial status. Possible values include: 'TrialAvailable', 'TrialUsed', 'TrialDisabled' + Status TrialStatus `json:"status,omitempty"` + // AvailableHosts - READ-ONLY; Number of trial hosts available + AvailableHosts *int32 `json:"availableHosts,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go new file mode 100644 index 000000000000..765297556ad5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go @@ -0,0 +1,149 @@ +package avs + +// 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/tracing" + "net/http" +) + +// OperationsClient is the azure VMware Solution API +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure responding to request") + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AVS/operations"), + 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 OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.OperationsClient", "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, "avs.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go new file mode 100644 index 000000000000..82af8e23b5ba --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go @@ -0,0 +1,719 @@ +package avs + +// 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" +) + +// PrivateCloudsClient is the azure VMware Solution API +type PrivateCloudsClient struct { + BaseClient +} + +// NewPrivateCloudsClient creates an instance of the PrivateCloudsClient client. +func NewPrivateCloudsClient(subscriptionID string) PrivateCloudsClient { + return NewPrivateCloudsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateCloudsClientWithBaseURI creates an instance of the PrivateCloudsClient 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 NewPrivateCloudsClientWithBaseURI(baseURI string, subscriptionID string) PrivateCloudsClient { + return PrivateCloudsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloud - the private cloud +func (client PrivateCloudsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (result PrivateCloudsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, + {TargetValue: privateCloud, + Constraints: []validation.Constraint{{Target: "privateCloud.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateCloud.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "privateCloud.PrivateCloudProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateCloud.PrivateCloudProperties.NetworkBlock", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloud) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateCloudsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloud), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) CreateOrUpdateSender(req *http.Request) (future PrivateCloudsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateCloud, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateCloudsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) DeleteSender(req *http.Request) (future PrivateCloudsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloud, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateCloudsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) 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 PrivateCloudsClient) GetResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateCloudsClient) List(ctx context.Context, resourceGroupName string) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.List") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure responding to request") + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateCloudsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds", 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 PrivateCloudsClient) 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 PrivateCloudsClient) ListResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "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, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListComplete(ctx context.Context, resourceGroupName string) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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) + return +} + +// ListAdminCredentials sends the list admin credentials request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result AdminCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListAdminCredentials") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "ListAdminCredentials", err.Error()) + } + + req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListAdminCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListAdminCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure responding to request") + } + + return +} + +// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. +func (client PrivateCloudsClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListAdminCredentialsResponder(resp *http.Response) (result AdminCredentials, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListInSubscription sends the list in subscription request. +func (client PrivateCloudsClient) ListInSubscription(ctx context.Context) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "ListInSubscription", err.Error()) + } + + result.fn = client.listInSubscriptionNextResults + req, err := client.ListInSubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure responding to request") + } + if result.pcl.hasNextLink() && result.pcl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListInSubscriptionPreparer prepares the ListInSubscription request. +func (client PrivateCloudsClient) ListInSubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInSubscriptionSender sends the ListInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInSubscriptionResponder handles the response to the ListInSubscription request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListInSubscriptionResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInSubscriptionNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listInSubscriptionNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListInSubscriptionComplete(ctx context.Context) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + 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.ListInSubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloudUpdate - the private cloud properties to be updated +func (client PrivateCloudsClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (result PrivateCloudsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloudUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateCloudsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + 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.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloudUpdate), + 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 PrivateCloudsClient) UpdateSender(req *http.Request) (future PrivateCloudsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) UpdateResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go new file mode 100644 index 000000000000..23307592c097 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go @@ -0,0 +1,30 @@ +package avs + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " avs/2020-03-20" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} From b2fcebd3b20e408d91e234491a03f5d1f3094fa1 Mon Sep 17 00:00:00 2001 From: yupwei68 Date: Wed, 12 Aug 2020 14:33:37 +0800 Subject: [PATCH 02/23] update --- azurerm/internal/provider/services.go | 2 + .../avs/avs_private_clouds_data_source.go | 95 +- .../avs/avs_private_clouds_resource.go | 1142 +++--- .../internal/services/avs/client/client.go | 32 +- .../services/avs/parse/avs_authorizations.go | 32 - .../avs/parse/avs_authorizations_test.go | 77 - .../services/avs/parse/avs_clusters.go | 33 - .../services/avs/parse/avs_clusters_test.go | 77 - .../avs/parse/avs_hcx_enterprise_sites.go | 33 - .../parse/avs_hcx_enterprise_sites_test.go | 77 - .../services/avs/parse/avs_private_clouds.go | 37 +- .../avs/parse/avs_private_clouds_test.go | 122 +- azurerm/internal/services/avs/registration.go | 26 +- .../avs_private_clouds_data_source_test.go | 41 +- .../tests/avs_private_clouds_resource_test.go | 592 +-- .../avs/mgmt/2020-03-20/avs/authorizations.go | 861 ++-- .../mgmt/2020-03-20/avs/avsapi/interfaces.go | 89 - .../avs/mgmt/2020-03-20/avs/client.go | 104 +- .../avs/mgmt/2020-03-20/avs/clusters.go | 1049 +++-- .../mgmt/2020-03-20/avs/hcxenterprisesites.go | 863 ++-- .../avs/mgmt/2020-03-20/avs/locations.go | 402 +- .../avs/mgmt/2020-03-20/avs/models.go | 3592 +++++++++-------- .../avs/mgmt/2020-03-20/avs/operations.go | 295 +- .../avs/mgmt/2020-03-20/avs/privateclouds.go | 1432 ++++--- .../avs/mgmt/2020-03-20/avs/version.go | 60 +- .../autorest/azure/environments.go | 8 +- vendor/modules.txt | 1 + 27 files changed, 5410 insertions(+), 5764 deletions(-) delete mode 100644 azurerm/internal/services/avs/parse/avs_authorizations.go delete mode 100644 azurerm/internal/services/avs/parse/avs_authorizations_test.go delete mode 100644 azurerm/internal/services/avs/parse/avs_clusters.go delete mode 100644 azurerm/internal/services/avs/parse/avs_clusters_test.go delete mode 100644 azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go delete mode 100644 azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index 49a3b4c9946f..278a8b64f3d4 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -9,6 +9,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appplatform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/authorization" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/automation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/batch" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/blueprints" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/bot" @@ -92,6 +93,7 @@ func SupportedServices() []common.ServiceRegistration { applicationinsights.Registration{}, authorization.Registration{}, automation.Registration{}, + avs.Registration{}, batch.Registration{}, blueprints.Registration{}, bot.Registration{}, diff --git a/azurerm/internal/services/avs/avs_private_clouds_data_source.go b/azurerm/internal/services/avs/avs_private_clouds_data_source.go index f17087e87cf8..dc374d2c247e 100644 --- a/azurerm/internal/services/avs/avs_private_clouds_data_source.go +++ b/azurerm/internal/services/avs/avs_private_clouds_data_source.go @@ -1,61 +1,62 @@ package avs import ( - "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "time" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "time" ) + func dataSourceAvsPrivateCloud() *schema.Resource { - return &schema.Resource{ - Read: dataSourceArmAvsPrivateCloudRead, + return &schema.Resource{ + Read: dataSourceArmAvsPrivateCloudRead, - Timeouts: &schema.ResourceTimeout{ - Read: schema.DefaultTimeout(5 * time.Minute), - }, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(5 * time.Minute), + }, - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, - "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), - "location": azure.SchemaLocationForDataSource(), + "location": azure.SchemaLocationForDataSource(), - "tags": tags.SchemaDataSource(), - }, - } + "tags": tags.SchemaDataSource(), + }, + } } func dataSourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Avs.PrivateCloudClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - - resp, err :=client.Get(ctx, resourceGroup, name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Avs PrivateCloud %q does not exist", name) - } - return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) - } - if resp.ID == nil || *resp.ID== "" { - return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) - } - - d.SetId(*resp.ID) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("location", location.NormalizeNilable(resp.Location)) - return tags.FlattenAndSet(d, resp.Tags) + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Avs PrivateCloud %q does not exist", name) + } + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + if resp.ID == nil || *resp.ID == "" { + return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*resp.ID) + d.Set("name", name) + d.Set("resource_group_name", resourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + return tags.FlattenAndSet(d, resp.Tags) } diff --git a/azurerm/internal/services/avs/avs_private_clouds_resource.go b/azurerm/internal/services/avs/avs_private_clouds_resource.go index a8fa54c1bf00..42e97f9cfeae 100644 --- a/azurerm/internal/services/avs/avs_private_clouds_resource.go +++ b/azurerm/internal/services/avs/avs_private_clouds_resource.go @@ -1,630 +1,570 @@ package avs import ( - "fmt" - "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" - azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "log" - "time" + "fmt" + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "log" + "time" ) + func resourceArmAvsPrivateCloud() *schema.Resource { - return &schema.Resource{ - Create: resourceArmAvsPrivateCloudCreate, - Read: resourceArmAvsPrivateCloudRead, - Update: resourceArmAvsPrivateCloudUpdate, - Delete: resourceArmAvsPrivateCloudDelete, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), - Read: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), - }, - - Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { - _, err := parse.AvsPrivateCloudID(id) - return err - }), - - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "resource_group_name": azure.SchemaResourceGroupName(), - - "location": azure.SchemaLocation(), - - "sku": { - Type: schema.TypeList, - Required: true, - ForceNew: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - }, - }, - - "management_cluster": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cluster_size": { - Type: schema.TypeInt, - Required: true, - }, - - "cluster_id": { - Type: schema.TypeInt, - Computed: true, - }, - - "hosts": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - - "network_block": { - Type: schema.TypeString, - Required: true, - }, - - "circuit": { - Type: schema.TypeList, - Computed: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "express_route_id": { - Type: schema.TypeString, - Computed: true, - }, - - "express_route_private_peering_id": { - Type: schema.TypeString, - Computed: true, - }, - - "primary_subnet": { - Type: schema.TypeString, - Computed: true, - }, - - "secondary_subnet": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - - "identity_source": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - }, - - "alias": { - Type: schema.TypeString, - Optional: true, - }, - - "base_group_dn": { - Type: schema.TypeString, - Optional: true, - }, - - "base_user_dn": { - Type: schema.TypeString, - Optional: true, - }, - - "domain": { - Type: schema.TypeString, - Optional: true, - }, - - "password": { - Type: schema.TypeString, - Optional: true, - }, - - "primary_server": { - Type: schema.TypeString, - Optional: true, - }, - - "secondary_server": { - Type: schema.TypeString, - Optional: true, - }, - - "ssl": { - Type: schema.TypeBool, - Optional: true, - }, - - "username": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - - "internet": { - Type: schema.TypeBool, - Optional: true, - }, - - "nsxt_password": { - Type: schema.TypeString, - Optional: true, - }, - - "vcenter_password": { - Type: schema.TypeString, - Optional: true, - }, - - "endpoint": { - Type: schema.TypeList, - Computed: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "hcx_cloud_manager": { - Type: schema.TypeString, - Computed: true, - }, - - "nsxt_manager": { - Type: schema.TypeString, - Computed: true, - }, - - "vcsa": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - - "management_network": { - Type: schema.TypeString, - Computed: true, - }, - - "nsxt_certificate_thumbprint": { - Type: schema.TypeString, - Computed: true, - }, - - "provisioning_network": { - Type: schema.TypeString, - Computed: true, - }, - - "type": { - Type: schema.TypeString, - Computed: true, - }, - - "vcenter_certificate_thumbprint": { - Type: schema.TypeString, - Computed: true, - }, - - "vmotion_network": { - Type: schema.TypeString, - Computed: true, - }, - - "tags": tags.Schema(), - }, - } + return &schema.Resource{ + Create: resourceArmAvsPrivateCloudCreate, + Read: resourceArmAvsPrivateCloudRead, + Update: resourceArmAvsPrivateCloudUpdate, + Delete: resourceArmAvsPrivateCloudDelete, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.AvsPrivateCloudID(id) + return err + }), + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "sku_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "av20", + "av36", + "av36t", + }, true), + DiffSuppressFunc: suppress.CaseDifference, + }, + + "management_cluster": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_size": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(3, 16), + }, + + "cluster_id": { + Type: schema.TypeInt, + Computed: true, + }, + + "hosts": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + + "network_block": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.IsCIDR, + }, + + "identity_source": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "alias": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "base_group_dn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "base_user_dn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "domain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "password": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "primary_server_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsURLWithHTTPorHTTPS, + }, + + "secondary_server_url": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.IsURLWithHTTPorHTTPS, + }, + + "ssl_enabled": { + Type: schema.TypeBool, + Required: true, + }, + + "username": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + + "internet_connected": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "nsxt_password": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "vcenter_password": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "circuit": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "express_route_id": { + Type: schema.TypeString, + Computed: true, + }, + + "express_route_private_peering_id": { + Type: schema.TypeString, + Computed: true, + }, + + "primary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + + "secondary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "hcx_cloud_manager_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "management_network": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_manager_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "provisioning_network": { + Type: schema.TypeString, + Computed: true, + }, + + "vcenter_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "vcsa_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "vmotion_network": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tags.Schema(), + }, + } } func resourceArmAvsPrivateCloudCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Avs.PrivateCloudClient - ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) - defer cancel() - - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - - existing, err :=client.Get(ctx, resourceGroup, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for present of existing Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) - } - } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_avs_private_cloud", *existing.ID) - } - - internet := avs.Disabled - if d.Get("internet").(bool) { - internet = avs.Enabled - } - - privateCloud := avs.PrivateCloud{ - Location: utils.String(location.Normalize(d.Get("location").(string))), - Sku: expandArmPrivateCloudSku(d.Get("sku").([]interface{})), - PrivateCloudProperties: &avs.PrivateCloudProperties{ - ManagementCluster: expandArmPrivateCloudManagementCluster(d.Get("management_cluster").([]interface{})), - NetworkBlock: utils.String(d.Get("network_block").(string)), - IdentitySources: expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()), - Internet: internet, - NsxtPassword: utils.String(d.Get("nsxt_password").(string)), - VcenterPassword: utils.String(d.Get("vcenter_password").(string)), - }, - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), - } - future, err :=client.CreateOrUpdate(ctx, resourceGroup, name, privateCloud) - if err != nil { - return fmt.Errorf("creating Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on creating future for Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - resp, err :=client.Get(ctx, resourceGroup, name) - if err != nil { - return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - if resp.ID == nil || *resp.ID== "" { - return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) - } - - d.SetId(*resp.ID) - return resourceArmAvsPrivateCloudRead(d, meta) + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + + existing, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for present of existing Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + } + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_avs_private_cloud", *existing.ID) + } + + internet := avs.Disabled + if d.Get("internet_connected").(bool) { + internet = avs.Enabled + } + + privateCloud := avs.PrivateCloud{ + Location: utils.String(location.Normalize(d.Get("location").(string))), + Sku: &avs.Sku{ + Name: utils.String(d.Get("sku_name").(string)), + }, + PrivateCloudProperties: &avs.PrivateCloudProperties{ + ManagementCluster: &avs.ManagementCluster{ + ClusterSize: utils.Int32(int32(d.Get("management_cluster.0.cluster_size").(int))), + }, + NetworkBlock: utils.String(d.Get("network_block").(string)), + IdentitySources: expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()), + Internet: internet, + NsxtPassword: utils.String(d.Get("nsxt_password").(string)), + VcenterPassword: utils.String(d.Get("vcenter_password").(string)), + }, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + future, err := client.CreateOrUpdate(ctx, resourceGroup, name, privateCloud) + if err != nil { + return fmt.Errorf("creating Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on creating future for Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if resp.ID == nil || *resp.ID == "" { + return fmt.Errorf("empty or nil ID returned for Avs PrivateCloud %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*resp.ID) + return resourceArmAvsPrivateCloudRead(d, meta) } func resourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Avs.PrivateCloudClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.AvsPrivateCloudID(d.Id()) - if err != nil { - return err - } - - resp, err :=client.Get(ctx, id.ResourceGroup, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] avs %q does not exist - removing from state", d.Id()) - d.SetId("") - return nil - } - return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("location", location.NormalizeNilable(resp.Location)) - if props := resp.PrivateCloudProperties; props != nil { - if err := d.Set("management_cluster", flattenArmPrivateCloudManagementCluster(props.ManagementCluster)); err != nil { - return fmt.Errorf("setting `management_cluster`: %+v", err) - } - d.Set("network_block", props.NetworkBlock) - if err := d.Set("circuit", flattenArmPrivateCloudCircuit(props.Circuit)); err != nil { - return fmt.Errorf("setting `circuit`: %+v", err) - } - if err := d.Set("identity_source", flattenArmPrivateCloudIdentitySourceArray(props.IdentitySources)); err != nil { - return fmt.Errorf("setting `identity_source`: %+v", err) - } - d.Set("internet", props.Internet==avs.Enabled) - d.Set("nsxt_password", props.NsxtPassword) - d.Set("vcenter_password", props.VcenterPassword) - if err := d.Set("endpoint", flattenArmPrivateCloudEndpoints(props.Endpoints)); err != nil { - return fmt.Errorf("setting `endpoint`: %+v", err) - } - d.Set("management_network", props.ManagementNetwork) - d.Set("nsxt_certificate_thumbprint", props.NsxtCertificateThumbprint) - d.Set("provisioning_network", props.ProvisioningNetwork) - d.Set("vcenter_certificate_thumbprint", props.VcenterCertificateThumbprint) - d.Set("vmotion_network", props.VmotionNetwork) - } - if err := d.Set("sku", flattenArmPrivateCloudSku(resp.Sku)); err != nil { - return fmt.Errorf("setting `sku`: %+v", err) - } - d.Set("type", resp.Type) - return tags.FlattenAndSet(d, resp.Tags) + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] avs %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil + } + return fmt.Errorf("retrieving Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + if props := resp.PrivateCloudProperties; props != nil { + if err := d.Set("management_cluster", flattenArmPrivateCloudManagementCluster(props.ManagementCluster)); err != nil { + return fmt.Errorf("setting `management_cluster`: %+v", err) + } + d.Set("network_block", props.NetworkBlock) + if err := d.Set("circuit", flattenArmPrivateCloudCircuit(props.Circuit)); err != nil { + return fmt.Errorf("setting `circuit`: %+v", err) + } + if err := d.Set("identity_source", flattenArmPrivateCloudIdentitySourceArray(props.IdentitySources)); err != nil { + return fmt.Errorf("setting `identity_source`: %+v", err) + } + d.Set("internet_connected", props.Internet == avs.Enabled) + d.Set("nsxt_password", props.NsxtPassword) + d.Set("vcenter_password", props.VcenterPassword) + d.Set("hcx_cloud_manager_endpoint", props.Endpoints.HcxCloudManager) + d.Set("nsxt_manager_endpoint", props.Endpoints.NsxtManager) + d.Set("vcsa_endpoint", props.Endpoints.Vcsa) + d.Set("management_network", props.ManagementNetwork) + d.Set("nsxt_certificate_thumbprint", props.NsxtCertificateThumbprint) + d.Set("provisioning_network", props.ProvisioningNetwork) + d.Set("vcenter_certificate_thumbprint", props.VcenterCertificateThumbprint) + d.Set("vmotion_network", props.VmotionNetwork) + } + d.Set("sku_name", resp.Sku.Name) + return tags.FlattenAndSet(d, resp.Tags) } func resourceArmAvsPrivateCloudUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Avs.PrivateCloudClient - ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.AvsPrivateCloudID(d.Id()) - if err != nil { - return err - } - - privateCloudUpdate := avs.PrivateCloudUpdate{ - PrivateCloudUpdateProperties: &avs.PrivateCloudUpdateProperties{ - }, - } - if d.HasChange("management_cluster") { - privateCloudUpdate.PrivateCloudUpdateProperties.ManagementCluster = expandArmPrivateCloudManagementCluster(d.Get("management_cluster").([]interface{})) - } - if d.HasChange("internet") { - internet := avs.Disabled - if d.Get("internet").(bool) { - internet = avs.Enabled - } - privateCloudUpdate.PrivateCloudUpdateProperties.Internet = internet - } - if d.HasChange("identity_source") { - privateCloudUpdate.PrivateCloudUpdateProperties.IdentitySources = expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()) - } - if d.HasChange("tags") { - privateCloudUpdate.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) - } - - future, err :=client.Update(ctx, id.ResourceGroup, id.Name, privateCloudUpdate) - if err != nil { - return fmt.Errorf("updating Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on updating future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - return resourceArmAvsPrivateCloudRead(d, meta) + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + privateCloudUpdate := avs.PrivateCloudUpdate{ + PrivateCloudUpdateProperties: &avs.PrivateCloudUpdateProperties{}, + } + if d.HasChange("management_cluster") { + privateCloudUpdate.PrivateCloudUpdateProperties.ManagementCluster = &avs.ManagementCluster{ + ClusterSize: utils.Int32(int32(d.Get("management_cluster.0.cluster_size").(int))), + } + } + if d.HasChange("internet_connected") { + internet := avs.Disabled + if d.Get("internet").(bool) { + internet = avs.Enabled + } + privateCloudUpdate.PrivateCloudUpdateProperties.Internet = internet + } + if d.HasChange("identity_source") { + privateCloudUpdate.PrivateCloudUpdateProperties.IdentitySources = expandArmPrivateCloudIdentitySourceArray(d.Get("identity_source").(*schema.Set).List()) + } + if d.HasChange("tags") { + privateCloudUpdate.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) + } + + future, err := client.Update(ctx, id.ResourceGroup, id.Name, privateCloudUpdate) + if err != nil { + return fmt.Errorf("updating Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on updating future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + return resourceArmAvsPrivateCloudRead(d, meta) } func resourceArmAvsPrivateCloudDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Avs.PrivateCloudClient - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.AvsPrivateCloudID(d.Id()) - if err != nil { - return err - } - - future, err :=client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { - return fmt.Errorf("deleting Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on deleting future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - return nil -} - -func expandArmPrivateCloudSku(input []interface{}) *avs.Sku { - if len(input) == 0 { - return nil - } - v := input[0].(map[string]interface{}) - return &avs.Sku{ - Name: utils.String(v["name"].(string)), - } -} - -func expandArmPrivateCloudManagementCluster(input []interface{}) *avs.ManagementCluster { - if len(input) == 0 { - return nil - } - v := input[0].(map[string]interface{}) - return &avs.ManagementCluster{ - ClusterSize: utils.Int32(int32(v["cluster_size"].(int))), - } + client := meta.(*clients.Client).Avs.PrivateCloudClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AvsPrivateCloudID(d.Id()) + if err != nil { + return err + } + + future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("deleting Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting on deleting future for Avs PrivateCloud %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + return nil } func expandArmPrivateCloudIdentitySourceArray(input []interface{}) *[]avs.IdentitySource { - results := make([]avs.IdentitySource, 0) - for _, item := range input { - v := item.(map[string]interface{}) - sSL := avs.SslEnumDisabled - if v["ssl"].(bool) { - sSL = avs.SslEnumEnabled - } - result := avs.IdentitySource{ - Name: utils.String(v["name"].(string)), - Alias: utils.String(v["alias"].(string)), - Domain: utils.String(v["domain"].(string)), - BaseUserDN: utils.String(v["base_user_dn"].(string)), - BaseGroupDN: utils.String(v["base_group_dn"].(string)), - PrimaryServer: utils.String(v["primary_server"].(string)), - SecondaryServer: utils.String(v["secondary_server"].(string)), - Ssl: sSL, - Username: utils.String(v["username"].(string)), - Password: utils.String(v["password"].(string)), - } - results = append(results, result) - } - return &results + results := make([]avs.IdentitySource, 0) + for _, item := range input { + v := item.(map[string]interface{}) + sSL := avs.SslEnumDisabled + if v["ssl"].(bool) { + sSL = avs.SslEnumEnabled + } + result := avs.IdentitySource{ + Name: utils.String(v["name"].(string)), + Alias: utils.String(v["alias"].(string)), + Domain: utils.String(v["domain"].(string)), + BaseUserDN: utils.String(v["base_user_dn"].(string)), + BaseGroupDN: utils.String(v["base_group_dn"].(string)), + PrimaryServer: utils.String(v["primary_server_url"].(string)), + SecondaryServer: utils.String(v["secondary_server_url"].(string)), + Ssl: sSL, + Username: utils.String(v["username"].(string)), + Password: utils.String(v["password"].(string)), + } + results = append(results, result) + } + return &results } func flattenArmPrivateCloudManagementCluster(input *avs.ManagementCluster) []interface{} { - if input == nil { - return make([]interface{}, 0) - } - - var clusterSize int32 - if input.ClusterSize != nil { - clusterSize = *input.ClusterSize - } - var clusterId int32 - if input.ClusterID != nil { - clusterId = *input.ClusterID - } - return []interface{}{ - map[string]interface{}{ - "cluster_size": clusterSize, - "cluster_id": clusterId, - "hosts": utils.FlattenStringSlice(input.Hosts), - }, - } + if input == nil { + return make([]interface{}, 0) + } + + var clusterSize int32 + if input.ClusterSize != nil { + clusterSize = *input.ClusterSize + } + var clusterId int32 + if input.ClusterID != nil { + clusterId = *input.ClusterID + } + return []interface{}{ + map[string]interface{}{ + "cluster_size": clusterSize, + "cluster_id": clusterId, + "hosts": utils.FlattenStringSlice(input.Hosts), + }, + } } func flattenArmPrivateCloudCircuit(input *avs.Circuit) []interface{} { - if input == nil { - return make([]interface{}, 0) - } - - var expressRouteId string - if input.ExpressRouteID != nil { - expressRouteId = *input.ExpressRouteID - } - var expressRoutePrivatePeeringId string - if input.ExpressRoutePrivatePeeringID != nil { - expressRoutePrivatePeeringId = *input.ExpressRoutePrivatePeeringID - } - var primarySubnet string - if input.PrimarySubnet != nil { - primarySubnet = *input.PrimarySubnet - } - var secondarySubnet string - if input.SecondarySubnet != nil { - secondarySubnet = *input.SecondarySubnet - } - return []interface{}{ - map[string]interface{}{ - "express_route_id": expressRouteId, - "express_route_private_peering_id": expressRoutePrivatePeeringId, - "primary_subnet": primarySubnet, - "secondary_subnet": secondarySubnet, - }, - } + if input == nil { + return make([]interface{}, 0) + } + + var expressRouteId string + if input.ExpressRouteID != nil { + expressRouteId = *input.ExpressRouteID + } + var expressRoutePrivatePeeringId string + if input.ExpressRoutePrivatePeeringID != nil { + expressRoutePrivatePeeringId = *input.ExpressRoutePrivatePeeringID + } + var primarySubnet string + if input.PrimarySubnet != nil { + primarySubnet = *input.PrimarySubnet + } + var secondarySubnet string + if input.SecondarySubnet != nil { + secondarySubnet = *input.SecondarySubnet + } + return []interface{}{ + map[string]interface{}{ + "express_route_id": expressRouteId, + "express_route_private_peering_id": expressRoutePrivatePeeringId, + "primary_subnet": primarySubnet, + "secondary_subnet": secondarySubnet, + }, + } } func flattenArmPrivateCloudIdentitySourceArray(input *[]avs.IdentitySource) []interface{} { - results := make([]interface{}, 0) - if input == nil { - return results - } - - for _, item := range *input { - var name string - if item.Name != nil { - name = *item.Name - } - var alias string - if item.Alias != nil { - alias = *item.Alias - } - var baseGroupDn string - if item.BaseGroupDN != nil { - baseGroupDn = *item.BaseGroupDN - } - var baseUserDn string - if item.BaseUserDN != nil { - baseUserDn = *item.BaseUserDN - } - var domain string - if item.Domain != nil { - domain = *item.Domain - } - var password string - if item.Password != nil { - password = *item.Password - } - var primaryServer string - if item.PrimaryServer != nil { - primaryServer = *item.PrimaryServer - } - var secondaryServer string - if item.SecondaryServer != nil { - secondaryServer = *item.SecondaryServer - } - sSL := item.Ssl==avs.SslEnumEnabled - var username string - if item.Username != nil { - username = *item.Username - } - v := map[string]interface{}{ - "name": name, - "alias": alias, - "base_group_dn": baseGroupDn, - "base_user_dn": baseUserDn, - "domain": domain, - "password": password, - "primary_server": primaryServer, - "secondary_server": secondaryServer, - "ssl": sSL, - "username": username, - } - results = append(results, v) - } - return results -} - -func flattenArmPrivateCloudEndpoints(input *avs.Endpoints) []interface{} { - if input == nil { - return make([]interface{}, 0) - } - - var hcxCloudManager string - if input.HcxCloudManager != nil { - hcxCloudManager = *input.HcxCloudManager - } - var nsxtManager string - if input.NsxtManager != nil { - nsxtManager = *input.NsxtManager - } - var vcsa string - if input.Vcsa != nil { - vcsa = *input.Vcsa - } - return []interface{}{ - map[string]interface{}{ - "hcx_cloud_manager": hcxCloudManager, - "nsxt_manager": nsxtManager, - "vcsa": vcsa, - }, - } -} - -func flattenArmPrivateCloudSku(input *avs.Sku) []interface{} { - if input == nil { - return make([]interface{}, 0) - } - - var name string - if input.Name != nil { - name = *input.Name - } - return []interface{}{ - map[string]interface{}{ - "name": name, - }, - } + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, item := range *input { + var name string + if item.Name != nil { + name = *item.Name + } + var alias string + if item.Alias != nil { + alias = *item.Alias + } + var baseGroupDn string + if item.BaseGroupDN != nil { + baseGroupDn = *item.BaseGroupDN + } + var baseUserDn string + if item.BaseUserDN != nil { + baseUserDn = *item.BaseUserDN + } + var domain string + if item.Domain != nil { + domain = *item.Domain + } + var password string + if item.Password != nil { + password = *item.Password + } + var primaryServer string + if item.PrimaryServer != nil { + primaryServer = *item.PrimaryServer + } + var secondaryServer string + if item.SecondaryServer != nil { + secondaryServer = *item.SecondaryServer + } + sSL := item.Ssl == avs.SslEnumEnabled + var username string + if item.Username != nil { + username = *item.Username + } + v := map[string]interface{}{ + "name": name, + "alias": alias, + "base_group_dn": baseGroupDn, + "base_user_dn": baseUserDn, + "domain": domain, + "password": password, + "primary_server_url": primaryServer, + "secondary_server_url": secondaryServer, + "ssl_enabled": sSL, + "username": username, + } + results = append(results, v) + } + return results } diff --git a/azurerm/internal/services/avs/client/client.go b/azurerm/internal/services/avs/client/client.go index dff68a01c8c5..ca0362e7231b 100644 --- a/azurerm/internal/services/avs/client/client.go +++ b/azurerm/internal/services/avs/client/client.go @@ -1,33 +1,19 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) + type Client struct { - PrivateCloudClient *avs.PrivateCloudsClient - ClusterClient *avs.ClustersClient - HcxEnterpriseSiteClient *avs.HcxEnterpriseSitesClient - AuthorizationClient *avs.AuthorizationsClient + PrivateCloudClient *avs.PrivateCloudsClient } func NewClient(o *common.ClientOptions) *Client { - privateCloudClient := avs.NewPrivateCloudsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&privateCloudClient.Client, o.ResourceManagerAuthorizer) - - clusterClient := avs.NewClustersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&clusterClient.Client, o.ResourceManagerAuthorizer) - - hcxEnterpriseSiteClient := avs.NewHcxEnterpriseSitesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&hcxEnterpriseSiteClient.Client, o.ResourceManagerAuthorizer) - - authorizationClient := avs.NewAuthorizationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&authorizationClient.Client, o.ResourceManagerAuthorizer) + privateCloudClient := avs.NewPrivateCloudsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&privateCloudClient.Client, o.ResourceManagerAuthorizer) - return &Client{ - PrivateCloudClient: &privateCloudClient, - ClusterClient: &clusterClient, - HcxEnterpriseSiteClient: &hcxEnterpriseSiteClient, - AuthorizationClient: &authorizationClient, - } + return &Client{ + PrivateCloudClient: &privateCloudClient, + } } diff --git a/azurerm/internal/services/avs/parse/avs_authorizations.go b/azurerm/internal/services/avs/parse/avs_authorizations.go deleted file mode 100644 index 2a731776e466..000000000000 --- a/azurerm/internal/services/avs/parse/avs_authorizations.go +++ /dev/null @@ -1,32 +0,0 @@ -package parse -import ( - "fmt" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" -) -type AvsAuthorizationId struct { - ResourceGroup string - PrivateCloudName string - Name string -} - -func AvsAuthorizationID(input string) (*AvsAuthorizationId, error) { - id, err := azure.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing avsAuthorization ID %q: %+v", input, err) - } - - avsAuthorization := AvsAuthorizationId{ - ResourceGroup: id.ResourceGroup, - } - if avsAuthorization.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { - return nil, err - } - if avsAuthorization.Name, err = id.PopSegment("authorizations"); err != nil { - return nil, err - } - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &avsAuthorization, nil -} diff --git a/azurerm/internal/services/avs/parse/avs_authorizations_test.go b/azurerm/internal/services/avs/parse/avs_authorizations_test.go deleted file mode 100644 index 92aa90a0119c..000000000000 --- a/azurerm/internal/services/avs/parse/avs_authorizations_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package parse - -import ( - "testing" -) - -func TestAvsAuthorizationID(t *testing.T) { - testData := []struct { - Name string - Input string - Expected *AvsAuthorizationId - }{ - { - Name: "Empty", - Input: "", - Expected: nil, - }, - { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, - }, - { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, - }, - { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, - }, - { - Name: "Missing Authorization Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations", - Expected: nil, - }, - { - Name: "avs Authorization ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/authorization1", - Expected: &AvsAuthorizationId{ - ResourceGroup:"resourceGroup1", - PrivateCloudName:"privateCloud1", - Name:"authorization1", - }, - }, - { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/Authorizations/authorization1", - Expected: nil, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) - - actual, err := AvsAuthorizationID(v.Input) - if err != nil { - if v.Expected == nil { - continue - } - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - - if actual.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/azurerm/internal/services/avs/parse/avs_clusters.go b/azurerm/internal/services/avs/parse/avs_clusters.go deleted file mode 100644 index baa1b08c9e4d..000000000000 --- a/azurerm/internal/services/avs/parse/avs_clusters.go +++ /dev/null @@ -1,33 +0,0 @@ -package parse - -import ( - "fmt" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" -) -type AvsClusterId struct { - ResourceGroup string - PrivateCloudName string - Name string -} - -func AvsClusterID(input string) (*AvsClusterId, error) { - id, err := azure.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing avsCluster ID %q: %+v", input, err) - } - - avsCluster := AvsClusterId{ - ResourceGroup: id.ResourceGroup, - } - if avsCluster.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { - return nil, err - } - if avsCluster.Name, err = id.PopSegment("clusters"); err != nil { - return nil, err - } - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &avsCluster, nil -} diff --git a/azurerm/internal/services/avs/parse/avs_clusters_test.go b/azurerm/internal/services/avs/parse/avs_clusters_test.go deleted file mode 100644 index 15ad350cdf91..000000000000 --- a/azurerm/internal/services/avs/parse/avs_clusters_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package parse - -import ( - "testing" -) - -func TestAvsClusterID(t *testing.T) { - testData := []struct { - Name string - Input string - Expected *AvsClusterId - }{ - { - Name: "Empty", - Input: "", - Expected: nil, - }, - { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, - }, - { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, - }, - { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, - }, - { - Name: "Missing Cluster Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters", - Expected: nil, - }, - { - Name: "avs Cluster ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters/cluster1", - Expected: &AvsClusterId{ - ResourceGroup:"resourceGroup1", - PrivateCloudName:"privateCloud1", - Name:"cluster1", - }, - }, - { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/Clusters/cluster1", - Expected: nil, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) - - actual, err := AvsClusterID(v.Input) - if err != nil { - if v.Expected == nil { - continue - } - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - - if actual.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go deleted file mode 100644 index a6dbc043d15a..000000000000 --- a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites.go +++ /dev/null @@ -1,33 +0,0 @@ -package parse - -import ( - "fmt" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" -) -type AvsHcxEnterpriseSiteId struct { - ResourceGroup string - PrivateCloudName string - Name string -} - -func AvsHcxEnterpriseSiteID(input string) (*AvsHcxEnterpriseSiteId, error) { - id, err := azure.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing avsHcxEnterpriseSite ID %q: %+v", input, err) - } - - avsHcxEnterpriseSite := AvsHcxEnterpriseSiteId{ - ResourceGroup: id.ResourceGroup, - } - if avsHcxEnterpriseSite.PrivateCloudName, err = id.PopSegment("privateClouds"); err != nil { - return nil, err - } - if avsHcxEnterpriseSite.Name, err = id.PopSegment("hcxEnterpriseSites"); err != nil { - return nil, err - } - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &avsHcxEnterpriseSite, nil -} diff --git a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go b/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go deleted file mode 100644 index 446154273fe2..000000000000 --- a/azurerm/internal/services/avs/parse/avs_hcx_enterprise_sites_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package parse - -import ( - "testing" -) - -func TestAvsHcxEnterpriseSiteID(t *testing.T) { - testData := []struct { - Name string - Input string - Expected *AvsHcxEnterpriseSiteId - }{ - { - Name: "Empty", - Input: "", - Expected: nil, - }, - { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, - }, - { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, - }, - { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, - }, - { - Name: "Missing HcxEnterpriseSite Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites", - Expected: nil, - }, - { - Name: "avs HcxEnterpriseSite ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites/hcxEnterpriseSite1", - Expected: &AvsHcxEnterpriseSiteId{ - ResourceGroup:"resourceGroup1", - PrivateCloudName:"privateCloud1", - Name:"hcxEnterpriseSite1", - }, - }, - { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1/HcxEnterpriseSites/hcxEnterpriseSite1", - Expected: nil, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) - - actual, err := AvsHcxEnterpriseSiteID(v.Input) - if err != nil { - if v.Expected == nil { - continue - } - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - - if actual.PrivateCloudName != v.Expected.PrivateCloudName { - t.Fatalf("Expected %q but got %q for PrivateCloudName", v.Expected.PrivateCloudName, actual.PrivateCloudName) - } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/azurerm/internal/services/avs/parse/avs_private_clouds.go b/azurerm/internal/services/avs/parse/avs_private_clouds.go index 631f7e3367fb..6f0de3451d96 100644 --- a/azurerm/internal/services/avs/parse/avs_private_clouds.go +++ b/azurerm/internal/services/avs/parse/avs_private_clouds.go @@ -1,29 +1,30 @@ package parse import ( - "fmt" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) + type AvsPrivateCloudId struct { - ResourceGroup string - Name string + ResourceGroup string + Name string } func AvsPrivateCloudID(input string) (*AvsPrivateCloudId, error) { - id, err := azure.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing avsPrivateCloud ID %q: %+v", input, err) - } + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing avsPrivateCloud ID %q: %+v", input, err) + } - avsPrivateCloud := AvsPrivateCloudId{ - ResourceGroup: id.ResourceGroup, - } - if avsPrivateCloud.Name, err = id.PopSegment("privateClouds"); err != nil { - return nil, err - } - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } + avsPrivateCloud := AvsPrivateCloudId{ + ResourceGroup: id.ResourceGroup, + } + if avsPrivateCloud.Name, err = id.PopSegment("privateClouds"); err != nil { + return nil, err + } + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } - return &avsPrivateCloud, nil + return &avsPrivateCloud, nil } diff --git a/azurerm/internal/services/avs/parse/avs_private_clouds_test.go b/azurerm/internal/services/avs/parse/avs_private_clouds_test.go index aae5c201712b..ba5a75d5f4f3 100644 --- a/azurerm/internal/services/avs/parse/avs_private_clouds_test.go +++ b/azurerm/internal/services/avs/parse/avs_private_clouds_test.go @@ -1,72 +1,72 @@ package parse import ( - "testing" + "testing" ) func TestAvsPrivateCloudID(t *testing.T) { - testData := []struct { - Name string - Input string - Expected *AvsPrivateCloudId - }{ - { - Name: "Empty", - Input: "", - Expected: nil, - }, - { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, - }, - { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, - }, - { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, - }, - { - Name: "Missing PrivateCloud Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds", - Expected: nil, - }, - { - Name: "avs PrivateCloud ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1", - Expected: &AvsPrivateCloudId{ - ResourceGroup:"resourceGroup1", - Name:"privateCloud1", - }, - }, - { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/PrivateClouds/privateCloud1", - Expected: nil, - }, - } + testData := []struct { + Name string + Input string + Expected *AvsPrivateCloudId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing PrivateCloud Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds", + Expected: nil, + }, + { + Name: "avs PrivateCloud ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/privateClouds/privateCloud1", + Expected: &AvsPrivateCloudId{ + ResourceGroup: "resourceGroup1", + Name: "privateCloud1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.AVS/PrivateClouds/privateCloud1", + Expected: nil, + }, + } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q..", v.Name) + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) - actual, err := AvsPrivateCloudID(v.Input) - if err != nil { - if v.Expected == nil { - continue - } - t.Fatalf("Expected a value but got an error: %s", err) - } + actual, err := AvsPrivateCloudID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } } diff --git a/azurerm/internal/services/avs/registration.go b/azurerm/internal/services/avs/registration.go index 265fd5bdcb7a..f6d02a09485a 100644 --- a/azurerm/internal/services/avs/registration.go +++ b/azurerm/internal/services/avs/registration.go @@ -6,32 +6,26 @@ type Registration struct{} // Name is the name of this Service func (r Registration) Name() string { - return "Avs" + return "Avs" } // WebsiteCategories returns a list of categories which can be used for the sidebar func (r Registration) WebsiteCategories() []string { - return []string{ - "Avs", - } + return []string{ + "Avs", + } } // SupportedDataSources returns the supported Data Sources supported by this Service func (r Registration) SupportedDataSources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "azurerm_avs_private_cloud": dataSourceAvsPrivateCloud(), - "azurerm_avs_cluster": dataSourceAvsCluster(), - "azurerm_avs_hcx_enterprise_site": dataSourceAvsHcxEnterpriseSite(), - "azurerm_avs_authorization": dataSourceAvsAuthorization(), - } + return map[string]*schema.Resource{ + "azurerm_avs_private_cloud": dataSourceAvsPrivateCloud(), + } } // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "azurerm_avs_private_cloud": resourceArmAvsPrivateCloud(), - "azurerm_avs_cluster": resourceArmAvsCluster(), - "azurerm_avs_hcx_enterprise_site": resourceArmAvsHcxEnterpriseSite(), - "azurerm_avs_authorization": resourceArmAvsAuthorization(), - } + return map[string]*schema.Resource{ + "azurerm_avs_private_cloud": resourceArmAvsPrivateCloud(), + } } diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go index d84a4baa121a..c9e5acf2c8e6 100644 --- a/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go @@ -1,31 +1,32 @@ package tests import ( - "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "testing" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "testing" ) + func TestAccDataSourceAzureRMavsPrivateCloud_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceavsPrivateCloud_basic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - }, - }) + data := acceptance.BuildTestData(t, "data.azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + }, + }) } func testAccDataSourceavsPrivateCloud_basic(data acceptance.TestData) string { - config := testAccAzureRMavsPrivateCloud_basic(data) - return fmt.Sprintf(` + config := testAccAzureRMavsPrivateCloud_basic(data) + return fmt.Sprintf(` %s data "azurerm_avs_private_cloud" "test" { diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go index 7450e4db545f..586110f8a203 100644 --- a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go @@ -1,198 +1,299 @@ package tests import ( - "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "testing" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" + "testing" ) func TestAccAzureRMavsPrivateCloud_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_basic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + }, + }) } func TestAccAzureRMavsPrivateCloud_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_basic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.RequiresImportErrorStep(testAccAzureRMavsPrivateCloud_requiresImport), - }, - }) + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.RequiresImportErrorStep(testAccAzureRMavsPrivateCloud_requiresImport), + }, + }) } func TestAccAzureRMavsPrivateCloud_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_complete(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + }, + }) } func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_basic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - { - Config: testAccAzureRMavsPrivateCloud_complete(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - { - Config: testAccAzureRMavsPrivateCloud_basic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMavsPrivateCloud_updateManagementCluster(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_complete(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - { - Config: testAccAzureRMavsPrivateCloud_updateManagementCluster(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_update(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + }, + }) } func TestAccAzureRMavsPrivateCloud_updateIdentitySources(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMavsPrivateCloud_complete(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - { - Config: testAccAzureRMavsPrivateCloud_updateIdentitySources(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMavsPrivateCloudExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) + data := acceptance.BuildTestData(t, "azurerm_avs_private_cloud", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMavsPrivateCloudDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMavsPrivateCloud_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_updateIdentitySources(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMavsPrivateCloud_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), + ), + }, + data.ImportStep(), + }, + }) } func testCheckAzureRMavsPrivateCloudExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("avs PrivateCloud not found: %s", resourceName) - } - id, err := parse.AvsPrivateCloudID(rs.Primary.ID) - if err != nil { - return err - } - if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { - if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("bad: Avs PrivateCloud %q does not exist", id.Name) - } - return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) - } - return nil - } + return func(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("avs PrivateCloud not found: %s", resourceName) + } + id, err := parse.AvsPrivateCloudID(rs.Primary.ID) + if err != nil { + return err + } + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("bad: Avs PrivateCloud %q does not exist", id.Name) + } + return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) + } + return nil + } } func testCheckAzureRMavsPrivateCloudDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + client := acceptance.AzureProvider.Meta().(*clients.Client).Avs.PrivateCloudClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_avs_private_cloud" { - continue - } - id, err := parse.AvsPrivateCloudID(rs.Primary.ID) - if err != nil { - return err - } - if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { - if !utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) - } - } - return nil - } - return nil + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_avs_private_cloud" { + continue + } + id, err := parse.AvsPrivateCloudID(rs.Primary.ID) + if err != nil { + return err + } + if resp, err := client.Get(ctx, id.ResourceGroup, id.Name); err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("bad: Get on Avs.PrivateCloudClient: %+v", err) + } + } + return nil + } + return nil } func testAccAzureRMavsPrivateCloud_template(data acceptance.TestData) string { - return fmt.Sprintf(` + return fmt.Sprintf(` provider "azurerm" { features {} } @@ -205,17 +306,15 @@ resource "azurerm_resource_group" "test" { } func testAccAzureRMavsPrivateCloud_basic(data acceptance.TestData) string { - template := testAccAzureRMavsPrivateCloud_template(data) - return fmt.Sprintf(` + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` %s resource "azurerm_avs_private_cloud" "test" { - name = "acctest-apc-%d" + name = "acctest-apc-%d" resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku { - name = "av36" - } + location = azurerm_resource_group.test.location + sku_name = "av36" management_cluster { cluster_size = 4 @@ -226,19 +325,18 @@ resource "azurerm_avs_private_cloud" "test" { } func testAccAzureRMavsPrivateCloud_requiresImport(data acceptance.TestData) string { - config := testAccAzureRMavsPrivateCloud_basic(data) - return fmt.Sprintf(` + config := testAccAzureRMavsPrivateCloud_basic(data) + return fmt.Sprintf(` %s resource "azurerm_avs_private_cloud" "import" { - name = azurerm_avs_private_cloud.test.name + name = azurerm_avs_private_cloud.test.name resource_group_name = azurerm_avs_private_cloud.test.resource_group_name - location = azurerm_avs_private_cloud.test.location - sku { - name = azurerm_avs_private_cloud.test.sku.name - } + location = azurerm_avs_private_cloud.test.location + sku_name = azurerm_avs_private_cloud.test.sku_name + management_cluster { - cluster_size = azurerm_avs_private_cloud.test.management_cluster.cluster_size + cluster_size = azurerm_avs_private_cloud.test.management_cluster.0.cluster_size } network_block = azurerm_avs_private_cloud.test.network_block } @@ -246,37 +344,35 @@ resource "azurerm_avs_private_cloud" "import" { } func testAccAzureRMavsPrivateCloud_complete(data acceptance.TestData) string { - template := testAccAzureRMavsPrivateCloud_template(data) - return fmt.Sprintf(` + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` %s resource "azurerm_avs_private_cloud" "test" { - name = "acctest-apc-%d" + name = "acctest-apc-%d" resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku { - name = "AV36" - } + location = azurerm_resource_group.test.location + sku_name = "AV36" management_cluster { cluster_size = 4 } network_block = "192.168.48.0/22" identity_source { - name = "" - alias = "" - base_group_dn = "" - base_user_dn = "" - domain = "" - password = "" - primary_server = "" - secondary_server = "" - ssl = false - username = "" + name = "testName" + alias = "testAlias" + base_group_dn = "testGp" + base_user_dn = "testUser" + domain = "testDomain" + password = "PassWord1234!" + primary_server_url = "http://test.com" + secondary_server_url = "http://test2.com" + ssl_enabled = false + username = "testUser" } - internet = false - nsxt_password = "" - vcenter_password = "" + internet_connected = false + nsxt_password = "PassWord1234!" + vcenter_password = "PassWord1234!" tags = { ENV = "Test" } @@ -284,80 +380,88 @@ resource "azurerm_avs_private_cloud" "test" { `, template, data.RandomInteger) } -func testAccAzureRMavsPrivateCloud_updateManagementCluster(data acceptance.TestData) string { - template := testAccAzureRMavsPrivateCloud_template(data) - return fmt.Sprintf(` +func testAccAzureRMavsPrivateCloud_update(data acceptance.TestData) string { + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` %s resource "azurerm_avs_private_cloud" "test" { - name = "acctest-apc-%d" + name = "acctest-apc-%d" resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku { - name = "AV36" - } + location = azurerm_resource_group.test.location + sku_name = "AV36" management_cluster { - cluster_size = 4 + cluster_size = 3 } network_block = "192.168.48.0/22" identity_source { - name = "" - alias = "" - base_group_dn = "" - base_user_dn = "" - domain = "" - password = "" - primary_server = "" - secondary_server = "" - ssl = false - username = "" + name = "testName2" + alias = "testAlias2" + base_group_dn = "testGp2" + base_user_dn = "testUser2" + domain = "testDomain2" + password = "PassWord1234!2" + primary_server_url = "http://test_secondary.com" + secondary_server_url = "http://test_secondary2.com" + ssl_enabled = true + username = "testUser2" } - internet = false - nsxt_password = "" - vcenter_password = "" + internet_connected = true + nsxt_password = "PassWord1234!" + vcenter_password = "PassWord1234!" tags = { - ENV = "Test" + ENV = "Stage" } } `, template, data.RandomInteger) } func testAccAzureRMavsPrivateCloud_updateIdentitySources(data acceptance.TestData) string { - template := testAccAzureRMavsPrivateCloud_template(data) - return fmt.Sprintf(` + template := testAccAzureRMavsPrivateCloud_template(data) + return fmt.Sprintf(` %s resource "azurerm_avs_private_cloud" "test" { name = "acctest-apc-%d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - sku { - name = "AV36" - } + sku_name= "AV36" management_cluster { cluster_size = 4 } network_block = "192.168.48.0/22" identity_source { - name = "" - alias = "" - base_group_dn = "" - base_user_dn = "" - domain = "" - password = "" - primary_server = "" - secondary_server = "" - ssl = false - username = "" + name = "testName" + alias = "testAlias" + base_group_dn = "testGp" + base_user_dn = "testUser" + domain = "testDomain" + password = "PassWord1234!" + primary_server_url = "http://test.com" + secondary_server_url = "http://test2.com" + ssl_enabled = false + username = "testUser" + } + +identity_source { + name = "testName3" + alias = "testAlias3" + base_group_dn = "testGp3" + base_user_dn = "testUser3" + domain = "testDomain3" + password = "PassWord1234!3" + primary_server_url = "http://test_secondary.com" + secondary_server_url = "http://test_secondary2.com" + ssl_enabled = true + username = "testUser3" } - internet = false - nsxt_password = "" - vcenter_password = "" + internet_connected = false + nsxt_password = "PassWord1234!" + vcenter_password = "PassWord1234!" tags = { ENV = "Test" } -} `, template, data.RandomInteger) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go index e8cc967e2088..34bb4663ebe7 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/authorizations.go @@ -1,432 +1,429 @@ -package avs - -// 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" -) - -// AuthorizationsClient is the azure VMware Solution API -type AuthorizationsClient struct { - BaseClient -} - -// NewAuthorizationsClient creates an instance of the AuthorizationsClient client. -func NewAuthorizationsClient(subscriptionID string) AuthorizationsClient { - return NewAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewAuthorizationsClientWithBaseURI creates an instance of the AuthorizationsClient 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 NewAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationsClient { - return AuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate sends the create or update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - the name of the private cloud. -// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud -// authorization - an ExpressRoute Circuit Authorization -func (client AuthorizationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (result AuthorizationsCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, authorizationName, authorization) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client AuthorizationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationName": autorest.Encode("path", authorizationName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", pathParameters), - autorest.WithJSON(authorization), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client AuthorizationsClient) CreateOrUpdateSender(req *http.Request) (future AuthorizationsCreateOrUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client AuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteAuthorization, 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 sends the delete request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud -func (client AuthorizationsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result AuthorizationsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, authorizationName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client AuthorizationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationName": autorest.Encode("path", authorizationName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) DeleteSender(req *http.Request) (future AuthorizationsDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client AuthorizationsClient) 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 sends the get request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud -func (client AuthorizationsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result ExpressRouteAuthorization, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, authorizationName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client AuthorizationsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationName": autorest.Encode("path", authorizationName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) 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 AuthorizationsClient) GetResponder(resp *http.Response) (result ExpressRouteAuthorization, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List sends the list request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client AuthorizationsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.List") - defer func() { - sc := -1 - if result.eral.Response.Response != nil { - sc = result.eral.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.eral.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure sending request") - return - } - - result.eral, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure responding to request") - } - if result.eral.hasNextLink() && result.eral.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListPreparer prepares the List request. -func (client AuthorizationsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations", 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 AuthorizationsClient) 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 AuthorizationsClient) ListResponder(resp *http.Response) (result ExpressRouteAuthorizationList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client AuthorizationsClient) listNextResults(ctx context.Context, lastResults ExpressRouteAuthorizationList) (result ExpressRouteAuthorizationList, err error) { - req, err := lastResults.expressRouteAuthorizationListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "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, "avs.AuthorizationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client AuthorizationsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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, privateCloudName) - return -} +package avs + +// 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" +) + +// AuthorizationsClient is the azure VMware Solution API +type AuthorizationsClient struct { + BaseClient +} + +// NewAuthorizationsClient creates an instance of the AuthorizationsClient client. +func NewAuthorizationsClient(subscriptionID string) AuthorizationsClient { + return NewAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAuthorizationsClientWithBaseURI creates an instance of the AuthorizationsClient 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 NewAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationsClient { + return AuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +// authorization - an ExpressRoute Circuit Authorization +func (client AuthorizationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (result AuthorizationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, authorizationName, authorization) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AuthorizationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", pathParameters), + autorest.WithJSON(authorization), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationsClient) CreateOrUpdateSender(req *http.Request) (future AuthorizationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteAuthorization, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result AuthorizationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AuthorizationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) DeleteSender(req *http.Request) (future AuthorizationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AuthorizationsClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// authorizationName - name of the ExpressRoute Circuit Authorization in the private cloud +func (client AuthorizationsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result ExpressRouteAuthorization, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, authorizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AuthorizationsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authorizationName": autorest.Encode("path", authorizationName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", 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 AuthorizationsClient) 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 AuthorizationsClient) GetResponder(resp *http.Response) (result ExpressRouteAuthorization, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client AuthorizationsClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.List") + defer func() { + sc := -1 + if result.eral.Response.Response != nil { + sc = result.eral.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.AuthorizationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.eral.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure sending request") + return + } + + result.eral, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AuthorizationsClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations", 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 AuthorizationsClient) 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 AuthorizationsClient) ListResponder(resp *http.Response) (result ExpressRouteAuthorizationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AuthorizationsClient) listNextResults(ctx context.Context, lastResults ExpressRouteAuthorizationList) (result ExpressRouteAuthorizationList, err error) { + req, err := lastResults.expressRouteAuthorizationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "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, "avs.AuthorizationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AuthorizationsClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ExpressRouteAuthorizationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationsClient.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, privateCloudName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go deleted file mode 100644 index eb7087c9474a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/avsapi/interfaces.go +++ /dev/null @@ -1,89 +0,0 @@ -package avsapi - -// 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/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" - "github.com/Azure/go-autorest/autorest" -) - -// OperationsClientAPI contains the set of methods on the OperationsClient type. -type OperationsClientAPI interface { - List(ctx context.Context) (result avs.OperationListPage, err error) - ListComplete(ctx context.Context) (result avs.OperationListIterator, err error) -} - -var _ OperationsClientAPI = (*avs.OperationsClient)(nil) - -// LocationsClientAPI contains the set of methods on the LocationsClient type. -type LocationsClientAPI interface { - CheckQuotaAvailability(ctx context.Context, location string) (result avs.Quota, err error) - CheckTrialAvailability(ctx context.Context, location string) (result avs.Trial, err error) -} - -var _ LocationsClientAPI = (*avs.LocationsClient)(nil) - -// PrivateCloudsClientAPI contains the set of methods on the PrivateCloudsClient type. -type PrivateCloudsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud avs.PrivateCloud) (result avs.PrivateCloudsCreateOrUpdateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloudsDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.PrivateCloud, err error) - List(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListPage, err error) - ListComplete(ctx context.Context, resourceGroupName string) (result avs.PrivateCloudListIterator, err error) - ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.AdminCredentials, err error) - ListInSubscription(ctx context.Context) (result avs.PrivateCloudListPage, err error) - ListInSubscriptionComplete(ctx context.Context) (result avs.PrivateCloudListIterator, err error) - Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate avs.PrivateCloudUpdate) (result avs.PrivateCloudsUpdateFuture, err error) -} - -var _ PrivateCloudsClientAPI = (*avs.PrivateCloudsClient)(nil) - -// ClustersClientAPI contains the set of methods on the ClustersClient type. -type ClustersClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster avs.Cluster) (result avs.ClustersCreateOrUpdateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.ClustersDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result avs.Cluster, err error) - List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListPage, err error) - ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ClusterListIterator, err error) - Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate avs.ClusterUpdate) (result avs.ClustersUpdateFuture, err error) -} - -var _ ClustersClientAPI = (*avs.ClustersClient)(nil) - -// HcxEnterpriseSitesClientAPI contains the set of methods on the HcxEnterpriseSitesClient type. -type HcxEnterpriseSitesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (result avs.HcxEnterpriseSite, err error) - Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) - Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result avs.HcxEnterpriseSite, err error) - List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListPage, err error) - ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.HcxEnterpriseSiteListIterator, err error) -} - -var _ HcxEnterpriseSitesClientAPI = (*avs.HcxEnterpriseSitesClient)(nil) - -// AuthorizationsClientAPI contains the set of methods on the AuthorizationsClient type. -type AuthorizationsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string, authorization interface{}) (result avs.AuthorizationsCreateOrUpdateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.AuthorizationsDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, privateCloudName string, authorizationName string) (result avs.ExpressRouteAuthorization, err error) - List(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListPage, err error) - ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result avs.ExpressRouteAuthorizationListIterator, err error) -} - -var _ AuthorizationsClientAPI = (*avs.AuthorizationsClient)(nil) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go index f9b3fc4c05b3..9d82901763af 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/client.go @@ -1,52 +1,52 @@ -// Package avs implements the Azure ARM Avs service API version 2020-03-20. -// -// Azure VMware Solution API -package avs - -// 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 ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Avs - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Avs. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient 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 NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} +// Package avs implements the Azure ARM Avs service API version 2020-03-20. +// +// Azure VMware Solution API +package avs + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Avs + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Avs. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient 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 NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go index fb28755b2d24..4db00f22bb14 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/clusters.go @@ -1,526 +1,523 @@ -package avs - -// 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" -) - -// ClustersClient is the azure VMware Solution API -type ClustersClient struct { - BaseClient -} - -// NewClustersClient creates an instance of the ClustersClient client. -func NewClustersClient(subscriptionID string) ClustersClient { - return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewClustersClientWithBaseURI creates an instance of the ClustersClient 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 NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { - return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate sends the create or update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - the name of the private cloud. -// clusterName - name of the cluster in the private cloud -// cluster - a cluster in the private cloud -func (client ClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (result ClustersCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, - {TargetValue: cluster, - Constraints: []validation.Constraint{{Target: "cluster.Sku", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "cluster.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, - {Target: "cluster.ClusterProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("avs.ClustersClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, cluster) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), - autorest.WithJSON(cluster), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client ClustersClient) CreateOrUpdateSender(req *http.Request) (future ClustersCreateOrUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client ClustersClient) CreateOrUpdateResponder(resp *http.Response) (result Cluster, 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 sends the delete request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// clusterName - name of the cluster in the private cloud -func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result ClustersDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (future ClustersDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client ClustersClient) 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 sends the get request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// clusterName - name of the cluster in the private cloud -func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result Cluster, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) 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 ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List sends the list request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client ClustersClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.List") - defer func() { - sc := -1 - if result.cl.Response.Response != nil { - sc = result.cl.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.cl.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure sending request") - return - } - - result.cl, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure responding to request") - } - if result.cl.hasNextLink() && result.cl.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListPreparer prepares the List request. -func (client ClustersClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters", 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 ClustersClient) 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 ClustersClient) ListResponder(resp *http.Response) (result ClusterList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ClustersClient) listNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { - req, err := lastResults.clusterListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.ClustersClient", "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, "avs.ClustersClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ClustersClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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, privateCloudName) - return -} - -// Update sends the update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// clusterName - name of the cluster in the private cloud -// clusterUpdate - the cluster properties to be updated -func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (result ClustersUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), - autorest.WithJSON(clusterUpdate), - 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 ClustersClient) UpdateSender(req *http.Request) (future ClustersUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} +package avs + +// 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" +) + +// ClustersClient is the azure VMware Solution API +type ClustersClient struct { + BaseClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient 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 NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// clusterName - name of the cluster in the private cloud +// cluster - a cluster in the private cloud +func (client ClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (result ClustersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, + {TargetValue: cluster, + Constraints: []validation.Constraint{{Target: "cluster.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "cluster.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "cluster.ClusterProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.ClustersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, cluster) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, cluster Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(cluster), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) CreateOrUpdateSender(req *http.Request) (future ClustersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateOrUpdateResponder(resp *http.Response) (result Cluster, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result ClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (future ClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", 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 ClustersClient) 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 ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client ClustersClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ClustersClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters", 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 ClustersClient) 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 ClustersClient) ListResponder(resp *http.Response) (result ClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ClustersClient) listNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.ClustersClient", "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, "avs.ClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClustersClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.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, privateCloudName) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// clusterName - name of the cluster in the private cloud +// clusterUpdate - the cluster properties to be updated +func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (result ClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.ClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, clusterName, clusterUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, clusterName string, clusterUpdate ClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", pathParameters), + autorest.WithJSON(clusterUpdate), + 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 ClustersClient) UpdateSender(req *http.Request) (future ClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go index f04bbdee504f..06abda970182 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/hcxenterprisesites.go @@ -1,433 +1,430 @@ -package avs - -// 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" -) - -// HcxEnterpriseSitesClient is the azure VMware Solution API -type HcxEnterpriseSitesClient struct { - BaseClient -} - -// NewHcxEnterpriseSitesClient creates an instance of the HcxEnterpriseSitesClient client. -func NewHcxEnterpriseSitesClient(subscriptionID string) HcxEnterpriseSitesClient { - return NewHcxEnterpriseSitesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewHcxEnterpriseSitesClientWithBaseURI creates an instance of the HcxEnterpriseSitesClient 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 NewHcxEnterpriseSitesClientWithBaseURI(baseURI string, subscriptionID string) HcxEnterpriseSitesClient { - return HcxEnterpriseSitesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate sends the create or update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - the name of the private cloud. -// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud -// hcxEnterpriseSite - the HCX Enterprise Site -func (client HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (result HcxEnterpriseSite, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.CreateOrUpdate") - 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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, hcxEnterpriseSite) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client HcxEnterpriseSitesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", pathParameters), - autorest.WithJSON(hcxEnterpriseSite), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client HcxEnterpriseSitesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client HcxEnterpriseSitesClient) CreateOrUpdateResponder(resp *http.Response) (result HcxEnterpriseSite, 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 sends the delete request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud -func (client HcxEnterpriseSitesClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client HcxEnterpriseSitesClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client HcxEnterpriseSitesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get sends the get request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud -func (client HcxEnterpriseSitesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result HcxEnterpriseSite, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client HcxEnterpriseSitesClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) GetResponder(resp *http.Response) (result HcxEnterpriseSite, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List sends the list request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client HcxEnterpriseSitesClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.List") - defer func() { - sc := -1 - if result.hesl.Response.Response != nil { - sc = result.hesl.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.hesl.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure sending request") - return - } - - result.hesl, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure responding to request") - } - if result.hesl.hasNextLink() && result.hesl.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListPreparer prepares the List request. -func (client HcxEnterpriseSitesClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) ListResponder(resp *http.Response) (result HcxEnterpriseSiteList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client HcxEnterpriseSitesClient) listNextResults(ctx context.Context, lastResults HcxEnterpriseSiteList) (result HcxEnterpriseSiteList, err error) { - req, err := lastResults.hcxEnterpriseSiteListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "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, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client HcxEnterpriseSitesClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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, privateCloudName) - return -} +package avs + +// 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" +) + +// HcxEnterpriseSitesClient is the azure VMware Solution API +type HcxEnterpriseSitesClient struct { + BaseClient +} + +// NewHcxEnterpriseSitesClient creates an instance of the HcxEnterpriseSitesClient client. +func NewHcxEnterpriseSitesClient(subscriptionID string) HcxEnterpriseSitesClient { + return NewHcxEnterpriseSitesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHcxEnterpriseSitesClientWithBaseURI creates an instance of the HcxEnterpriseSitesClient 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 NewHcxEnterpriseSitesClientWithBaseURI(baseURI string, subscriptionID string) HcxEnterpriseSitesClient { + return HcxEnterpriseSitesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - the name of the private cloud. +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +// hcxEnterpriseSite - the HCX Enterprise Site +func (client HcxEnterpriseSitesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.CreateOrUpdate") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName, hcxEnterpriseSite) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client HcxEnterpriseSitesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string, hcxEnterpriseSite interface{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", pathParameters), + autorest.WithJSON(hcxEnterpriseSite), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client HcxEnterpriseSitesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client HcxEnterpriseSitesClient) CreateOrUpdateResponder(resp *http.Response) (result HcxEnterpriseSite, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HcxEnterpriseSitesClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HcxEnterpriseSitesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// hcxEnterpriseSiteName - name of the HCX Enterprise Site in the private cloud +func (client HcxEnterpriseSitesClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (result HcxEnterpriseSite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName, hcxEnterpriseSiteName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HcxEnterpriseSitesClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string, hcxEnterpriseSiteName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hcxEnterpriseSiteName": autorest.Encode("path", hcxEnterpriseSiteName), + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) GetResponder(resp *http.Response) (result HcxEnterpriseSite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client HcxEnterpriseSitesClient) List(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.List") + defer func() { + sc := -1 + if result.hesl.Response.Response != nil { + sc = result.hesl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.HcxEnterpriseSitesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.hesl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure sending request") + return + } + + result.hesl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client HcxEnterpriseSitesClient) ListPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites", 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 HcxEnterpriseSitesClient) 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 HcxEnterpriseSitesClient) ListResponder(resp *http.Response) (result HcxEnterpriseSiteList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client HcxEnterpriseSitesClient) listNextResults(ctx context.Context, lastResults HcxEnterpriseSiteList) (result HcxEnterpriseSiteList, err error) { + req, err := lastResults.hcxEnterpriseSiteListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "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, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.HcxEnterpriseSitesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client HcxEnterpriseSitesClient) ListComplete(ctx context.Context, resourceGroupName string, privateCloudName string) (result HcxEnterpriseSiteListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSitesClient.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, privateCloudName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go index 1a3f5032a634..27fa5caec5ff 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/locations.go @@ -1,201 +1,201 @@ -package avs - -// 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" -) - -// LocationsClient is the azure VMware Solution API -type LocationsClient struct { - BaseClient -} - -// NewLocationsClient creates an instance of the LocationsClient client. -func NewLocationsClient(subscriptionID string) LocationsClient { - return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewLocationsClientWithBaseURI creates an instance of the LocationsClient 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 NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { - return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckQuotaAvailability return quota for subscription by region -// Parameters: -// location - azure region -func (client LocationsClient) CheckQuotaAvailability(ctx context.Context, location string) (result Quota, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("avs.LocationsClient", "CheckQuotaAvailability", err.Error()) - } - - req, err := client.CheckQuotaAvailabilityPreparer(ctx, location) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", nil, "Failure preparing request") - return - } - - resp, err := client.CheckQuotaAvailabilitySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckQuotaAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure responding to request") - } - - return -} - -// CheckQuotaAvailabilityPreparer prepares the CheckQuotaAvailability request. -func (client LocationsClient) CheckQuotaAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability", pathParameters), - 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 LocationsClient) 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 LocationsClient) CheckQuotaAvailabilityResponder(resp *http.Response) (result Quota, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CheckTrialAvailability return trial status for subscription by region -// Parameters: -// location - azure region -func (client LocationsClient) CheckTrialAvailability(ctx context.Context, location string) (result Trial, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.CheckTrialAvailability") - 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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("avs.LocationsClient", "CheckTrialAvailability", err.Error()) - } - - req, err := client.CheckTrialAvailabilityPreparer(ctx, location) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", nil, "Failure preparing request") - return - } - - resp, err := client.CheckTrialAvailabilitySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckTrialAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure responding to request") - } - - return -} - -// CheckTrialAvailabilityPreparer prepares the CheckTrialAvailability request. -func (client LocationsClient) CheckTrialAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckTrialAvailabilitySender sends the CheckTrialAvailability request. The method will close the -// http.Response Body if it receives an error. -func (client LocationsClient) CheckTrialAvailabilitySender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckTrialAvailabilityResponder handles the response to the CheckTrialAvailability request. The method always -// closes the http.Response Body. -func (client LocationsClient) CheckTrialAvailabilityResponder(resp *http.Response) (result Trial, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} +package avs + +// 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" +) + +// LocationsClient is the azure VMware Solution API +type LocationsClient struct { + BaseClient +} + +// NewLocationsClient creates an instance of the LocationsClient client. +func NewLocationsClient(subscriptionID string) LocationsClient { + return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationsClientWithBaseURI creates an instance of the LocationsClient 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 NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckQuotaAvailability return quota for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckQuotaAvailability(ctx context.Context, location string) (result Quota, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckQuotaAvailability", err.Error()) + } + + req, err := client.CheckQuotaAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckQuotaAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckQuotaAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckQuotaAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckQuotaAvailabilityPreparer prepares the CheckQuotaAvailability request. +func (client LocationsClient) CheckQuotaAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability", pathParameters), + 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 LocationsClient) 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 LocationsClient) CheckQuotaAvailabilityResponder(resp *http.Response) (result Quota, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckTrialAvailability return trial status for subscription by region +// Parameters: +// location - azure region +func (client LocationsClient) CheckTrialAvailability(ctx context.Context, location string) (result Trial, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.CheckTrialAvailability") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.LocationsClient", "CheckTrialAvailability", err.Error()) + } + + req, err := client.CheckTrialAvailabilityPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckTrialAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckTrialAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.LocationsClient", "CheckTrialAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckTrialAvailabilityPreparer prepares the CheckTrialAvailability request. +func (client LocationsClient) CheckTrialAvailabilityPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckTrialAvailabilitySender sends the CheckTrialAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) CheckTrialAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckTrialAvailabilityResponder handles the response to the CheckTrialAvailability request. The method always +// closes the http.Response Body. +func (client LocationsClient) CheckTrialAvailabilityResponder(resp *http.Response) (result Trial, 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/avs/mgmt/2020-03-20/avs/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go index 26c10c261f3a..ab5b813b1640 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/models.go @@ -1,1770 +1,1822 @@ -package avs - -// 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/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/avs/mgmt/2020-03-20/avs" - -// AdminCredentials administrative credentials for accessing vCenter and NSX-T -type AdminCredentials struct { - autorest.Response `json:"-"` - // NsxtUsername - READ-ONLY; NSX-T Manager username - NsxtUsername *string `json:"nsxtUsername,omitempty"` - // NsxtPassword - READ-ONLY; NSX-T Manager password - NsxtPassword *string `json:"nsxtPassword,omitempty"` - // VcenterUsername - READ-ONLY; vCenter admin username - VcenterUsername *string `json:"vcenterUsername,omitempty"` - // VcenterPassword - READ-ONLY; vCenter admin password - VcenterPassword *string `json:"vcenterPassword,omitempty"` -} - -// AuthorizationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type AuthorizationsCreateOrUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *AuthorizationsCreateOrUpdateFuture) Result(client AuthorizationsClient) (era ExpressRouteAuthorization, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if era.Response.Response, err = future.GetResult(sender); err == nil && era.Response.Response.StatusCode != http.StatusNoContent { - era, err = client.CreateOrUpdateResponder(era.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", era.Response.Response, "Failure responding to request") - } - } - return -} - -// AuthorizationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type AuthorizationsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *AuthorizationsDeleteFuture) Result(client AuthorizationsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.AuthorizationsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// Circuit an ExpressRoute Circuit -type Circuit struct { - // PrimarySubnet - READ-ONLY; CIDR of primary subnet - PrimarySubnet *string `json:"primarySubnet,omitempty"` - // SecondarySubnet - READ-ONLY; CIDR of secondary subnet - SecondarySubnet *string `json:"secondarySubnet,omitempty"` - // ExpressRouteID - READ-ONLY; Identifier of the ExpressRoute Circuit (Microsoft Colo only) - ExpressRouteID *string `json:"expressRouteID,omitempty"` - // ExpressRoutePrivatePeeringID - READ-ONLY; ExpressRoute Circuit private peering identifier - ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty"` -} - -// CloudError API error response -type CloudError struct { - // Error - An error returned by the API - Error *ErrorResponse `json:"error,omitempty"` -} - -// Cluster a cluster resource -type Cluster struct { - autorest.Response `json:"-"` - // Sku - The cluster SKU - Sku *Sku `json:"sku,omitempty"` - // ClusterProperties - The properties of a cluster resource - *ClusterProperties `json:"properties,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"` -} - -// MarshalJSON is the custom marshaler for Cluster. -func (c Cluster) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if c.Sku != nil { - objectMap["sku"] = c.Sku - } - if c.ClusterProperties != nil { - objectMap["properties"] = c.ClusterProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Cluster struct. -func (c *Cluster) 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 "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - c.Sku = &sku - } - case "properties": - if v != nil { - var clusterProperties ClusterProperties - err = json.Unmarshal(*v, &clusterProperties) - if err != nil { - return err - } - c.ClusterProperties = &clusterProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - c.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - c.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - c.Type = &typeVar - } - } - } - - return nil -} - -// ClusterList a paged list of clusters -type ClusterList struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The items on a page - Value *[]Cluster `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next page if any - NextLink *string `json:"nextLink,omitempty"` -} - -// ClusterListIterator provides access to a complete listing of Cluster values. -type ClusterListIterator struct { - i int - page ClusterListPage -} - -// 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 *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.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 *ClusterListIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ClusterListIterator) 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 ClusterListIterator) Response() ClusterList { - 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 ClusterListIterator) Value() Cluster { - if !iter.page.NotDone() { - return Cluster{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ClusterListIterator type. -func NewClusterListIterator(page ClusterListPage) ClusterListIterator { - return ClusterListIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (cl ClusterList) IsEmpty() bool { - return cl.Value == nil || len(*cl.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (cl ClusterList) hasNextLink() bool { - return cl.NextLink != nil && len(*cl.NextLink) != 0 -} - -// clusterListPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { - if !cl.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(cl.NextLink))) -} - -// ClusterListPage contains a page of Cluster values. -type ClusterListPage struct { - fn func(context.Context, ClusterList) (ClusterList, error) - cl ClusterList -} - -// 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 *ClusterListPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.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.cl) - if err != nil { - return err - } - page.cl = 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 *ClusterListPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ClusterListPage) NotDone() bool { - return !page.cl.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ClusterListPage) Response() ClusterList { - return page.cl -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ClusterListPage) Values() []Cluster { - if page.cl.IsEmpty() { - return nil - } - return *page.cl.Value -} - -// Creates a new instance of the ClusterListPage type. -func NewClusterListPage(getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { - return ClusterListPage{fn: getNextPage} -} - -// ClusterProperties the properties of a cluster -type ClusterProperties struct { - // ProvisioningState - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' - ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` - // ClusterID - READ-ONLY; The identity - ClusterID *int32 `json:"clusterId,omitempty"` - // Hosts - READ-ONLY; The hosts - Hosts *[]string `json:"hosts,omitempty"` - // ClusterSize - The cluster size - ClusterSize *int32 `json:"clusterSize,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClusterProperties. -func (cp ClusterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cp.ClusterSize != nil { - objectMap["clusterSize"] = cp.ClusterSize - } - return json.Marshal(objectMap) -} - -// ClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ClustersCreateOrUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ClustersCreateOrUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.ClustersCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { - c, err = client.CreateOrUpdateResponder(c.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") - } - } - return -} - -// ClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type ClustersDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ClustersDeleteFuture) Result(client ClustersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.ClustersDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type ClustersUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ClustersUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.ClustersUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { - c, err = client.UpdateResponder(c.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", c.Response.Response, "Failure responding to request") - } - } - return -} - -// ClusterUpdate an update of a cluster resource -type ClusterUpdate struct { - // ClusterUpdateProperties - The properties of a cluster resource that may be updated - *ClusterUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClusterUpdate. -func (cu ClusterUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cu.ClusterUpdateProperties != nil { - objectMap["properties"] = cu.ClusterUpdateProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ClusterUpdate struct. -func (cu *ClusterUpdate) 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 "properties": - if v != nil { - var clusterUpdateProperties ClusterUpdateProperties - err = json.Unmarshal(*v, &clusterUpdateProperties) - if err != nil { - return err - } - cu.ClusterUpdateProperties = &clusterUpdateProperties - } - } - } - - return nil -} - -// ClusterUpdateProperties the properties of a cluster that may be updated -type ClusterUpdateProperties struct { - // ClusterSize - The cluster size - ClusterSize *int32 `json:"clusterSize,omitempty"` -} - -// Endpoints endpoint addresses -type Endpoints struct { - // NsxtManager - READ-ONLY; Endpoint for the NSX-T Data Center manager - NsxtManager *string `json:"nsxtManager,omitempty"` - // Vcsa - READ-ONLY; Endpoint for Virtual Center Server Appliance - Vcsa *string `json:"vcsa,omitempty"` - // HcxCloudManager - READ-ONLY; Endpoint for the HCX Cloud Manager - HcxCloudManager *string `json:"hcxCloudManager,omitempty"` -} - -// ErrorAdditionalInfo the resource management error additional info. -type ErrorAdditionalInfo struct { - // Type - READ-ONLY; The additional info type. - Type *string `json:"type,omitempty"` - // Info - READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty"` -} - -// ErrorResponse the resource management error response. -type ErrorResponse struct { - // Code - READ-ONLY; The error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; The error message. - Message *string `json:"message,omitempty"` - // Target - READ-ONLY; The error target. - Target *string `json:"target,omitempty"` - // Details - READ-ONLY; The error details. - Details *[]ErrorResponse `json:"details,omitempty"` - // AdditionalInfo - READ-ONLY; The error additional info. - AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` -} - -// ExpressRouteAuthorization expressRoute Circuit Authorization -type ExpressRouteAuthorization struct { - autorest.Response `json:"-"` - // ExpressRouteAuthorizationProperties - The properties of an ExpressRoute Circuit Authorization resource - *ExpressRouteAuthorizationProperties `json:"properties,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"` -} - -// MarshalJSON is the custom marshaler for ExpressRouteAuthorization. -func (era ExpressRouteAuthorization) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if era.ExpressRouteAuthorizationProperties != nil { - objectMap["properties"] = era.ExpressRouteAuthorizationProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ExpressRouteAuthorization struct. -func (era *ExpressRouteAuthorization) 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 "properties": - if v != nil { - var expressRouteAuthorizationProperties ExpressRouteAuthorizationProperties - err = json.Unmarshal(*v, &expressRouteAuthorizationProperties) - if err != nil { - return err - } - era.ExpressRouteAuthorizationProperties = &expressRouteAuthorizationProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - era.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - era.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - era.Type = &typeVar - } - } - } - - return nil -} - -// ExpressRouteAuthorizationList a paged list of ExpressRoute Circuit Authorizations -type ExpressRouteAuthorizationList struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The items on a page - Value *[]ExpressRouteAuthorization `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next page if any - NextLink *string `json:"nextLink,omitempty"` -} - -// ExpressRouteAuthorizationListIterator provides access to a complete listing of ExpressRouteAuthorization -// values. -type ExpressRouteAuthorizationListIterator struct { - i int - page ExpressRouteAuthorizationListPage -} - -// 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 *ExpressRouteAuthorizationListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListIterator.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 *ExpressRouteAuthorizationListIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ExpressRouteAuthorizationListIterator) 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 ExpressRouteAuthorizationListIterator) Response() ExpressRouteAuthorizationList { - 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 ExpressRouteAuthorizationListIterator) Value() ExpressRouteAuthorization { - if !iter.page.NotDone() { - return ExpressRouteAuthorization{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ExpressRouteAuthorizationListIterator type. -func NewExpressRouteAuthorizationListIterator(page ExpressRouteAuthorizationListPage) ExpressRouteAuthorizationListIterator { - return ExpressRouteAuthorizationListIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (eral ExpressRouteAuthorizationList) IsEmpty() bool { - return eral.Value == nil || len(*eral.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (eral ExpressRouteAuthorizationList) hasNextLink() bool { - return eral.NextLink != nil && len(*eral.NextLink) != 0 -} - -// expressRouteAuthorizationListPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (eral ExpressRouteAuthorizationList) expressRouteAuthorizationListPreparer(ctx context.Context) (*http.Request, error) { - if !eral.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(eral.NextLink))) -} - -// ExpressRouteAuthorizationListPage contains a page of ExpressRouteAuthorization values. -type ExpressRouteAuthorizationListPage struct { - fn func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error) - eral ExpressRouteAuthorizationList -} - -// 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 *ExpressRouteAuthorizationListPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListPage.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.eral) - if err != nil { - return err - } - page.eral = 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 *ExpressRouteAuthorizationListPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ExpressRouteAuthorizationListPage) NotDone() bool { - return !page.eral.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ExpressRouteAuthorizationListPage) Response() ExpressRouteAuthorizationList { - return page.eral -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ExpressRouteAuthorizationListPage) Values() []ExpressRouteAuthorization { - if page.eral.IsEmpty() { - return nil - } - return *page.eral.Value -} - -// Creates a new instance of the ExpressRouteAuthorizationListPage type. -func NewExpressRouteAuthorizationListPage(getNextPage func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error)) ExpressRouteAuthorizationListPage { - return ExpressRouteAuthorizationListPage{fn: getNextPage} -} - -// ExpressRouteAuthorizationProperties the properties of an ExpressRoute Circuit Authorization resource -type ExpressRouteAuthorizationProperties struct { - // ProvisioningState - READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning. Possible values include: 'ExpressRouteAuthorizationProvisioningStateSucceeded', 'ExpressRouteAuthorizationProvisioningStateFailed', 'ExpressRouteAuthorizationProvisioningStateUpdating' - ProvisioningState ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty"` - // ExpressRouteAuthorizationID - READ-ONLY; The ID of the ExpressRoute Circuit Authorization - ExpressRouteAuthorizationID *string `json:"expressRouteAuthorizationId,omitempty"` - // ExpressRouteAuthorizationKey - READ-ONLY; The key of the ExpressRoute Circuit Authorization - ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty"` -} - -// HcxEnterpriseSite an HCX Enterprise Site resource -type HcxEnterpriseSite struct { - autorest.Response `json:"-"` - // HcxEnterpriseSiteProperties - The properties of an HCX Enterprise Site resource - *HcxEnterpriseSiteProperties `json:"properties,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"` -} - -// MarshalJSON is the custom marshaler for HcxEnterpriseSite. -func (hes HcxEnterpriseSite) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if hes.HcxEnterpriseSiteProperties != nil { - objectMap["properties"] = hes.HcxEnterpriseSiteProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for HcxEnterpriseSite struct. -func (hes *HcxEnterpriseSite) 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 "properties": - if v != nil { - var hcxEnterpriseSiteProperties HcxEnterpriseSiteProperties - err = json.Unmarshal(*v, &hcxEnterpriseSiteProperties) - if err != nil { - return err - } - hes.HcxEnterpriseSiteProperties = &hcxEnterpriseSiteProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - hes.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - hes.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - hes.Type = &typeVar - } - } - } - - return nil -} - -// HcxEnterpriseSiteList a paged list of HCX Enterprise Sites -type HcxEnterpriseSiteList struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The items on a page - Value *[]HcxEnterpriseSite `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next page if any - NextLink *string `json:"nextLink,omitempty"` -} - -// HcxEnterpriseSiteListIterator provides access to a complete listing of HcxEnterpriseSite values. -type HcxEnterpriseSiteListIterator struct { - i int - page HcxEnterpriseSiteListPage -} - -// 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 *HcxEnterpriseSiteListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListIterator.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 *HcxEnterpriseSiteListIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter HcxEnterpriseSiteListIterator) 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 HcxEnterpriseSiteListIterator) Response() HcxEnterpriseSiteList { - 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 HcxEnterpriseSiteListIterator) Value() HcxEnterpriseSite { - if !iter.page.NotDone() { - return HcxEnterpriseSite{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the HcxEnterpriseSiteListIterator type. -func NewHcxEnterpriseSiteListIterator(page HcxEnterpriseSiteListPage) HcxEnterpriseSiteListIterator { - return HcxEnterpriseSiteListIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (hesl HcxEnterpriseSiteList) IsEmpty() bool { - return hesl.Value == nil || len(*hesl.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (hesl HcxEnterpriseSiteList) hasNextLink() bool { - return hesl.NextLink != nil && len(*hesl.NextLink) != 0 -} - -// hcxEnterpriseSiteListPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (hesl HcxEnterpriseSiteList) hcxEnterpriseSiteListPreparer(ctx context.Context) (*http.Request, error) { - if !hesl.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(hesl.NextLink))) -} - -// HcxEnterpriseSiteListPage contains a page of HcxEnterpriseSite values. -type HcxEnterpriseSiteListPage struct { - fn func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error) - hesl HcxEnterpriseSiteList -} - -// 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 *HcxEnterpriseSiteListPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListPage.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.hesl) - if err != nil { - return err - } - page.hesl = 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 *HcxEnterpriseSiteListPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page HcxEnterpriseSiteListPage) NotDone() bool { - return !page.hesl.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page HcxEnterpriseSiteListPage) Response() HcxEnterpriseSiteList { - return page.hesl -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page HcxEnterpriseSiteListPage) Values() []HcxEnterpriseSite { - if page.hesl.IsEmpty() { - return nil - } - return *page.hesl.Value -} - -// Creates a new instance of the HcxEnterpriseSiteListPage type. -func NewHcxEnterpriseSiteListPage(getNextPage func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error)) HcxEnterpriseSiteListPage { - return HcxEnterpriseSiteListPage{fn: getNextPage} -} - -// HcxEnterpriseSiteProperties the properties of an HCX Enterprise Site -type HcxEnterpriseSiteProperties struct { - // ActivationKey - READ-ONLY; The activation key - ActivationKey *string `json:"activationKey,omitempty"` - // Status - READ-ONLY; The status of the HCX Enterprise Site. Possible values include: 'Available', 'Consumed', 'Deactivated', 'Deleted' - Status HcxEnterpriseSiteStatus `json:"status,omitempty"` -} - -// IdentitySource vCenter Single Sign On Identity Source -type IdentitySource struct { - // Name - The name of the identity source - Name *string `json:"name,omitempty"` - // Alias - The domain's NetBIOS name - Alias *string `json:"alias,omitempty"` - // Domain - The domain's dns name - Domain *string `json:"domain,omitempty"` - // BaseUserDN - The base distinguished name for users - BaseUserDN *string `json:"baseUserDN,omitempty"` - // BaseGroupDN - The base distinguished name for groups - BaseGroupDN *string `json:"baseGroupDN,omitempty"` - // PrimaryServer - Primary server URL - PrimaryServer *string `json:"primaryServer,omitempty"` - // SecondaryServer - Secondary server URL - SecondaryServer *string `json:"secondaryServer,omitempty"` - // Ssl - Protect LDAP communication using SSL certificate (LDAPS). Possible values include: 'SslEnumEnabled', 'SslEnumDisabled' - Ssl SslEnum `json:"ssl,omitempty"` - // Username - The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group - Username *string `json:"username,omitempty"` - // Password - The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. - Password *string `json:"password,omitempty"` -} - -// ManagementCluster the properties of a default cluster -type ManagementCluster struct { - // ClusterID - READ-ONLY; The identity - ClusterID *int32 `json:"clusterId,omitempty"` - // Hosts - READ-ONLY; The hosts - Hosts *[]string `json:"hosts,omitempty"` - // ClusterSize - The cluster size - ClusterSize *int32 `json:"clusterSize,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagementCluster. -func (mc ManagementCluster) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mc.ClusterSize != nil { - objectMap["clusterSize"] = mc.ClusterSize - } - return json.Marshal(objectMap) -} - -// Operation a REST API operation -type Operation struct { - // Name - READ-ONLY; Name of the operation being performed on this object - Name *string `json:"name,omitempty"` - // Display - READ-ONLY; Contains the localized display information for this operation - Display *OperationDisplay `json:"display,omitempty"` -} - -// OperationDisplay contains the localized display information for this operation -type OperationDisplay struct { - // Provider - READ-ONLY; Localized friendly form of the resource provider name - Provider *string `json:"provider,omitempty"` - // Resource - READ-ONLY; Localized friendly form of the resource type related to this operation - Resource *string `json:"resource,omitempty"` - // Operation - READ-ONLY; Localized friendly name for the operation - Operation *string `json:"operation,omitempty"` - // Description - READ-ONLY; Localized friendly description for the operation - Description *string `json:"description,omitempty"` -} - -// OperationList pageable list of operations -type OperationList struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of operations - Value *[]Operation `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next page if any - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationListIterator provides access to a complete listing of Operation values. -type OperationListIterator struct { - i int - page OperationListPage -} - -// 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 *OperationListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.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 *OperationListIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListIterator) 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 OperationListIterator) Response() OperationList { - 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 OperationListIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListIterator type. -func NewOperationListIterator(page OperationListPage) OperationListIterator { - return OperationListIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (ol OperationList) IsEmpty() bool { - return ol.Value == nil || len(*ol.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (ol OperationList) hasNextLink() bool { - return ol.NextLink != nil && len(*ol.NextLink) != 0 -} - -// operationListPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { - if !ol.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(ol.NextLink))) -} - -// OperationListPage contains a page of Operation values. -type OperationListPage struct { - fn func(context.Context, OperationList) (OperationList, error) - ol OperationList -} - -// 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 *OperationListPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.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.ol) - if err != nil { - return err - } - page.ol = 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 *OperationListPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListPage) NotDone() bool { - return !page.ol.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListPage) Response() OperationList { - return page.ol -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListPage) Values() []Operation { - if page.ol.IsEmpty() { - return nil - } - return *page.ol.Value -} - -// Creates a new instance of the OperationListPage type. -func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { - return OperationListPage{fn: getNextPage} -} - -// PrivateCloud a private cloud resource -type PrivateCloud struct { - autorest.Response `json:"-"` - // Sku - The private cloud SKU - Sku *Sku `json:"sku,omitempty"` - // PrivateCloudProperties - The properties of a private cloud resource - *PrivateCloudProperties `json:"properties,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // 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"` -} - -// MarshalJSON is the custom marshaler for PrivateCloud. -func (pc PrivateCloud) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pc.Sku != nil { - objectMap["sku"] = pc.Sku - } - if pc.PrivateCloudProperties != nil { - objectMap["properties"] = pc.PrivateCloudProperties - } - if pc.Location != nil { - objectMap["location"] = pc.Location - } - if pc.Tags != nil { - objectMap["tags"] = pc.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateCloud struct. -func (pc *PrivateCloud) 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 "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - pc.Sku = &sku - } - case "properties": - if v != nil { - var privateCloudProperties PrivateCloudProperties - err = json.Unmarshal(*v, &privateCloudProperties) - if err != nil { - return err - } - pc.PrivateCloudProperties = &privateCloudProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - pc.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - pc.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - pc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - pc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - pc.Type = &typeVar - } - } - } - - return nil -} - -// PrivateCloudList a paged list of private clouds -type PrivateCloudList struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The items on the page - Value *[]PrivateCloud `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next page if any - NextLink *string `json:"nextLink,omitempty"` -} - -// PrivateCloudListIterator provides access to a complete listing of PrivateCloud values. -type PrivateCloudListIterator struct { - i int - page PrivateCloudListPage -} - -// 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 *PrivateCloudListIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListIterator.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 *PrivateCloudListIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter PrivateCloudListIterator) 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 PrivateCloudListIterator) Response() PrivateCloudList { - 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 PrivateCloudListIterator) Value() PrivateCloud { - if !iter.page.NotDone() { - return PrivateCloud{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the PrivateCloudListIterator type. -func NewPrivateCloudListIterator(page PrivateCloudListPage) PrivateCloudListIterator { - return PrivateCloudListIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (pcl PrivateCloudList) IsEmpty() bool { - return pcl.Value == nil || len(*pcl.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (pcl PrivateCloudList) hasNextLink() bool { - return pcl.NextLink != nil && len(*pcl.NextLink) != 0 -} - -// privateCloudListPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (pcl PrivateCloudList) privateCloudListPreparer(ctx context.Context) (*http.Request, error) { - if !pcl.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(pcl.NextLink))) -} - -// PrivateCloudListPage contains a page of PrivateCloud values. -type PrivateCloudListPage struct { - fn func(context.Context, PrivateCloudList) (PrivateCloudList, error) - pcl PrivateCloudList -} - -// 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 *PrivateCloudListPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListPage.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.pcl) - if err != nil { - return err - } - page.pcl = 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 *PrivateCloudListPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page PrivateCloudListPage) NotDone() bool { - return !page.pcl.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page PrivateCloudListPage) Response() PrivateCloudList { - return page.pcl -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page PrivateCloudListPage) Values() []PrivateCloud { - if page.pcl.IsEmpty() { - return nil - } - return *page.pcl.Value -} - -// Creates a new instance of the PrivateCloudListPage type. -func NewPrivateCloudListPage(getNextPage func(context.Context, PrivateCloudList) (PrivateCloudList, error)) PrivateCloudListPage { - return PrivateCloudListPage{fn: getNextPage} -} - -// PrivateCloudProperties the properties of a private cloud resource -type PrivateCloudProperties struct { - // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'PrivateCloudProvisioningStateSucceeded', 'PrivateCloudProvisioningStateFailed', 'PrivateCloudProvisioningStateCancelled', 'PrivateCloudProvisioningStatePending', 'PrivateCloudProvisioningStateBuilding', 'PrivateCloudProvisioningStateDeleting', 'PrivateCloudProvisioningStateUpdating' - ProvisioningState PrivateCloudProvisioningState `json:"provisioningState,omitempty"` - // Circuit - An ExpressRoute Circuit - Circuit *Circuit `json:"circuit,omitempty"` - // Endpoints - READ-ONLY; The endpoints - Endpoints *Endpoints `json:"endpoints,omitempty"` - // NetworkBlock - The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22 - NetworkBlock *string `json:"networkBlock,omitempty"` - // ManagementNetwork - READ-ONLY; Network used to access vCenter Server and NSX-T Manager - ManagementNetwork *string `json:"managementNetwork,omitempty"` - // ProvisioningNetwork - READ-ONLY; Used for virtual machine cold migration, cloning, and snapshot migration - ProvisioningNetwork *string `json:"provisioningNetwork,omitempty"` - // VmotionNetwork - READ-ONLY; Used for live migration of virtual machines - VmotionNetwork *string `json:"vmotionNetwork,omitempty"` - // VcenterPassword - Optionally, set the vCenter admin password when the private cloud is created - VcenterPassword *string `json:"vcenterPassword,omitempty"` - // NsxtPassword - Optionally, set the NSX-T Manager password when the private cloud is created - NsxtPassword *string `json:"nsxtPassword,omitempty"` - // VcenterCertificateThumbprint - READ-ONLY; Thumbprint of the vCenter Server SSL certificate - VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty"` - // NsxtCertificateThumbprint - READ-ONLY; Thumbprint of the NSX-T Manager SSL certificate - NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty"` - // ManagementCluster - The default cluster used for management - ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` - // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' - Internet InternetEnum `json:"internet,omitempty"` - // IdentitySources - vCenter Single Sign On Identity Sources - IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateCloudProperties. -func (pcp PrivateCloudProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pcp.Circuit != nil { - objectMap["circuit"] = pcp.Circuit - } - if pcp.NetworkBlock != nil { - objectMap["networkBlock"] = pcp.NetworkBlock - } - if pcp.VcenterPassword != nil { - objectMap["vcenterPassword"] = pcp.VcenterPassword - } - if pcp.NsxtPassword != nil { - objectMap["nsxtPassword"] = pcp.NsxtPassword - } - if pcp.ManagementCluster != nil { - objectMap["managementCluster"] = pcp.ManagementCluster - } - if pcp.Internet != "" { - objectMap["internet"] = pcp.Internet - } - if pcp.IdentitySources != nil { - objectMap["identitySources"] = pcp.IdentitySources - } - return json.Marshal(objectMap) -} - -// PrivateCloudsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type PrivateCloudsCreateOrUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *PrivateCloudsCreateOrUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { - pc, err = client.CreateOrUpdateResponder(pc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") - } - } - return -} - -// PrivateCloudsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type PrivateCloudsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *PrivateCloudsDeleteFuture) Result(client PrivateCloudsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// PrivateCloudsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type PrivateCloudsUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *PrivateCloudsUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { - pc, err = client.UpdateResponder(pc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") - } - } - return -} - -// PrivateCloudUpdate an update to a private cloud resource -type PrivateCloudUpdate struct { - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // PrivateCloudUpdateProperties - The updatable properties of a private cloud resource - *PrivateCloudUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateCloudUpdate. -func (pcu PrivateCloudUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pcu.Tags != nil { - objectMap["tags"] = pcu.Tags - } - if pcu.PrivateCloudUpdateProperties != nil { - objectMap["properties"] = pcu.PrivateCloudUpdateProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateCloudUpdate struct. -func (pcu *PrivateCloudUpdate) 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 - } - pcu.Tags = tags - } - case "properties": - if v != nil { - var privateCloudUpdateProperties PrivateCloudUpdateProperties - err = json.Unmarshal(*v, &privateCloudUpdateProperties) - if err != nil { - return err - } - pcu.PrivateCloudUpdateProperties = &privateCloudUpdateProperties - } - } - } - - return nil -} - -// PrivateCloudUpdateProperties the properties of a private cloud resource that may be updated -type PrivateCloudUpdateProperties struct { - // ManagementCluster - The default cluster used for management - ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` - // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' - Internet InternetEnum `json:"internet,omitempty"` - // IdentitySources - vCenter Single Sign On Identity Sources - IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` -} - -// Quota subscription quotas -type Quota struct { - autorest.Response `json:"-"` - // HostsRemaining - READ-ONLY; Remaining hosts quota by sku type - HostsRemaining map[string]*int32 `json:"hostsRemaining"` - // QuotaEnabled - READ-ONLY; Host quota is active for current subscription. Possible values include: 'QuotaEnabledEnabled', 'QuotaEnabledDisabled' - QuotaEnabled QuotaEnabled `json:"quotaEnabled,omitempty"` -} - -// MarshalJSON is the custom marshaler for Quota. -func (q Quota) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// Resource the core properties of ARM resources -type Resource struct { - // 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"` -} - -// Sku the resource model definition representing SKU -type Sku struct { - // Name - The name of the SKU. - Name *string `json:"name,omitempty"` -} - -// TrackedResource the resource model definition for a ARM tracked top level resource -type TrackedResource struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // 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"` -} - -// MarshalJSON is the custom marshaler for TrackedResource. -func (tr TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tr.Location != nil { - objectMap["location"] = tr.Location - } - if tr.Tags != nil { - objectMap["tags"] = tr.Tags - } - return json.Marshal(objectMap) -} - -// Trial subscription trial availability -type Trial struct { - autorest.Response `json:"-"` - // Status - READ-ONLY; Trial status. Possible values include: 'TrialAvailable', 'TrialUsed', 'TrialDisabled' - Status TrialStatus `json:"status,omitempty"` - // AvailableHosts - READ-ONLY; Number of trial hosts available - AvailableHosts *int32 `json:"availableHosts,omitempty"` -} +package avs + +// 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/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/avs/mgmt/2020-03-20/avs" + +// ClusterProvisioningState enumerates the values for cluster provisioning state. +type ClusterProvisioningState string + +const ( + // Cancelled ... + Cancelled ClusterProvisioningState = "Cancelled" + // Deleting ... + Deleting ClusterProvisioningState = "Deleting" + // Failed ... + Failed ClusterProvisioningState = "Failed" + // Succeeded ... + Succeeded ClusterProvisioningState = "Succeeded" + // Updating ... + Updating ClusterProvisioningState = "Updating" +) + +// PossibleClusterProvisioningStateValues returns an array of possible values for the ClusterProvisioningState const type. +func PossibleClusterProvisioningStateValues() []ClusterProvisioningState { + return []ClusterProvisioningState{Cancelled, Deleting, Failed, Succeeded, Updating} +} + +// ExpressRouteAuthorizationProvisioningState enumerates the values for express route authorization +// provisioning state. +type ExpressRouteAuthorizationProvisioningState string + +const ( + // ExpressRouteAuthorizationProvisioningStateFailed ... + ExpressRouteAuthorizationProvisioningStateFailed ExpressRouteAuthorizationProvisioningState = "Failed" + // ExpressRouteAuthorizationProvisioningStateSucceeded ... + ExpressRouteAuthorizationProvisioningStateSucceeded ExpressRouteAuthorizationProvisioningState = "Succeeded" + // ExpressRouteAuthorizationProvisioningStateUpdating ... + ExpressRouteAuthorizationProvisioningStateUpdating ExpressRouteAuthorizationProvisioningState = "Updating" +) + +// PossibleExpressRouteAuthorizationProvisioningStateValues returns an array of possible values for the ExpressRouteAuthorizationProvisioningState const type. +func PossibleExpressRouteAuthorizationProvisioningStateValues() []ExpressRouteAuthorizationProvisioningState { + return []ExpressRouteAuthorizationProvisioningState{ExpressRouteAuthorizationProvisioningStateFailed, ExpressRouteAuthorizationProvisioningStateSucceeded, ExpressRouteAuthorizationProvisioningStateUpdating} +} + +// HcxEnterpriseSiteStatus enumerates the values for hcx enterprise site status. +type HcxEnterpriseSiteStatus string + +const ( + // Available ... + Available HcxEnterpriseSiteStatus = "Available" + // Consumed ... + Consumed HcxEnterpriseSiteStatus = "Consumed" + // Deactivated ... + Deactivated HcxEnterpriseSiteStatus = "Deactivated" + // Deleted ... + Deleted HcxEnterpriseSiteStatus = "Deleted" +) + +// PossibleHcxEnterpriseSiteStatusValues returns an array of possible values for the HcxEnterpriseSiteStatus const type. +func PossibleHcxEnterpriseSiteStatusValues() []HcxEnterpriseSiteStatus { + return []HcxEnterpriseSiteStatus{Available, Consumed, Deactivated, Deleted} +} + +// InternetEnum enumerates the values for internet enum. +type InternetEnum string + +const ( + // Disabled ... + Disabled InternetEnum = "Disabled" + // Enabled ... + Enabled InternetEnum = "Enabled" +) + +// PossibleInternetEnumValues returns an array of possible values for the InternetEnum const type. +func PossibleInternetEnumValues() []InternetEnum { + return []InternetEnum{Disabled, Enabled} +} + +// PrivateCloudProvisioningState enumerates the values for private cloud provisioning state. +type PrivateCloudProvisioningState string + +const ( + // PrivateCloudProvisioningStateBuilding ... + PrivateCloudProvisioningStateBuilding PrivateCloudProvisioningState = "Building" + // PrivateCloudProvisioningStateCancelled ... + PrivateCloudProvisioningStateCancelled PrivateCloudProvisioningState = "Cancelled" + // PrivateCloudProvisioningStateDeleting ... + PrivateCloudProvisioningStateDeleting PrivateCloudProvisioningState = "Deleting" + // PrivateCloudProvisioningStateFailed ... + PrivateCloudProvisioningStateFailed PrivateCloudProvisioningState = "Failed" + // PrivateCloudProvisioningStatePending ... + PrivateCloudProvisioningStatePending PrivateCloudProvisioningState = "Pending" + // PrivateCloudProvisioningStateSucceeded ... + PrivateCloudProvisioningStateSucceeded PrivateCloudProvisioningState = "Succeeded" + // PrivateCloudProvisioningStateUpdating ... + PrivateCloudProvisioningStateUpdating PrivateCloudProvisioningState = "Updating" +) + +// PossiblePrivateCloudProvisioningStateValues returns an array of possible values for the PrivateCloudProvisioningState const type. +func PossiblePrivateCloudProvisioningStateValues() []PrivateCloudProvisioningState { + return []PrivateCloudProvisioningState{PrivateCloudProvisioningStateBuilding, PrivateCloudProvisioningStateCancelled, PrivateCloudProvisioningStateDeleting, PrivateCloudProvisioningStateFailed, PrivateCloudProvisioningStatePending, PrivateCloudProvisioningStateSucceeded, PrivateCloudProvisioningStateUpdating} +} + +// QuotaEnabled enumerates the values for quota enabled. +type QuotaEnabled string + +const ( + // QuotaEnabledDisabled ... + QuotaEnabledDisabled QuotaEnabled = "Disabled" + // QuotaEnabledEnabled ... + QuotaEnabledEnabled QuotaEnabled = "Enabled" +) + +// PossibleQuotaEnabledValues returns an array of possible values for the QuotaEnabled const type. +func PossibleQuotaEnabledValues() []QuotaEnabled { + return []QuotaEnabled{QuotaEnabledDisabled, QuotaEnabledEnabled} +} + +// SslEnum enumerates the values for ssl enum. +type SslEnum string + +const ( + // SslEnumDisabled ... + SslEnumDisabled SslEnum = "Disabled" + // SslEnumEnabled ... + SslEnumEnabled SslEnum = "Enabled" +) + +// PossibleSslEnumValues returns an array of possible values for the SslEnum const type. +func PossibleSslEnumValues() []SslEnum { + return []SslEnum{SslEnumDisabled, SslEnumEnabled} +} + +// TrialStatus enumerates the values for trial status. +type TrialStatus string + +const ( + // TrialAvailable ... + TrialAvailable TrialStatus = "TrialAvailable" + // TrialDisabled ... + TrialDisabled TrialStatus = "TrialDisabled" + // TrialUsed ... + TrialUsed TrialStatus = "TrialUsed" +) + +// PossibleTrialStatusValues returns an array of possible values for the TrialStatus const type. +func PossibleTrialStatusValues() []TrialStatus { + return []TrialStatus{TrialAvailable, TrialDisabled, TrialUsed} +} + +// AdminCredentials administrative credentials for accessing vCenter and NSX-T +type AdminCredentials struct { + autorest.Response `json:"-"` + // NsxtUsername - READ-ONLY; NSX-T Manager username + NsxtUsername *string `json:"nsxtUsername,omitempty"` + // NsxtPassword - READ-ONLY; NSX-T Manager password + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterUsername - READ-ONLY; vCenter admin username + VcenterUsername *string `json:"vcenterUsername,omitempty"` + // VcenterPassword - READ-ONLY; vCenter admin password + VcenterPassword *string `json:"vcenterPassword,omitempty"` +} + +// AuthorizationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AuthorizationsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AuthorizationsCreateOrUpdateFuture) Result(client AuthorizationsClient) (era ExpressRouteAuthorization, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if era.Response.Response, err = future.GetResult(sender); err == nil && era.Response.Response.StatusCode != http.StatusNoContent { + era, err = client.CreateOrUpdateResponder(era.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsCreateOrUpdateFuture", "Result", era.Response.Response, "Failure responding to request") + } + } + return +} + +// AuthorizationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AuthorizationsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AuthorizationsDeleteFuture) Result(client AuthorizationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.AuthorizationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.AuthorizationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Circuit an ExpressRoute Circuit +type Circuit struct { + // PrimarySubnet - READ-ONLY; CIDR of primary subnet + PrimarySubnet *string `json:"primarySubnet,omitempty"` + // SecondarySubnet - READ-ONLY; CIDR of secondary subnet + SecondarySubnet *string `json:"secondarySubnet,omitempty"` + // ExpressRouteID - READ-ONLY; Identifier of the ExpressRoute Circuit (Microsoft Colo only) + ExpressRouteID *string `json:"expressRouteID,omitempty"` + // ExpressRoutePrivatePeeringID - READ-ONLY; ExpressRoute Circuit private peering identifier + ExpressRoutePrivatePeeringID *string `json:"expressRoutePrivatePeeringID,omitempty"` +} + +// CloudError API error response +type CloudError struct { + // Error - An error returned by the API + Error *ErrorResponse `json:"error,omitempty"` +} + +// Cluster a cluster resource +type Cluster struct { + autorest.Response `json:"-"` + // Sku - The cluster SKU + Sku *Sku `json:"sku,omitempty"` + // ClusterProperties - The properties of a cluster resource + *ClusterProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ClusterList a paged list of clusters +type ClusterList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]Cluster `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterListIterator provides access to a complete listing of Cluster values. +type ClusterListIterator struct { + i int + page ClusterListPage +} + +// 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 *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.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 *ClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClusterListIterator) 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 ClusterListIterator) Response() ClusterList { + 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 ClusterListIterator) Value() Cluster { + if !iter.page.NotDone() { + return Cluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClusterListIterator type. +func NewClusterListIterator(page ClusterListPage) ClusterListIterator { + return ClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ClusterList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// clusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { + if cl.NextLink == nil || len(to.String(cl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ClusterListPage contains a page of Cluster values. +type ClusterListPage struct { + fn func(context.Context, ClusterList) (ClusterList, error) + cl ClusterList +} + +// 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 *ClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + 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 *ClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClusterListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClusterListPage) Response() ClusterList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClusterListPage) Values() []Cluster { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ClusterListPage type. +func NewClusterListPage(getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { + return ClusterListPage{fn: getNextPage} +} + +// ClusterProperties the properties of a cluster +type ClusterProperties struct { + // ProvisioningState - READ-ONLY; The state of the cluster provisioning. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Deleting', 'Updating' + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// ClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersCreateOrUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateOrUpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersDeleteFuture) Result(client ClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.ClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.ClustersUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClusterUpdate an update of a cluster resource +type ClusterUpdate struct { + // ClusterUpdateProperties - The properties of a cluster resource that may be updated + *ClusterUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterUpdate. +func (cu ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cu.ClusterUpdateProperties != nil { + objectMap["properties"] = cu.ClusterUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterUpdate struct. +func (cu *ClusterUpdate) 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 "properties": + if v != nil { + var clusterUpdateProperties ClusterUpdateProperties + err = json.Unmarshal(*v, &clusterUpdateProperties) + if err != nil { + return err + } + cu.ClusterUpdateProperties = &clusterUpdateProperties + } + } + } + + return nil +} + +// ClusterUpdateProperties the properties of a cluster that may be updated +type ClusterUpdateProperties struct { + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// Endpoints endpoint addresses +type Endpoints struct { + // NsxtManager - READ-ONLY; Endpoint for the NSX-T Data Center manager + NsxtManager *string `json:"nsxtManager,omitempty"` + // Vcsa - READ-ONLY; Endpoint for Virtual Center Server Appliance + Vcsa *string `json:"vcsa,omitempty"` + // HcxCloudManager - READ-ONLY; Endpoint for the HCX Cloud Manager + HcxCloudManager *string `json:"hcxCloudManager,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorResponse the resource management error response. +type ErrorResponse struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ExpressRouteAuthorization expressRoute Circuit Authorization +type ExpressRouteAuthorization struct { + autorest.Response `json:"-"` + // ExpressRouteAuthorizationProperties - The properties of an ExpressRoute Circuit Authorization resource + *ExpressRouteAuthorizationProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for ExpressRouteAuthorization. +func (era ExpressRouteAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if era.ExpressRouteAuthorizationProperties != nil { + objectMap["properties"] = era.ExpressRouteAuthorizationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExpressRouteAuthorization struct. +func (era *ExpressRouteAuthorization) 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 "properties": + if v != nil { + var expressRouteAuthorizationProperties ExpressRouteAuthorizationProperties + err = json.Unmarshal(*v, &expressRouteAuthorizationProperties) + if err != nil { + return err + } + era.ExpressRouteAuthorizationProperties = &expressRouteAuthorizationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + era.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + era.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + era.Type = &typeVar + } + } + } + + return nil +} + +// ExpressRouteAuthorizationList a paged list of ExpressRoute Circuit Authorizations +type ExpressRouteAuthorizationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]ExpressRouteAuthorization `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// ExpressRouteAuthorizationListIterator provides access to a complete listing of ExpressRouteAuthorization +// values. +type ExpressRouteAuthorizationListIterator struct { + i int + page ExpressRouteAuthorizationListPage +} + +// 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 *ExpressRouteAuthorizationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListIterator.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 *ExpressRouteAuthorizationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExpressRouteAuthorizationListIterator) 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 ExpressRouteAuthorizationListIterator) Response() ExpressRouteAuthorizationList { + 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 ExpressRouteAuthorizationListIterator) Value() ExpressRouteAuthorization { + if !iter.page.NotDone() { + return ExpressRouteAuthorization{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExpressRouteAuthorizationListIterator type. +func NewExpressRouteAuthorizationListIterator(page ExpressRouteAuthorizationListPage) ExpressRouteAuthorizationListIterator { + return ExpressRouteAuthorizationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eral ExpressRouteAuthorizationList) IsEmpty() bool { + return eral.Value == nil || len(*eral.Value) == 0 +} + +// expressRouteAuthorizationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eral ExpressRouteAuthorizationList) expressRouteAuthorizationListPreparer(ctx context.Context) (*http.Request, error) { + if eral.NextLink == nil || len(to.String(eral.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eral.NextLink))) +} + +// ExpressRouteAuthorizationListPage contains a page of ExpressRouteAuthorization values. +type ExpressRouteAuthorizationListPage struct { + fn func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error) + eral ExpressRouteAuthorizationList +} + +// 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 *ExpressRouteAuthorizationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExpressRouteAuthorizationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.eral) + if err != nil { + return err + } + page.eral = next + 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 *ExpressRouteAuthorizationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExpressRouteAuthorizationListPage) NotDone() bool { + return !page.eral.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExpressRouteAuthorizationListPage) Response() ExpressRouteAuthorizationList { + return page.eral +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExpressRouteAuthorizationListPage) Values() []ExpressRouteAuthorization { + if page.eral.IsEmpty() { + return nil + } + return *page.eral.Value +} + +// Creates a new instance of the ExpressRouteAuthorizationListPage type. +func NewExpressRouteAuthorizationListPage(getNextPage func(context.Context, ExpressRouteAuthorizationList) (ExpressRouteAuthorizationList, error)) ExpressRouteAuthorizationListPage { + return ExpressRouteAuthorizationListPage{fn: getNextPage} +} + +// ExpressRouteAuthorizationProperties the properties of an ExpressRoute Circuit Authorization resource +type ExpressRouteAuthorizationProperties struct { + // ProvisioningState - READ-ONLY; The state of the ExpressRoute Circuit Authorization provisioning. Possible values include: 'ExpressRouteAuthorizationProvisioningStateSucceeded', 'ExpressRouteAuthorizationProvisioningStateFailed', 'ExpressRouteAuthorizationProvisioningStateUpdating' + ProvisioningState ExpressRouteAuthorizationProvisioningState `json:"provisioningState,omitempty"` + // ExpressRouteAuthorizationID - READ-ONLY; The ID of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationID *string `json:"expressRouteAuthorizationId,omitempty"` + // ExpressRouteAuthorizationKey - READ-ONLY; The key of the ExpressRoute Circuit Authorization + ExpressRouteAuthorizationKey *string `json:"expressRouteAuthorizationKey,omitempty"` +} + +// HcxEnterpriseSite an HCX Enterprise Site resource +type HcxEnterpriseSite struct { + autorest.Response `json:"-"` + // HcxEnterpriseSiteProperties - The properties of an HCX Enterprise Site resource + *HcxEnterpriseSiteProperties `json:"properties,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"` +} + +// MarshalJSON is the custom marshaler for HcxEnterpriseSite. +func (hes HcxEnterpriseSite) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hes.HcxEnterpriseSiteProperties != nil { + objectMap["properties"] = hes.HcxEnterpriseSiteProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HcxEnterpriseSite struct. +func (hes *HcxEnterpriseSite) 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 "properties": + if v != nil { + var hcxEnterpriseSiteProperties HcxEnterpriseSiteProperties + err = json.Unmarshal(*v, &hcxEnterpriseSiteProperties) + if err != nil { + return err + } + hes.HcxEnterpriseSiteProperties = &hcxEnterpriseSiteProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hes.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hes.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hes.Type = &typeVar + } + } + } + + return nil +} + +// HcxEnterpriseSiteList a paged list of HCX Enterprise Sites +type HcxEnterpriseSiteList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on a page + Value *[]HcxEnterpriseSite `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// HcxEnterpriseSiteListIterator provides access to a complete listing of HcxEnterpriseSite values. +type HcxEnterpriseSiteListIterator struct { + i int + page HcxEnterpriseSiteListPage +} + +// 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 *HcxEnterpriseSiteListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListIterator.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 *HcxEnterpriseSiteListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HcxEnterpriseSiteListIterator) 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 HcxEnterpriseSiteListIterator) Response() HcxEnterpriseSiteList { + 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 HcxEnterpriseSiteListIterator) Value() HcxEnterpriseSite { + if !iter.page.NotDone() { + return HcxEnterpriseSite{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the HcxEnterpriseSiteListIterator type. +func NewHcxEnterpriseSiteListIterator(page HcxEnterpriseSiteListPage) HcxEnterpriseSiteListIterator { + return HcxEnterpriseSiteListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (hesl HcxEnterpriseSiteList) IsEmpty() bool { + return hesl.Value == nil || len(*hesl.Value) == 0 +} + +// hcxEnterpriseSiteListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hesl HcxEnterpriseSiteList) hcxEnterpriseSiteListPreparer(ctx context.Context) (*http.Request, error) { + if hesl.NextLink == nil || len(to.String(hesl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hesl.NextLink))) +} + +// HcxEnterpriseSiteListPage contains a page of HcxEnterpriseSite values. +type HcxEnterpriseSiteListPage struct { + fn func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error) + hesl HcxEnterpriseSiteList +} + +// 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 *HcxEnterpriseSiteListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HcxEnterpriseSiteListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.hesl) + if err != nil { + return err + } + page.hesl = next + 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 *HcxEnterpriseSiteListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HcxEnterpriseSiteListPage) NotDone() bool { + return !page.hesl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HcxEnterpriseSiteListPage) Response() HcxEnterpriseSiteList { + return page.hesl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HcxEnterpriseSiteListPage) Values() []HcxEnterpriseSite { + if page.hesl.IsEmpty() { + return nil + } + return *page.hesl.Value +} + +// Creates a new instance of the HcxEnterpriseSiteListPage type. +func NewHcxEnterpriseSiteListPage(getNextPage func(context.Context, HcxEnterpriseSiteList) (HcxEnterpriseSiteList, error)) HcxEnterpriseSiteListPage { + return HcxEnterpriseSiteListPage{fn: getNextPage} +} + +// HcxEnterpriseSiteProperties the properties of an HCX Enterprise Site +type HcxEnterpriseSiteProperties struct { + // ActivationKey - READ-ONLY; The activation key + ActivationKey *string `json:"activationKey,omitempty"` + // Status - READ-ONLY; The status of the HCX Enterprise Site. Possible values include: 'Available', 'Consumed', 'Deactivated', 'Deleted' + Status HcxEnterpriseSiteStatus `json:"status,omitempty"` +} + +// IdentitySource vCenter Single Sign On Identity Source +type IdentitySource struct { + // Name - The name of the identity source + Name *string `json:"name,omitempty"` + // Alias - The domain's NetBIOS name + Alias *string `json:"alias,omitempty"` + // Domain - The domain's dns name + Domain *string `json:"domain,omitempty"` + // BaseUserDN - The base distinguished name for users + BaseUserDN *string `json:"baseUserDN,omitempty"` + // BaseGroupDN - The base distinguished name for groups + BaseGroupDN *string `json:"baseGroupDN,omitempty"` + // PrimaryServer - Primary server URL + PrimaryServer *string `json:"primaryServer,omitempty"` + // SecondaryServer - Secondary server URL + SecondaryServer *string `json:"secondaryServer,omitempty"` + // Ssl - Protect LDAP communication using SSL certificate (LDAPS). Possible values include: 'SslEnumEnabled', 'SslEnumDisabled' + Ssl SslEnum `json:"ssl,omitempty"` + // Username - The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group + Username *string `json:"username,omitempty"` + // Password - The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. + Password *string `json:"password,omitempty"` +} + +// ManagementCluster the properties of a default cluster +type ManagementCluster struct { + // ClusterID - READ-ONLY; The identity + ClusterID *int32 `json:"clusterId,omitempty"` + // Hosts - READ-ONLY; The hosts + Hosts *[]string `json:"hosts,omitempty"` + // ClusterSize - The cluster size + ClusterSize *int32 `json:"clusterSize,omitempty"` +} + +// Operation a REST API operation +type Operation struct { + // Name - READ-ONLY; Name of the operation being performed on this object + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; Contains the localized display information for this operation + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay contains the localized display information for this operation +type OperationDisplay struct { + // Provider - READ-ONLY; Localized friendly form of the resource provider name + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Localized friendly form of the resource type related to this operation + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// OperationList pageable list of operations +type OperationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// 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 *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.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 *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) 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 OperationListIterator) Response() OperationList { + 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 OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if ol.NextLink == nil || len(to.String(ol.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// 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 *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + 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 *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{fn: getNextPage} +} + +// PrivateCloud a private cloud resource +type PrivateCloud struct { + autorest.Response `json:"-"` + // Sku - The private cloud SKU + Sku *Sku `json:"sku,omitempty"` + // PrivateCloudProperties - The properties of a private cloud resource + *PrivateCloudProperties `json:"properties,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // 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"` +} + +// MarshalJSON is the custom marshaler for PrivateCloud. +func (pc PrivateCloud) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pc.Sku != nil { + objectMap["sku"] = pc.Sku + } + if pc.PrivateCloudProperties != nil { + objectMap["properties"] = pc.PrivateCloudProperties + } + if pc.Location != nil { + objectMap["location"] = pc.Location + } + if pc.Tags != nil { + objectMap["tags"] = pc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloud struct. +func (pc *PrivateCloud) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + pc.Sku = &sku + } + case "properties": + if v != nil { + var privateCloudProperties PrivateCloudProperties + err = json.Unmarshal(*v, &privateCloudProperties) + if err != nil { + return err + } + pc.PrivateCloudProperties = &privateCloudProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + pc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + pc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pc.Type = &typeVar + } + } + } + + return nil +} + +// PrivateCloudList a paged list of private clouds +type PrivateCloudList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The items on the page + Value *[]PrivateCloud `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next page if any + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateCloudListIterator provides access to a complete listing of PrivateCloud values. +type PrivateCloudListIterator struct { + i int + page PrivateCloudListPage +} + +// 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 *PrivateCloudListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListIterator.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 *PrivateCloudListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateCloudListIterator) 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 PrivateCloudListIterator) Response() PrivateCloudList { + 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 PrivateCloudListIterator) Value() PrivateCloud { + if !iter.page.NotDone() { + return PrivateCloud{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateCloudListIterator type. +func NewPrivateCloudListIterator(page PrivateCloudListPage) PrivateCloudListIterator { + return PrivateCloudListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pcl PrivateCloudList) IsEmpty() bool { + return pcl.Value == nil || len(*pcl.Value) == 0 +} + +// privateCloudListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pcl PrivateCloudList) privateCloudListPreparer(ctx context.Context) (*http.Request, error) { + if pcl.NextLink == nil || len(to.String(pcl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pcl.NextLink))) +} + +// PrivateCloudListPage contains a page of PrivateCloud values. +type PrivateCloudListPage struct { + fn func(context.Context, PrivateCloudList) (PrivateCloudList, error) + pcl PrivateCloudList +} + +// 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 *PrivateCloudListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.pcl) + if err != nil { + return err + } + page.pcl = next + 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 *PrivateCloudListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateCloudListPage) NotDone() bool { + return !page.pcl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateCloudListPage) Response() PrivateCloudList { + return page.pcl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateCloudListPage) Values() []PrivateCloud { + if page.pcl.IsEmpty() { + return nil + } + return *page.pcl.Value +} + +// Creates a new instance of the PrivateCloudListPage type. +func NewPrivateCloudListPage(getNextPage func(context.Context, PrivateCloudList) (PrivateCloudList, error)) PrivateCloudListPage { + return PrivateCloudListPage{fn: getNextPage} +} + +// PrivateCloudProperties the properties of a private cloud resource +type PrivateCloudProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'PrivateCloudProvisioningStateSucceeded', 'PrivateCloudProvisioningStateFailed', 'PrivateCloudProvisioningStateCancelled', 'PrivateCloudProvisioningStatePending', 'PrivateCloudProvisioningStateBuilding', 'PrivateCloudProvisioningStateDeleting', 'PrivateCloudProvisioningStateUpdating' + ProvisioningState PrivateCloudProvisioningState `json:"provisioningState,omitempty"` + // Circuit - An ExpressRoute Circuit + Circuit *Circuit `json:"circuit,omitempty"` + // Endpoints - READ-ONLY; The endpoints + Endpoints *Endpoints `json:"endpoints,omitempty"` + // NetworkBlock - The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22 + NetworkBlock *string `json:"networkBlock,omitempty"` + // ManagementNetwork - READ-ONLY; Network used to access vCenter Server and NSX-T Manager + ManagementNetwork *string `json:"managementNetwork,omitempty"` + // ProvisioningNetwork - READ-ONLY; Used for virtual machine cold migration, cloning, and snapshot migration + ProvisioningNetwork *string `json:"provisioningNetwork,omitempty"` + // VmotionNetwork - READ-ONLY; Used for live migration of virtual machines + VmotionNetwork *string `json:"vmotionNetwork,omitempty"` + // VcenterPassword - Optionally, set the vCenter admin password when the private cloud is created + VcenterPassword *string `json:"vcenterPassword,omitempty"` + // NsxtPassword - Optionally, set the NSX-T Manager password when the private cloud is created + NsxtPassword *string `json:"nsxtPassword,omitempty"` + // VcenterCertificateThumbprint - READ-ONLY; Thumbprint of the vCenter Server SSL certificate + VcenterCertificateThumbprint *string `json:"vcenterCertificateThumbprint,omitempty"` + // NsxtCertificateThumbprint - READ-ONLY; Thumbprint of the NSX-T Manager SSL certificate + NsxtCertificateThumbprint *string `json:"nsxtCertificateThumbprint,omitempty"` + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// PrivateCloudsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateCloudsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsCreateOrUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.CreateOrUpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsCreateOrUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsDeleteFuture) Result(client PrivateCloudsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateCloudsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateCloudsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateCloudsUpdateFuture) Result(client PrivateCloudsClient) (pc PrivateCloud, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("avs.PrivateCloudsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pc.Response.Response, err = future.GetResult(sender); err == nil && pc.Response.Response.StatusCode != http.StatusNoContent { + pc, err = client.UpdateResponder(pc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsUpdateFuture", "Result", pc.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateCloudUpdate an update to a private cloud resource +type PrivateCloudUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // PrivateCloudUpdateProperties - The updatable properties of a private cloud resource + *PrivateCloudUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateCloudUpdate. +func (pcu PrivateCloudUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pcu.Tags != nil { + objectMap["tags"] = pcu.Tags + } + if pcu.PrivateCloudUpdateProperties != nil { + objectMap["properties"] = pcu.PrivateCloudUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateCloudUpdate struct. +func (pcu *PrivateCloudUpdate) 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 + } + pcu.Tags = tags + } + case "properties": + if v != nil { + var privateCloudUpdateProperties PrivateCloudUpdateProperties + err = json.Unmarshal(*v, &privateCloudUpdateProperties) + if err != nil { + return err + } + pcu.PrivateCloudUpdateProperties = &privateCloudUpdateProperties + } + } + } + + return nil +} + +// PrivateCloudUpdateProperties the properties of a private cloud resource that may be updated +type PrivateCloudUpdateProperties struct { + // ManagementCluster - The default cluster used for management + ManagementCluster *ManagementCluster `json:"managementCluster,omitempty"` + // Internet - Connectivity to internet is enabled or disabled. Possible values include: 'Enabled', 'Disabled' + Internet InternetEnum `json:"internet,omitempty"` + // IdentitySources - vCenter Single Sign On Identity Sources + IdentitySources *[]IdentitySource `json:"identitySources,omitempty"` +} + +// Quota subscription quotas +type Quota struct { + autorest.Response `json:"-"` + // HostsRemaining - READ-ONLY; Remaining hosts quota by sku type + HostsRemaining map[string]*int32 `json:"hostsRemaining"` + // QuotaEnabled - READ-ONLY; Host quota is active for current subscription. Possible values include: 'QuotaEnabledEnabled', 'QuotaEnabledDisabled' + QuotaEnabled QuotaEnabled `json:"quotaEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for Quota. +func (q Quota) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource the core properties of ARM resources +type Resource struct { + // 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"` +} + +// Sku the resource model definition representing SKU +type Sku struct { + // Name - The name of the SKU. + Name *string `json:"name,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // 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"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// Trial subscription trial availability +type Trial struct { + autorest.Response `json:"-"` + // Status - READ-ONLY; Trial status. Possible values include: 'TrialAvailable', 'TrialUsed', 'TrialDisabled' + Status TrialStatus `json:"status,omitempty"` + // AvailableHosts - READ-ONLY; Number of trial hosts available + AvailableHosts *int32 `json:"availableHosts,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go index 765297556ad5..19476d3f8955 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/operations.go @@ -1,149 +1,146 @@ -package avs - -// 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/tracing" - "net/http" -) - -// OperationsClient is the azure VMware Solution API -type OperationsClient struct { - BaseClient -} - -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists all of the available operations -func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.ol.Response.Response != nil { - sc = result.ol.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.ol.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure sending request") - return - } - - result.ol, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure responding to request") - } - if result.ol.hasNextLink() && result.ol.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.AVS/operations"), - 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 OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { - req, err := lastResults.operationListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.OperationsClient", "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, "avs.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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) - return -} +package avs + +// 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/tracing" + "net/http" +) + +// OperationsClient is the azure VMware Solution API +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AVS/operations"), + 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 OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.OperationsClient", "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, "avs.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go index 82af8e23b5ba..c31ab8f53081 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/privateclouds.go @@ -1,719 +1,713 @@ -package avs - -// 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" -) - -// PrivateCloudsClient is the azure VMware Solution API -type PrivateCloudsClient struct { - BaseClient -} - -// NewPrivateCloudsClient creates an instance of the PrivateCloudsClient client. -func NewPrivateCloudsClient(subscriptionID string) PrivateCloudsClient { - return NewPrivateCloudsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPrivateCloudsClientWithBaseURI creates an instance of the PrivateCloudsClient 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 NewPrivateCloudsClientWithBaseURI(baseURI string, subscriptionID string) PrivateCloudsClient { - return PrivateCloudsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate sends the create or update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// privateCloud - the private cloud -func (client PrivateCloudsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (result PrivateCloudsCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, - {TargetValue: privateCloud, - Constraints: []validation.Constraint{{Target: "privateCloud.Sku", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "privateCloud.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, - {Target: "privateCloud.PrivateCloudProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "privateCloud.PrivateCloudProperties.NetworkBlock", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("avs.PrivateCloudsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloud) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client PrivateCloudsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", pathParameters), - autorest.WithJSON(privateCloud), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateCloudsClient) CreateOrUpdateSender(req *http.Request) (future PrivateCloudsCreateOrUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client PrivateCloudsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateCloud, 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 sends the delete request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client PrivateCloudsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client PrivateCloudsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) DeleteSender(req *http.Request) (future PrivateCloudsDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client PrivateCloudsClient) 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 sends the get request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client PrivateCloudsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloud, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client PrivateCloudsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) 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 PrivateCloudsClient) GetResponder(resp *http.Response) (result PrivateCloud, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List sends the list request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -func (client PrivateCloudsClient) List(ctx context.Context, resourceGroupName string) (result PrivateCloudListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.List") - defer func() { - sc := -1 - if result.pcl.Response.Response != nil { - sc = result.pcl.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.pcl.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure sending request") - return - } - - result.pcl, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure responding to request") - } - if result.pcl.hasNextLink() && result.pcl.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListPreparer prepares the List request. -func (client PrivateCloudsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds", 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 PrivateCloudsClient) 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 PrivateCloudsClient) ListResponder(resp *http.Response) (result PrivateCloudList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client PrivateCloudsClient) listNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { - req, err := lastResults.privateCloudListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "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, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client PrivateCloudsClient) ListComplete(ctx context.Context, resourceGroupName string) (result PrivateCloudListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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) - return -} - -// ListAdminCredentials sends the list admin credentials request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -func (client PrivateCloudsClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result AdminCredentials, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListAdminCredentials") - 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: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "ListAdminCredentials", err.Error()) - } - - req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, privateCloudName) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", nil, "Failure preparing request") - return - } - - resp, err := client.ListAdminCredentialsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure sending request") - return - } - - result, err = client.ListAdminCredentialsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure responding to request") - } - - return -} - -// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. -func (client PrivateCloudsClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateCloudsClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always -// closes the http.Response Body. -func (client PrivateCloudsClient) ListAdminCredentialsResponder(resp *http.Response) (result AdminCredentials, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListInSubscription sends the list in subscription request. -func (client PrivateCloudsClient) ListInSubscription(ctx context.Context) (result PrivateCloudListPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") - defer func() { - sc := -1 - if result.pcl.Response.Response != nil { - sc = result.pcl.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("avs.PrivateCloudsClient", "ListInSubscription", err.Error()) - } - - result.fn = client.listInSubscriptionNextResults - req, err := client.ListInSubscriptionPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") - return - } - - resp, err := client.ListInSubscriptionSender(req) - if err != nil { - result.pcl.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure sending request") - return - } - - result.pcl, err = client.ListInSubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure responding to request") - } - if result.pcl.hasNextLink() && result.pcl.IsEmpty() { - err = result.NextWithContext(ctx) - } - - return -} - -// ListInSubscriptionPreparer prepares the ListInSubscription request. -func (client PrivateCloudsClient) ListInSubscriptionPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListInSubscriptionSender sends the ListInSubscription request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateCloudsClient) ListInSubscriptionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListInSubscriptionResponder handles the response to the ListInSubscription request. The method always -// closes the http.Response Body. -func (client PrivateCloudsClient) ListInSubscriptionResponder(resp *http.Response) (result PrivateCloudList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listInSubscriptionNextResults retrieves the next set of results, if any. -func (client PrivateCloudsClient) listInSubscriptionNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { - req, err := lastResults.privateCloudListPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListInSubscriptionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure sending next results request") - } - result, err = client.ListInSubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListInSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. -func (client PrivateCloudsClient) ListInSubscriptionComplete(ctx context.Context) (result PrivateCloudListIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") - 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.ListInSubscription(ctx) - return -} - -// Update sends the update request. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// privateCloudName - name of the private cloud -// privateCloudUpdate - the private cloud properties to be updated -func (client PrivateCloudsClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (result PrivateCloudsUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloudUpdate) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client PrivateCloudsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "privateCloudName": autorest.Encode("path", privateCloudName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-03-20" - 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.AVS/privateClouds/{privateCloudName}", pathParameters), - autorest.WithJSON(privateCloudUpdate), - 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 PrivateCloudsClient) UpdateSender(req *http.Request) (future PrivateCloudsUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client PrivateCloudsClient) UpdateResponder(resp *http.Response) (result PrivateCloud, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} +package avs + +// 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" +) + +// PrivateCloudsClient is the azure VMware Solution API +type PrivateCloudsClient struct { + BaseClient +} + +// NewPrivateCloudsClient creates an instance of the PrivateCloudsClient client. +func NewPrivateCloudsClient(subscriptionID string) PrivateCloudsClient { + return NewPrivateCloudsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateCloudsClientWithBaseURI creates an instance of the PrivateCloudsClient 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 NewPrivateCloudsClientWithBaseURI(baseURI string, subscriptionID string) PrivateCloudsClient { + return PrivateCloudsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloud - the private cloud +func (client PrivateCloudsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (result PrivateCloudsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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}}}, + {TargetValue: privateCloud, + Constraints: []validation.Constraint{{Target: "privateCloud.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateCloud.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "privateCloud.PrivateCloudProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateCloud.PrivateCloudProperties.NetworkBlock", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloud) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateCloudsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloud PrivateCloud) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloud), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) CreateOrUpdateSender(req *http.Request) (future PrivateCloudsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateCloud, 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 sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Delete(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloudsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateCloudsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) DeleteSender(req *http.Request) (future PrivateCloudsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) Get(ctx context.Context, resourceGroupName string, privateCloudName string) (result PrivateCloud, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateCloudsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", 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 PrivateCloudsClient) 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 PrivateCloudsClient) GetResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateCloudsClient) List(ctx context.Context, resourceGroupName string) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.List") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateCloudsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds", 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 PrivateCloudsClient) 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 PrivateCloudsClient) ListResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "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, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListComplete(ctx context.Context, resourceGroupName string) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.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) + return +} + +// ListAdminCredentials sends the list admin credentials request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +func (client PrivateCloudsClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, privateCloudName string) (result AdminCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListAdminCredentials") + 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: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "ListAdminCredentials", err.Error()) + } + + req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, privateCloudName) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListAdminCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListAdminCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListAdminCredentials", resp, "Failure responding to request") + } + + return +} + +// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. +func (client PrivateCloudsClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListAdminCredentialsResponder(resp *http.Response) (result AdminCredentials, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListInSubscription sends the list in subscription request. +func (client PrivateCloudsClient) ListInSubscription(ctx context.Context) (result PrivateCloudListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + defer func() { + sc := -1 + if result.pcl.Response.Response != nil { + sc = result.pcl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("avs.PrivateCloudsClient", "ListInSubscription", err.Error()) + } + + result.fn = client.listInSubscriptionNextResults + req, err := client.ListInSubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.pcl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure sending request") + return + } + + result.pcl, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "ListInSubscription", resp, "Failure responding to request") + } + + return +} + +// ListInSubscriptionPreparer prepares the ListInSubscription request. +func (client PrivateCloudsClient) ListInSubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInSubscriptionSender sends the ListInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateCloudsClient) ListInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInSubscriptionResponder handles the response to the ListInSubscription request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) ListInSubscriptionResponder(resp *http.Response) (result PrivateCloudList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInSubscriptionNextResults retrieves the next set of results, if any. +func (client PrivateCloudsClient) listInSubscriptionNextResults(ctx context.Context, lastResults PrivateCloudList) (result PrivateCloudList, err error) { + req, err := lastResults.privateCloudListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "listInSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateCloudsClient) ListInSubscriptionComplete(ctx context.Context) (result PrivateCloudListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.ListInSubscription") + 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.ListInSubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// privateCloudName - name of the private cloud +// privateCloudUpdate - the private cloud properties to be updated +func (client PrivateCloudsClient) Update(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (result PrivateCloudsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateCloudsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, 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("avs.PrivateCloudsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, privateCloudName, privateCloudUpdate) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "avs.PrivateCloudsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateCloudsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, privateCloudName string, privateCloudUpdate PrivateCloudUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateCloudName": autorest.Encode("path", privateCloudName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-20" + 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.AVS/privateClouds/{privateCloudName}", pathParameters), + autorest.WithJSON(privateCloudUpdate), + 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 PrivateCloudsClient) UpdateSender(req *http.Request) (future PrivateCloudsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateCloudsClient) UpdateResponder(resp *http.Response) (result PrivateCloud, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go index 23307592c097..d683b8eba0a0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs/version.go @@ -1,30 +1,30 @@ -package avs - -import "github.com/Azure/azure-sdk-for-go/version" - -// 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. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " avs/2020-03-20" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} +package avs + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " avs/2020-03-20" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go index 6c20b8179ab0..59823831abaa 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go @@ -81,11 +81,11 @@ var ( ManagementPortalURL: "https://manage.windowsazure.com/", PublishSettingsURL: "https://manage.windowsazure.com/publishsettings/index", ServiceManagementEndpoint: "https://management.core.windows.net/", - ResourceManagerEndpoint: "https://management.azure.com/", - ActiveDirectoryEndpoint: "https://login.microsoftonline.com/", + ResourceManagerEndpoint: "https://api-dogfood.resources.windows-int.net/", + ActiveDirectoryEndpoint: "https://login.windows-ppe.net/", GalleryEndpoint: "https://gallery.azure.com/", KeyVaultEndpoint: "https://vault.azure.net/", - GraphEndpoint: "https://graph.windows.net/", + GraphEndpoint: "https://graph.ppe.windows.net/", ServiceBusEndpoint: "https://servicebus.windows.net/", BatchManagementEndpoint: "https://batch.core.windows.net/", StorageEndpointSuffix: "core.windows.net", @@ -97,7 +97,7 @@ var ( ResourceManagerVMDNSSuffix: "cloudapp.azure.com", ContainerRegistryDNSSuffix: "azurecr.io", CosmosDBDNSSuffix: "documents.azure.com", - TokenAudience: "https://management.azure.com/", + TokenAudience: "https://management.core.windows.net/", ResourceIdentifiers: ResourceIdentifier{ Graph: "https://graph.windows.net/", KeyVault: "https://vault.azure.net", diff --git a/vendor/modules.txt b/vendor/modules.txt index 5930bdcabfda..a607417326bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,6 +14,7 @@ github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2019-12-01/apimana github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appconfiguration github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation +github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn github.com/Azure/azure-sdk-for-go/services/cognitiveservices/mgmt/2017-04-18/cognitiveservices From 5d84477f7bcfd32e404e32d07addd07ddfc89b27 Mon Sep 17 00:00:00 2001 From: yupwei68 Date: Fri, 14 Aug 2020 11:15:27 +0800 Subject: [PATCH 03/23] update --- .../avs/avs_private_clouds_resource.go | 4 +-- .../tests/avs_private_clouds_resource_test.go | 30 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/azurerm/internal/services/avs/avs_private_clouds_resource.go b/azurerm/internal/services/avs/avs_private_clouds_resource.go index 42e97f9cfeae..cee17e5d83c1 100644 --- a/azurerm/internal/services/avs/avs_private_clouds_resource.go +++ b/azurerm/internal/services/avs/avs_private_clouds_resource.go @@ -351,8 +351,6 @@ func resourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("setting `identity_source`: %+v", err) } d.Set("internet_connected", props.Internet == avs.Enabled) - d.Set("nsxt_password", props.NsxtPassword) - d.Set("vcenter_password", props.VcenterPassword) d.Set("hcx_cloud_manager_endpoint", props.Endpoints.HcxCloudManager) d.Set("nsxt_manager_endpoint", props.Endpoints.NsxtManager) d.Set("vcsa_endpoint", props.Endpoints.Vcsa) @@ -435,7 +433,7 @@ func expandArmPrivateCloudIdentitySourceArray(input []interface{}) *[]avs.Identi for _, item := range input { v := item.(map[string]interface{}) sSL := avs.SslEnumDisabled - if v["ssl"].(bool) { + if v["ssl_enabled"].(bool) { sSL = avs.SslEnumEnabled } result := avs.IdentitySource{ diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go index 586110f8a203..3b5416f57804 100644 --- a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go @@ -23,7 +23,7 @@ func TestAccAzureRMavsPrivateCloud_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -73,7 +73,7 @@ func TestAccAzureRMavsPrivateCloud_complete(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -88,7 +88,7 @@ func TestAccAzureRMavsPrivateCloud_complete(t *testing.T) { resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), ), }, - data.ImportStep(), + data.ImportStep("nsxt_password", "vcenter_password"), }, }) } @@ -105,7 +105,7 @@ func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -126,7 +126,7 @@ func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -147,7 +147,7 @@ func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -168,7 +168,7 @@ func TestAccAzureRMavsPrivateCloud_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -207,7 +207,7 @@ func TestAccAzureRMavsPrivateCloud_updateIdentitySources(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -228,7 +228,7 @@ func TestAccAzureRMavsPrivateCloud_updateIdentitySources(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), - resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), @@ -371,8 +371,8 @@ resource "azurerm_avs_private_cloud" "test" { username = "testUser" } internet_connected = false - nsxt_password = "PassWord1234!" - vcenter_password = "PassWord1234!" + nsxt_password = "QazWsx13$Edc" + vcenter_password = "QazWsx13$Edc" tags = { ENV = "Test" } @@ -408,8 +408,8 @@ resource "azurerm_avs_private_cloud" "test" { username = "testUser2" } internet_connected = true - nsxt_password = "PassWord1234!" - vcenter_password = "PassWord1234!" + nsxt_password = "QazWsx13$Edc" + vcenter_password = "QazWsx13$Edc" tags = { ENV = "Stage" } @@ -458,8 +458,8 @@ identity_source { username = "testUser3" } internet_connected = false - nsxt_password = "PassWord1234!" - vcenter_password = "PassWord1234!" + nsxt_password = "QazWsx13$Edc" + vcenter_password = "QazWsx13$Edc" tags = { ENV = "Test" } From cbd705ab4e48bb5815c28ad70e693bad8c3023ad Mon Sep 17 00:00:00 2001 From: yupwei68 Date: Thu, 20 Aug 2020 09:41:45 +0800 Subject: [PATCH 04/23] update --- .../provider/required_resource_providers.go | 1 + .../avs/avs_private_clouds_data_source.go | 132 ++++++++++++- .../avs/avs_private_clouds_resource.go | 11 +- .../services/avs/parse/avs_private_clouds.go | 1 + .../avs_private_clouds_data_source_test.go | 22 ++- .../tests/avs_private_clouds_resource_test.go | 60 +++--- .../docs/d/avs_authorizations.html.markdown | 47 ----- .../website/docs/d/avs_clusters.html.markdown | 47 ----- .../d/avs_hcx_enterprise_sites.html.markdown | 47 ----- .../docs/d/avs_private_clouds.html.markdown | 48 ----- .../docs/r/avs_authorizations.html.markdown | 78 -------- .../website/docs/r/avs_clusters.html.markdown | 93 ---------- .../r/avs_hcx_enterprise_sites.html.markdown | 76 -------- .../docs/r/avs_private_clouds.html.markdown | 159 ---------------- .../autorest/azure/environments.go | 8 +- website/allowed-subcategories | 1 + website/azurerm.erb | 13 ++ .../docs/d/avs_private_cloud.html.markdown | 96 ++++++++++ .../docs/r/avs_private_cloud.html.markdown | 174 ++++++++++++++++++ 19 files changed, 478 insertions(+), 636 deletions(-) delete mode 100644 azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown delete mode 100644 azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown create mode 100644 website/docs/d/avs_private_cloud.html.markdown create mode 100644 website/docs/r/avs_private_cloud.html.markdown diff --git a/azurerm/internal/provider/required_resource_providers.go b/azurerm/internal/provider/required_resource_providers.go index 110cd6026774..8208ae6e0f65 100644 --- a/azurerm/internal/provider/required_resource_providers.go +++ b/azurerm/internal/provider/required_resource_providers.go @@ -20,6 +20,7 @@ func RequiredResourceProviders() map[string]struct{} { "Microsoft.AppPlatform": {}, "Microsoft.Authorization": {}, "Microsoft.Automation": {}, + "Microsoft.AVS": {}, "Microsoft.Blueprints": {}, "Microsoft.BotService": {}, "Microsoft.Cache": {}, diff --git a/azurerm/internal/services/avs/avs_private_clouds_data_source.go b/azurerm/internal/services/avs/avs_private_clouds_data_source.go index dc374d2c247e..c1cb1adedc7d 100644 --- a/azurerm/internal/services/avs/avs_private_clouds_data_source.go +++ b/azurerm/internal/services/avs/avs_private_clouds_data_source.go @@ -2,6 +2,9 @@ package avs import ( "fmt" + "time" + + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" @@ -9,7 +12,6 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "time" ) func dataSourceAvsPrivateCloud() *schema.Resource { @@ -30,6 +32,115 @@ func dataSourceAvsPrivateCloud() *schema.Resource { "location": azure.SchemaLocationForDataSource(), + "sku_name": { + Type: schema.TypeString, + Computed: true, + }, + + "management_cluster": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_size": { + Type: schema.TypeInt, + Computed: true, + }, + + "cluster_id": { + Type: schema.TypeInt, + Computed: true, + }, + + "hosts": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + + "network_block": { + Type: schema.TypeString, + Computed: true, + }, + + "internet_connected": { + Type: schema.TypeBool, + Computed: true, + }, + + "circuit": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "express_route_id": { + Type: schema.TypeString, + Computed: true, + }, + + "express_route_private_peering_id": { + Type: schema.TypeString, + Computed: true, + }, + + "primary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + + "secondary_subnet": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "hcx_cloud_manager_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "management_network": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "nsxt_manager_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "provisioning_network": { + Type: schema.TypeString, + Computed: true, + }, + + "vcenter_certificate_thumbprint": { + Type: schema.TypeString, + Computed: true, + }, + + "vcsa_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "vmotion_network": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tags.SchemaDataSource(), }, } @@ -58,5 +169,24 @@ func dataSourceArmAvsPrivateCloudRead(d *schema.ResourceData, meta interface{}) d.Set("name", name) d.Set("resource_group_name", resourceGroup) d.Set("location", location.NormalizeNilable(resp.Location)) + if props := resp.PrivateCloudProperties; props != nil { + if err := d.Set("management_cluster", flattenArmPrivateCloudManagementCluster(props.ManagementCluster)); err != nil { + return fmt.Errorf("setting `management_cluster`: %+v", err) + } + d.Set("network_block", props.NetworkBlock) + if err := d.Set("circuit", flattenArmPrivateCloudCircuit(props.Circuit)); err != nil { + return fmt.Errorf("setting `circuit`: %+v", err) + } + d.Set("internet_connected", props.Internet == avs.Enabled) + d.Set("hcx_cloud_manager_endpoint", props.Endpoints.HcxCloudManager) + d.Set("nsxt_manager_endpoint", props.Endpoints.NsxtManager) + d.Set("vcsa_endpoint", props.Endpoints.Vcsa) + d.Set("management_network", props.ManagementNetwork) + d.Set("nsxt_certificate_thumbprint", props.NsxtCertificateThumbprint) + d.Set("provisioning_network", props.ProvisioningNetwork) + d.Set("vcenter_certificate_thumbprint", props.VcenterCertificateThumbprint) + d.Set("vmotion_network", props.VmotionNetwork) + } + d.Set("sku_name", resp.Sku.Name) return tags.FlattenAndSet(d, resp.Tags) } diff --git a/azurerm/internal/services/avs/avs_private_clouds_resource.go b/azurerm/internal/services/avs/avs_private_clouds_resource.go index cee17e5d83c1..bbf039d42c26 100644 --- a/azurerm/internal/services/avs/avs_private_clouds_resource.go +++ b/azurerm/internal/services/avs/avs_private_clouds_resource.go @@ -2,6 +2,9 @@ package avs import ( "fmt" + "log" + "time" + "github.com/Azure/azure-sdk-for-go/services/avs/mgmt/2020-03-20/avs" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -15,8 +18,6 @@ import ( azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "log" - "time" ) func resourceArmAvsPrivateCloud() *schema.Resource { @@ -27,10 +28,10 @@ func resourceArmAvsPrivateCloud() *schema.Resource { Delete: resourceArmAvsPrivateCloudDelete, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), + Create: schema.DefaultTimeout(240 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), + Update: schema.DefaultTimeout(240 * time.Minute), + Delete: schema.DefaultTimeout(240 * time.Minute), }, Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { diff --git a/azurerm/internal/services/avs/parse/avs_private_clouds.go b/azurerm/internal/services/avs/parse/avs_private_clouds.go index 6f0de3451d96..413dcd67c847 100644 --- a/azurerm/internal/services/avs/parse/avs_private_clouds.go +++ b/azurerm/internal/services/avs/parse/avs_private_clouds.go @@ -2,6 +2,7 @@ package parse import ( "fmt" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" ) diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go index c9e5acf2c8e6..a2ca5d628658 100644 --- a/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_data_source_test.go @@ -2,9 +2,10 @@ package tests import ( "fmt" + "testing" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "testing" ) func TestAccDataSourceAzureRMavsPrivateCloud_basic(t *testing.T) { @@ -18,6 +19,23 @@ func TestAccDataSourceAzureRMavsPrivateCloud_basic(t *testing.T) { Config: testAccDataSourceavsPrivateCloud_basic(data), Check: resource.ComposeTestCheckFunc( testCheckAzureRMavsPrivateCloudExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_size"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.cluster_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_cluster.0.hosts.#"), + resource.TestCheckResourceAttrSet(data.ResourceName, "network_block"), + resource.TestCheckResourceAttrSet(data.ResourceName, "internet_connected"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.express_route_private_peering_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.primary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "circuit.0.secondary_subnet"), + resource.TestCheckResourceAttrSet(data.ResourceName, "hcx_cloud_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "management_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "nsxt_manager_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "provisioning_network"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcenter_certificate_thumbprint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vcsa_endpoint"), + resource.TestCheckResourceAttrSet(data.ResourceName, "vmotion_network"), ), }, }, @@ -30,7 +48,7 @@ func testAccDataSourceavsPrivateCloud_basic(data acceptance.TestData) string { %s data "azurerm_avs_private_cloud" "test" { - name = azurerm_avs_private_cloud.test.name + name = azurerm_avs_private_cloud.test.name resource_group_name = azurerm_avs_private_cloud.test.resource_group_name } `, config) diff --git a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go index 3b5416f57804..b0af360f8467 100644 --- a/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go +++ b/azurerm/internal/services/avs/tests/avs_private_clouds_resource_test.go @@ -2,13 +2,14 @@ package tests import ( "fmt" + "testing" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/avs/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "testing" ) func TestAccAzureRMavsPrivateCloud_basic(t *testing.T) { @@ -317,7 +318,7 @@ resource "azurerm_avs_private_cloud" "test" { sku_name = "av36" management_cluster { - cluster_size = 4 + cluster_size = 3 } network_block = "192.168.48.0/22" } @@ -355,7 +356,7 @@ resource "azurerm_avs_private_cloud" "test" { sku_name = "AV36" management_cluster { - cluster_size = 4 + cluster_size = 3 } network_block = "192.168.48.0/22" identity_source { @@ -392,7 +393,7 @@ resource "azurerm_avs_private_cloud" "test" { sku_name = "AV36" management_cluster { - cluster_size = 3 + cluster_size = 4 } network_block = "192.168.48.0/22" identity_source { @@ -423,45 +424,46 @@ func testAccAzureRMavsPrivateCloud_updateIdentitySources(data acceptance.TestDat %s resource "azurerm_avs_private_cloud" "test" { - name = "acctest-apc-%d" + name = "acctest-apc-%d" resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - sku_name= "AV36" + location = azurerm_resource_group.test.location + sku_name = "AV36" management_cluster { - cluster_size = 4 + cluster_size = 3 } network_block = "192.168.48.0/22" identity_source { - name = "testName" - alias = "testAlias" - base_group_dn = "testGp" - base_user_dn = "testUser" - domain = "testDomain" - password = "PassWord1234!" - primary_server_url = "http://test.com" + name = "testName" + alias = "testAlias" + base_group_dn = "testGp" + base_user_dn = "testUser" + domain = "testDomain" + password = "PassWord1234!" + primary_server_url = "http://test.com" secondary_server_url = "http://test2.com" - ssl_enabled = false - username = "testUser" + ssl_enabled = false + username = "testUser" } -identity_source { - name = "testName3" - alias = "testAlias3" - base_group_dn = "testGp3" - base_user_dn = "testUser3" - domain = "testDomain3" - password = "PassWord1234!3" - primary_server_url = "http://test_secondary.com" + identity_source { + name = "testName3" + alias = "testAlias3" + base_group_dn = "testGp3" + base_user_dn = "testUser3" + domain = "testDomain3" + password = "PassWord1234!3" + primary_server_url = "http://test_secondary.com" secondary_server_url = "http://test_secondary2.com" - ssl_enabled = true - username = "testUser3" + ssl_enabled = true + username = "testUser3" } internet_connected = false - nsxt_password = "QazWsx13$Edc" - vcenter_password = "QazWsx13$Edc" + nsxt_password = "QazWsx13$Edc" + vcenter_password = "QazWsx13$Edc" tags = { ENV = "Test" } +} `, template, data.RandomInteger) } diff --git a/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown deleted file mode 100644 index 6f2c6e9881d6..000000000000 --- a/azurerm/internal/services/avs/website/docs/d/avs_authorizations.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: Data Source: azurerm_avs_authorization" -description: |- - Gets information about an existing avs Authorization. ---- - -# Data Source: azurerm_avs_authorization - -Use this data source to access information about an existing avs Authorization. - -## Example Usage - -```hcl -data "azurerm_avs_authorization" "example" { - name = "example-authorization" - resource_group_name = "example-resource-group" - private_cloud_name = "existing" -} - -output "id" { - value = data.azurerm_avs_authorization.example.id -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name of this avs Authorization. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs Authorization exists. - -* `private_cloud_name` - (Required) Name of the private cloud. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs Authorization. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `read` - (Defaults to 5 minutes) Used when retrieving the avs Authorization. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown deleted file mode 100644 index de1690c15cf9..000000000000 --- a/azurerm/internal/services/avs/website/docs/d/avs_clusters.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: Data Source: azurerm_avs_cluster" -description: |- - Gets information about an existing avs Cluster. ---- - -# Data Source: azurerm_avs_cluster - -Use this data source to access information about an existing avs Cluster. - -## Example Usage - -```hcl -data "azurerm_avs_cluster" "example" { - name = "example-cluster" - resource_group_name = "example-resource-group" - private_cloud_name = "existing" -} - -output "id" { - value = data.azurerm_avs_cluster.example.id -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name of this avs Cluster. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs Cluster exists. - -* `private_cloud_name` - (Required) Name of the private cloud. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs Cluster. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `read` - (Defaults to 5 minutes) Used when retrieving the avs Cluster. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown deleted file mode 100644 index 6e18f0e9d375..000000000000 --- a/azurerm/internal/services/avs/website/docs/d/avs_hcx_enterprise_sites.html.markdown +++ /dev/null @@ -1,47 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: Data Source: azurerm_avs_hcx_enterprise_site" -description: |- - Gets information about an existing avs HcxEnterpriseSite. ---- - -# Data Source: azurerm_avs_hcx_enterprise_site - -Use this data source to access information about an existing avs HcxEnterpriseSite. - -## Example Usage - -```hcl -data "azurerm_avs_hcx_enterprise_site" "example" { - name = "example-hcxenterprisesite" - resource_group_name = "example-resource-group" - private_cloud_name = "existing" -} - -output "id" { - value = data.azurerm_avs_hcx_enterprise_site.example.id -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name of this avs HcxEnterpriseSite. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs HcxEnterpriseSite exists. - -* `private_cloud_name` - (Required) Name of the private cloud. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs HcxEnterpriseSite. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `read` - (Defaults to 5 minutes) Used when retrieving the avs HcxEnterpriseSite. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown b/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown deleted file mode 100644 index 38b17d1338ac..000000000000 --- a/azurerm/internal/services/avs/website/docs/d/avs_private_clouds.html.markdown +++ /dev/null @@ -1,48 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: Data Source: azurerm_avs_private_cloud" -description: |- - Gets information about an existing avs PrivateCloud. ---- - -# Data Source: azurerm_avs_private_cloud - -Use this data source to access information about an existing avs PrivateCloud. - -## Example Usage - -```hcl -data "azurerm_avs_private_cloud" "example" { - name = "example-privatecloud" - resource_group_name = "example-resource-group" -} - -output "id" { - value = data.azurerm_avs_private_cloud.example.id -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name of this avs PrivateCloud. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs PrivateCloud exists. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs PrivateCloud. - -* `location` - The Azure Region where the avs PrivateCloud exists. - -* `tags` - A mapping of tags assigned to the avs PrivateCloud. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `read` - (Defaults to 5 minutes) Used when retrieving the avs PrivateCloud. \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown deleted file mode 100644 index d098815c1b57..000000000000 --- a/azurerm/internal/services/avs/website/docs/r/avs_authorizations.html.markdown +++ /dev/null @@ -1,78 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_avs_authorization" -description: |- - Manages a avs Authorization. ---- - -# azurerm_avs_authorization - -Manages a avs Authorization. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_avs_private_cloud" "example" { - name = "example-privatecloud" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - sku { - name = "example-privatecloud" - } - - management_cluster { - cluster_size = 42 - } - network_block = "" -} - -resource "azurerm_avs_authorization" "example" { - name = "example-authorization" - resource_group_name = azurerm_resource_group.example.name - private_cloud_name = azurerm_avs_private_cloud.example.name -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name which should be used for this avs Authorization. Changing this forces a new avs Authorization to be created. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs Authorization should exist. Changing this forces a new avs Authorization to be created. - -* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs Authorization to be created. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs Authorization. - -* `express_route_authorization_id` - The ID of the express_route_authorization. - -* `express_route_authorization_key` - The key of the ExpressRoute Circuit Authorization. - -* `type` - Resource type. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 30 minutes) Used when creating the avs Authorization. -* `read` - (Defaults to 5 minutes) Used when retrieving the avs Authorization. -* `delete` - (Defaults to 30 minutes) Used when deleting the avs Authorization. - -## Import - -avs Authorizations can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_avs_authorization.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/authorization1 -``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown deleted file mode 100644 index f43b6c80c88d..000000000000 --- a/azurerm/internal/services/avs/website/docs/r/avs_clusters.html.markdown +++ /dev/null @@ -1,93 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_avs_cluster" -description: |- - Manages a avs Cluster. ---- - -# azurerm_avs_cluster - -Manages a avs Cluster. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_avs_private_cloud" "example" { - name = "example-privatecloud" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - sku { - name = "example-privatecloud" - } - - management_cluster { - cluster_size = 42 - } - network_block = "" -} - -resource "azurerm_avs_cluster" "example" { - name = "example-cluster" - resource_group_name = azurerm_resource_group.example.name - private_cloud_name = azurerm_avs_private_cloud.example.name - sku { - name = "example-cluster" - } - cluster_size = 42 -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name which should be used for this avs Cluster. Changing this forces a new avs Cluster to be created. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs Cluster should exist. Changing this forces a new avs Cluster to be created. - -* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs Cluster to be created. - -* `sku` - (Required) A `sku` block as defined below. Changing this forces a new avs Cluster to be created. - -* `cluster_size` - (Required) The cluster size. - ---- - -An `sku` block exports the following: - -* `name` - (Required) The name which should be used for this sku. Changing this forces a new avs Cluster to be created. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs Cluster. - -* `cluster_id` - The ID of the cluster. - -* `hosts` - The hosts. - -* `type` - Resource type. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 30 minutes) Used when creating the avs Cluster. -* `read` - (Defaults to 5 minutes) Used when retrieving the avs Cluster. -* `update` - (Defaults to 30 minutes) Used when updating the avs Cluster. -* `delete` - (Defaults to 30 minutes) Used when deleting the avs Cluster. - -## Import - -avs Clusters can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_avs_cluster.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/clusters/cluster1 -``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown deleted file mode 100644 index a7102f331b78..000000000000 --- a/azurerm/internal/services/avs/website/docs/r/avs_hcx_enterprise_sites.html.markdown +++ /dev/null @@ -1,76 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_avs_hcx_enterprise_site" -description: |- - Manages a avs HcxEnterpriseSite. ---- - -# azurerm_avs_hcx_enterprise_site - -Manages a avs HcxEnterpriseSite. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_avs_private_cloud" "example" { - name = "example-privatecloud" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - sku { - name = "example-privatecloud" - } - - management_cluster { - cluster_size = 42 - } - network_block = "" -} - -resource "azurerm_avs_hcx_enterprise_site" "example" { - name = "example-hcxenterprisesite" - resource_group_name = azurerm_resource_group.example.name - private_cloud_name = azurerm_avs_private_cloud.example.name -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name which should be used for this avs HcxEnterpriseSite. Changing this forces a new avs HcxEnterpriseSite to be created. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs HcxEnterpriseSite should exist. Changing this forces a new avs HcxEnterpriseSite to be created. - -* `private_cloud_name` - (Required) The name of the private cloud. Changing this forces a new avs HcxEnterpriseSite to be created. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs HcxEnterpriseSite. - -* `activation_key` - The activation key. - -* `type` - Resource type. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 30 minutes) Used when creating the avs HcxEnterpriseSite. -* `read` - (Defaults to 5 minutes) Used when retrieving the avs HcxEnterpriseSite. -* `delete` - (Defaults to 30 minutes) Used when deleting the avs HcxEnterpriseSite. - -## Import - -avs HcxEnterpriseSites can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_avs_hcx_enterprise_site.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/hcxEnterpriseSites/hcxEnterpriseSite1 -``` \ No newline at end of file diff --git a/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown b/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown deleted file mode 100644 index 099ec120d789..000000000000 --- a/azurerm/internal/services/avs/website/docs/r/avs_private_clouds.html.markdown +++ /dev/null @@ -1,159 +0,0 @@ ---- -subcategory: "Avs" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_avs_private_cloud" -description: |- - Manages a avs PrivateCloud. ---- - -# azurerm_avs_private_cloud - -Manages a avs PrivateCloud. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_avs_private_cloud" "example" { - name = "example-privatecloud" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - sku { - name = "example-privatecloud" - } - - management_cluster { - cluster_size = 42 - } - network_block = "192.168.48.0/22" -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The name which should be used for this avs PrivateCloud. Changing this forces a new avs PrivateCloud to be created. - -* `resource_group_name` - (Required) The name of the Resource Group where the avs PrivateCloud should exist. Changing this forces a new avs PrivateCloud to be created. - -* `location` - (Required) The Azure Region where the avs PrivateCloud should exist. Changing this forces a new avs PrivateCloud to be created. - -* `sku` - (Required) A `sku` block as defined below. Changing this forces a new avs PrivateCloud to be created. - -* `management_cluster` - (Required) A `management_cluster` block as defined below. - -* `network_block` - (Required) The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22. - ---- - -* `identity_source` - (Optional) A `identity_source` block as defined below. - -* `internet` - (Optional) Connectivity to internet is enabled or disabled. Possible values are "true" and "false" is allowed. - -* `nsxt_password` - (Optional) Optionally, set the NSX-T Manager password when the private cloud is created. - -* `vcenter_password` - (Optional) Optionally, set the vCenter admin password when the private cloud is created. - -* `tags` - (Optional) A mapping of tags which should be assigned to the avs PrivateCloud. - ---- - -An `sku` block exports the following: - -* `name` - (Required) The name which should be used for this sku. Changing this forces a new avs PrivateCloud to be created. - ---- - -An `management_cluster` block exports the following: - -* `cluster_size` - (Required) The cluster size. - ---- - -An `identity_source` block exports the following: - -* `name` - (Optional) The name which should be used for this identity_source. - -* `alias` - (Optional) The domain's NetBIOS name. - -* `base_group_dn` - (Optional) The base distinguished name for groups. - -* `base_user_dn` - (Optional) The base distinguished name for users. - -* `domain` - (Optional) The domain's dns name. - -* `password` - (Optional) The password of the Active Directory user with a minimum of read-only access to Base DN for users and groups. - -* `primary_server` - (Optional) Primary server URL. - -* `secondary_server` - (Optional) Secondary server URL. - -* `ssl` - (Optional) Protect LDAP communication using SSL certificate (LDAPS). Possible values are "true" and "false" is allowed. - -* `username` - (Optional) The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group. - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the avs PrivateCloud. - -* `circuit` - An ExpressRoute Circuit. A `circuit` block as defined below. - -* `endpoint` - The endpoints. A `endpoint` block as defined below. - -* `management_network` - Network used to access vCenter Server and NSX-T Manager. - -* `nsxt_certificate_thumbprint` - Thumbprint of the NSX-T Manager SSL certificate. - -* `provisioning_network` - Used for virtual machine cold migration, cloning, and snapshot migration. - -* `type` - Resource type. - -* `vcenter_certificate_thumbprint` - Thumbprint of the vCenter Server SSL certificate. - -* `vmotion_network` - Used for live migration of virtual machines. - ---- - -An `circuit` block exports the following: - -* `express_route_id` - The ID of the express_route. - -* `express_route_private_peering_id` - The ID of the express_route_private_peering. - -* `primary_subnet` - CIDR of primary subnet. - -* `secondary_subnet` - CIDR of secondary subnet. - ---- - -An `endpoint` block exports the following: - -* `hcx_cloud_manager` - Endpoint for the HCX Cloud Manager. - -* `nsxt_manager` - Endpoint for the NSX-T Data Center manager. - -* `vcsa` - Endpoint for Virtual Center Server Appliance. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 30 minutes) Used when creating the avs PrivateCloud. -* `read` - (Defaults to 5 minutes) Used when retrieving the avs PrivateCloud. -* `update` - (Defaults to 30 minutes) Used when updating the avs PrivateCloud. -* `delete` - (Defaults to 30 minutes) Used when deleting the avs PrivateCloud. - -## Import - -avs PrivateClouds can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_avs_private_cloud.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1 -``` \ No newline at end of file diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go index 59823831abaa..6c20b8179ab0 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go @@ -81,11 +81,11 @@ var ( ManagementPortalURL: "https://manage.windowsazure.com/", PublishSettingsURL: "https://manage.windowsazure.com/publishsettings/index", ServiceManagementEndpoint: "https://management.core.windows.net/", - ResourceManagerEndpoint: "https://api-dogfood.resources.windows-int.net/", - ActiveDirectoryEndpoint: "https://login.windows-ppe.net/", + ResourceManagerEndpoint: "https://management.azure.com/", + ActiveDirectoryEndpoint: "https://login.microsoftonline.com/", GalleryEndpoint: "https://gallery.azure.com/", KeyVaultEndpoint: "https://vault.azure.net/", - GraphEndpoint: "https://graph.ppe.windows.net/", + GraphEndpoint: "https://graph.windows.net/", ServiceBusEndpoint: "https://servicebus.windows.net/", BatchManagementEndpoint: "https://batch.core.windows.net/", StorageEndpointSuffix: "core.windows.net", @@ -97,7 +97,7 @@ var ( ResourceManagerVMDNSSuffix: "cloudapp.azure.com", ContainerRegistryDNSSuffix: "azurecr.io", CosmosDBDNSSuffix: "documents.azure.com", - TokenAudience: "https://management.core.windows.net/", + TokenAudience: "https://management.azure.com/", ResourceIdentifiers: ResourceIdentifier{ Graph: "https://graph.windows.net/", KeyVault: "https://vault.azure.net", diff --git a/website/allowed-subcategories b/website/allowed-subcategories index f0a9bf2a674e..2a95ad9a037f 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -6,6 +6,7 @@ App Service (Web Apps) Application Insights Authorization Automation +Avs Base Batch Blueprints diff --git a/website/azurerm.erb b/website/azurerm.erb index c21c580df7cc..c4552b74172f 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -137,6 +137,10 @@ azurerm_availability_set +
  • + azurerm_avs_private_cloud +
  • +
  • azurerm_backup_policy_vm
  • @@ -992,6 +996,15 @@ +
  • + Azure Vmware Solution Resources + +
  • +
  • Backup Resources