diff --git a/internal/clients/client.go b/internal/clients/client.go index cb8d507e5a90..e39ae857ecda 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -5,6 +5,7 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/validation" + dns_v2018_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01" "github.com/hashicorp/terraform-provider-azurerm/internal/common" "github.com/hashicorp/terraform-provider-azurerm/internal/features" aadb2c "github.com/hashicorp/terraform-provider-azurerm/internal/services/aadb2c/client" @@ -156,7 +157,7 @@ type Client struct { DevTestLabs *devtestlabs.Client DigitalTwins *digitaltwins.Client Disks *disks.Client - Dns *dns.Client + Dns *dns_v2018_05_01.Client DomainServices *domainservices.Client Elastic *elastic.Client EventGrid *eventgrid.Client diff --git a/internal/services/dns/client/client.go b/internal/services/dns/client/client.go index d1dc5bea72b8..0f34c6a66b83 100644 --- a/internal/services/dns/client/client.go +++ b/internal/services/dns/client/client.go @@ -1,24 +1,14 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/Azure/go-autorest/autorest" + dns_v2018_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) -type Client struct { - RecordSetsClient *dns.RecordSetsClient - ZonesClient *dns.ZonesClient -} - -func NewClient(o *common.ClientOptions) *Client { - RecordSetsClient := dns.NewRecordSetsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&RecordSetsClient.Client, o.ResourceManagerAuthorizer) - - ZonesClient := dns.NewZonesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&ZonesClient.Client, o.ResourceManagerAuthorizer) - - return &Client{ - RecordSetsClient: &RecordSetsClient, - ZonesClient: &ZonesClient, - } +func NewClient(o *common.ClientOptions) *dns_v2018_05_01.Client { + client := dns_v2018_05_01.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) { + c.Authorizer = o.ResourceManagerAuthorizer + }) + return &client } diff --git a/internal/services/dns/dns_a_record_data_source.go b/internal/services/dns/dns_a_record_data_source.go index e28f79570eaf..097da3483707 100644 --- a/internal/services/dns/dns_a_record_data_source.go +++ b/internal/services/dns/dns_a_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsARecord() *pluginsdk.Resource { @@ -57,48 +56,51 @@ func dataSourceDnsARecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsARecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeA, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.A) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS A record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS A record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewARecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("records", flattenAzureRmDnsARecords(resp.ARecords)); err != nil { - return fmt.Errorf("setting `records`: %+v", err) - } + if err := d.Set("records", flattenAzureRmDnsARecords(props.ARecords)); err != nil { + return fmt.Errorf("setting `records`: %+v", err) + } + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) - targetResourceId := "" - if resp.TargetResource != nil && resp.TargetResource.ID != nil { - targetResourceId = *resp.TargetResource.ID + return tags.FlattenAndSet(d, props.Metadata) + } } - d.Set("target_resource_id", targetResourceId) - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_a_record_resource.go b/internal/services/dns/dns_a_record_resource.go index 12b55baeaff8..4b785d7e4587 100644 --- a/internal/services/dns/dns_a_record_resource.go +++ b/internal/services/dns/dns_a_record_resource.go @@ -2,15 +2,15 @@ package dns import ( "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -30,8 +30,14 @@ func resourceDnsARecord() *pluginsdk.Resource { Delete: pluginsdk.DefaultTimeout(30 * time.Minute), }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ARecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeA { + return fmt.Errorf("this resource only supports 'A' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -41,11 +47,12 @@ func resourceDnsARecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "records": { @@ -75,13 +82,13 @@ func resourceDnsARecord() *pluginsdk.Resource { // TODO: switch ConflictsWith for ExactlyOneOf when the Provider SDK's updated }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsARecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -90,18 +97,17 @@ func resourceDnsARecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewARecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeA, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.A) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS A Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_a_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_a_record", id.ID()) } } @@ -110,18 +116,18 @@ func resourceDnsARecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) targetResourceId := d.Get("target_resource_id").(string) recordsRaw := d.Get("records").(*pluginsdk.Set).List() - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, ARecords: expandAzureRmDnsARecords(recordsRaw), - TargetResource: &dns.SubResource{}, + TargetResource: &recordsets.SubResource{}, }, } if targetResourceId != "" { - parameters.RecordSetProperties.TargetResource.ID = utils.String(targetResourceId) + parameters.Properties.TargetResource.Id = utils.String(targetResourceId) } // TODO: this can be removed when the provider SDK is upgraded @@ -129,99 +135,105 @@ func resourceDnsARecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("One of either `records` or `target_resource_id` must be specified") } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.A, parameters, eTag, ifNoneMatch); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { return fmt.Errorf("creating/updating DNS A Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsARecordRead(d, meta) } func resourceDnsARecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ARecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.AName, dns.A) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS A record %s: %+v", id.AName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.AName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("fqdn", resp.Fqdn) - d.Set("ttl", resp.TTL) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("fqdn", props.Fqdn) + d.Set("ttl", props.TTL) - if err := d.Set("records", flattenAzureRmDnsARecords(resp.ARecords)); err != nil { - return fmt.Errorf("setting `records`: %+v", err) - } + if err := d.Set("records", flattenAzureRmDnsARecords(props.ARecords)); err != nil { + return fmt.Errorf("setting `records`: %+v", err) + } + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) + + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } - targetResourceId := "" - if resp.TargetResource != nil && resp.TargetResource.ID != nil { - targetResourceId = *resp.TargetResource.ID } - d.Set("target_resource_id", targetResourceId) - return tags.FlattenAndSet(d, resp.Metadata) + return nil } func resourceDnsARecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ARecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.AName, dns.A, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS A Record %s: %+v", id.AName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func expandAzureRmDnsARecords(input []interface{}) *[]dns.ARecord { - records := make([]dns.ARecord, len(input)) +func expandAzureRmDnsARecords(input []interface{}) *[]recordsets.ARecord { + records := make([]recordsets.ARecord, len(input)) for i, v := range input { ipv4 := v.(string) - records[i] = dns.ARecord{ - Ipv4Address: &ipv4, + records[i] = recordsets.ARecord{ + IPv4Address: &ipv4, } } return &records } -func flattenAzureRmDnsARecords(records *[]dns.ARecord) []string { +func flattenAzureRmDnsARecords(records *[]recordsets.ARecord) []string { if records == nil { return []string{} } results := make([]string, 0) for _, record := range *records { - if record.Ipv4Address == nil { + if record.IPv4Address == nil { continue } - results = append(results, *record.Ipv4Address) + results = append(results, *record.IPv4Address) } return results diff --git a/internal/services/dns/dns_a_record_resource_test.go b/internal/services/dns/dns_a_record_resource_test.go index 56ac43d8ab7a..f6a7bafa402c 100644 --- a/internal/services/dns/dns_a_record_resource_test.go +++ b/internal/services/dns/dns_a_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -171,17 +170,17 @@ func TestAccAzureRMDnsARecord_AliasToRecords(t *testing.T) { } func (TestAccDnsARecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ARecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.AName, dns.A) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS A record %s (resource group: %s): %v", id.AName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (TestAccDnsARecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_aaaa_record_data_source.go b/internal/services/dns/dns_aaaa_record_data_source.go index cec8d0957089..ea1bc66b4c80 100644 --- a/internal/services/dns/dns_aaaa_record_data_source.go +++ b/internal/services/dns/dns_aaaa_record_data_source.go @@ -4,15 +4,14 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsAAAARecord() *pluginsdk.Resource { @@ -58,48 +57,51 @@ func dataSourceDnsAAAARecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsAAAARecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeAAAA, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.AAAA) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS AAAA record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS AAAA record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewAaaaRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("records", flattenAzureRmDnsAaaaRecords(resp.AaaaRecords)); err != nil { - return fmt.Errorf("setting `records`: %+v", err) - } + if err := d.Set("records", flattenAzureRmDnsAaaaRecords(props.AAAARecords)); err != nil { + return fmt.Errorf("setting `records`: %+v", err) + } + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) - targetResourceId := "" - if resp.TargetResource != nil && resp.TargetResource.ID != nil { - targetResourceId = *resp.TargetResource.ID + return tags.FlattenAndSet(d, props.Metadata) + } } - d.Set("target_resource_id", targetResourceId) - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_aaaa_record_resource.go b/internal/services/dns/dns_aaaa_record_resource.go index c8932efd587a..ab3e8708d1b3 100644 --- a/internal/services/dns/dns_aaaa_record_resource.go +++ b/internal/services/dns/dns_aaaa_record_resource.go @@ -2,15 +2,15 @@ package dns import ( "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -33,8 +33,14 @@ func resourceDnsAAAARecord() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.AaaaRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeAAAA { + return fmt.Errorf("this resource only supports 'AAAA' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -44,11 +50,12 @@ func resourceDnsAAAARecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "records": { @@ -72,7 +79,7 @@ func resourceDnsAAAARecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), "target_resource_id": { Type: pluginsdk.TypeString, @@ -85,7 +92,7 @@ func resourceDnsAAAARecord() *pluginsdk.Resource { } func resourceDnsAaaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -94,18 +101,17 @@ func resourceDnsAaaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewAaaaRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeAAAA, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.AAAA) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS AAAA Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_aaaa_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_aaaa_record", id.ID()) } } @@ -114,18 +120,18 @@ func resourceDnsAaaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface recordsRaw := d.Get("records").(*pluginsdk.Set).List() targetResourceId := d.Get("target_resource_id").(string) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - AaaaRecords: expandAzureRmDnsAaaaRecords(recordsRaw), - TargetResource: &dns.SubResource{}, + AAAARecords: expandAzureRmDnsAaaaRecords(recordsRaw), + TargetResource: &recordsets.SubResource{}, }, } if targetResourceId != "" { - parameters.RecordSetProperties.TargetResource.ID = utils.String(targetResourceId) + parameters.Properties.TargetResource.Id = utils.String(targetResourceId) } // TODO: this can be removed when the provider SDK is upgraded @@ -133,99 +139,103 @@ func resourceDnsAaaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface return fmt.Errorf("One of either `records` or `target_resource_id` must be specified") } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.AAAA, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS AAAA Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) - + d.SetId(id.ID()) return resourceDnsAaaaRecordRead(d, meta) } func resourceDnsAaaaRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AaaaRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.AAAAName, dns.AAAA) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS AAAA record %s: %v", id.AAAAName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.AAAAName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("fqdn", resp.Fqdn) - d.Set("ttl", resp.TTL) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("fqdn", props.Fqdn) + d.Set("ttl", props.TTL) - if err := d.Set("records", flattenAzureRmDnsAaaaRecords(resp.AaaaRecords)); err != nil { - return fmt.Errorf("setting `records`: %+v", err) - } + if err := d.Set("records", flattenAzureRmDnsAaaaRecords(props.AAAARecords)); err != nil { + return fmt.Errorf("setting `records`: %+v", err) + } + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) - targetResourceId := "" - if resp.TargetResource != nil && resp.TargetResource.ID != nil { - targetResourceId = *resp.TargetResource.ID + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - d.Set("target_resource_id", targetResourceId) - return tags.FlattenAndSet(d, resp.Metadata) + return nil } func resourceDnsAaaaRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AaaaRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.AAAAName, dns.AAAA, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS AAAA Record %s: %+v", id.AAAAName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", id.RelativeRecordSetName, err) } return nil } -func expandAzureRmDnsAaaaRecords(input []interface{}) *[]dns.AaaaRecord { - records := make([]dns.AaaaRecord, len(input)) +func expandAzureRmDnsAaaaRecords(input []interface{}) *[]recordsets.AaaaRecord { + records := make([]recordsets.AaaaRecord, len(input)) for i, v := range input { ipv6 := NormalizeIPv6Address(v) - records[i] = dns.AaaaRecord{ - Ipv6Address: &ipv6, + records[i] = recordsets.AaaaRecord{ + IPv6Address: &ipv6, } } return &records } -func flattenAzureRmDnsAaaaRecords(records *[]dns.AaaaRecord) []string { +func flattenAzureRmDnsAaaaRecords(records *[]recordsets.AaaaRecord) []string { if records == nil { return []string{} } results := make([]string, 0) for _, record := range *records { - if record.Ipv6Address == nil { + if record.IPv6Address == nil { continue } - results = append(results, NormalizeIPv6Address(*record.Ipv6Address)) + results = append(results, NormalizeIPv6Address(*record.IPv6Address)) } return results } diff --git a/internal/services/dns/dns_aaaa_record_resource_test.go b/internal/services/dns/dns_aaaa_record_resource_test.go index 30b4e4abfe5a..5185450d72fa 100644 --- a/internal/services/dns/dns_aaaa_record_resource_test.go +++ b/internal/services/dns/dns_aaaa_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -194,17 +193,17 @@ func TestAccAzureRMDnsAAAARecord_uncompressed(t *testing.T) { } func (DnsAAAARecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.AaaaRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.AAAAName, dns.AAAA) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS AAAA record %s (resource group: %s): %v", id.AAAAName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsAAAARecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_caa_record_data_source.go b/internal/services/dns/dns_caa_record_data_source.go index 760e2fb4fb9c..a8eea460c0e9 100644 --- a/internal/services/dns/dns_caa_record_data_source.go +++ b/internal/services/dns/dns_caa_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsCaaRecord() *pluginsdk.Resource { @@ -69,42 +68,45 @@ func dataSourceDnsCaaRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsCaaRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeCAA, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.CAA) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS CAA record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS CAA record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewCaaRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("record", flattenAzureRmDnsCaaRecords(resp.CaaRecords)); err != nil { - return err + if err := d.Set("record", flattenAzureRmDnsCaaRecords(props.CaaRecords)); err != nil { + return err + } + + return tags.FlattenAndSet(d, props.Metadata) + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_caa_record_resource.go b/internal/services/dns/dns_caa_record_resource.go index f11e333de4cc..013d001f5195 100644 --- a/internal/services/dns/dns_caa_record_resource.go +++ b/internal/services/dns/dns_caa_record_resource.go @@ -3,19 +3,17 @@ package dns import ( "bytes" "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceDnsCaaRecord() *pluginsdk.Resource { @@ -33,8 +31,14 @@ func resourceDnsCaaRecord() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CaaRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeCAA { + return fmt.Errorf("this resource only supports 'CAA' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -44,11 +48,12 @@ func resourceDnsCaaRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "record": { @@ -90,13 +95,13 @@ func resourceDnsCaaRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsCaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -105,103 +110,122 @@ func resourceDnsCaaRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{ resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewCaaRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeCAA, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.CAA) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing DNS CAA Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_caa_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_caa_record", id.ID()) } } ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, CaaRecords: expandAzureRmDnsCaaRecords(d), }, } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.CAA, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS CAA Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsCaaRecordRead(d, meta) } func resourceDnsCaaRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CaaRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.DnszoneName, id.CAAName, dns.CAA) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS CAA record %s: %v", id.CAAName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.CAAName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("record", flattenAzureRmDnsCaaRecords(resp.CaaRecords)); err != nil { - return err + if err := d.Set("record", flattenAzureRmDnsCaaRecords(props.CaaRecords)); err != nil { + return err + } + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - return tags.FlattenAndSet(d, resp.Metadata) + + return nil } func resourceDnsCaaRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CaaRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.CAAName, dns.CAA, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS CAA Record %s: %+v", id.CAAName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func flattenAzureRmDnsCaaRecords(records *[]dns.CaaRecord) []map[string]interface{} { +func flattenAzureRmDnsCaaRecords(records *[]recordsets.CaaRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0) if records != nil { for _, record := range *records { + flags := int64(0) + if record.Flags != nil { + flags = *record.Flags + } + + tag := "" + if record.Tag != nil { + tag = *record.Tag + } + + value := "" + if record.Value != nil { + value = *record.Value + } + results = append(results, map[string]interface{}{ - "flags": *record.Flags, - "tag": *record.Tag, - "value": *record.Value, + "flags": flags, + "tag": tag, + "value": value, }) } } @@ -209,23 +233,22 @@ func flattenAzureRmDnsCaaRecords(records *[]dns.CaaRecord) []map[string]interfac return results } -func expandAzureRmDnsCaaRecords(d *pluginsdk.ResourceData) *[]dns.CaaRecord { +func expandAzureRmDnsCaaRecords(d *pluginsdk.ResourceData) *[]recordsets.CaaRecord { recordStrings := d.Get("record").(*pluginsdk.Set).List() - records := make([]dns.CaaRecord, len(recordStrings)) + records := make([]recordsets.CaaRecord, 0) - for i, v := range recordStrings { + for _, v := range recordStrings { record := v.(map[string]interface{}) - flags := int32(record["flags"].(int)) + + flags := int64(record["flags"].(int)) tag := record["tag"].(string) value := record["value"].(string) - caaRecord := dns.CaaRecord{ + records = append(records, recordsets.CaaRecord{ Flags: &flags, Tag: &tag, Value: &value, - } - - records[i] = caaRecord + }) } return &records diff --git a/internal/services/dns/dns_caa_record_resource_test.go b/internal/services/dns/dns_caa_record_resource_test.go index d4733d22f3f5..e570d88b55ec 100644 --- a/internal/services/dns/dns_caa_record_resource_test.go +++ b/internal/services/dns/dns_caa_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -96,17 +95,17 @@ func TestAccDnsCaaRecord_withTags(t *testing.T) { } func (DnsCaaRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CaaRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.CAAName, dns.CAA) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS CAA record %s (resource group: %s): %v", id.CAAName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsCaaRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_cname_record_data_source.go b/internal/services/dns/dns_cname_record_data_source.go index c0c82681857a..eb66db443b40 100644 --- a/internal/services/dns/dns_cname_record_data_source.go +++ b/internal/services/dns/dns_cname_record_data_source.go @@ -4,14 +4,14 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsCNameRecord() *pluginsdk.Resource { @@ -55,52 +55,53 @@ func dataSourceDnsCNameRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsCNameRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeCNAME, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.CNAME) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS CNAME record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS CNAME record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewCnameRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if props := resp.RecordSetProperties; props != nil { - cname := "" - if props.CnameRecord != nil && props.CnameRecord.Cname != nil { - cname = *props.CnameRecord.Cname - } - d.Set("record", cname) + cname := "" + if props.CNAMERecord != nil && props.CNAMERecord.Cname != nil { + cname = *props.CNAMERecord.Cname + } + d.Set("record", cname) + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) - targetResourceId := "" - if props.TargetResource != nil && props.TargetResource.ID != nil { - targetResourceId = *props.TargetResource.ID + return tags.FlattenAndSet(d, props.Metadata) } - d.Set("target_resource_id", targetResourceId) } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_cname_record_resource.go b/internal/services/dns/dns_cname_record_resource.go index 7b9c40ac7d6d..0e081b352437 100644 --- a/internal/services/dns/dns_cname_record_resource.go +++ b/internal/services/dns/dns_cname_record_resource.go @@ -2,15 +2,15 @@ package dns import ( "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -31,8 +31,14 @@ func resourceDnsCNameRecord() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CnameRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeCNAME { + return fmt.Errorf("this resource only supports 'CNAME' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -42,11 +48,12 @@ func resourceDnsCNameRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "record": { @@ -72,13 +79,13 @@ func resourceDnsCNameRecord() *pluginsdk.Resource { ConflictsWith: []string{"record"}, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsCNameRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -87,18 +94,17 @@ func resourceDnsCNameRecordCreateUpdate(d *pluginsdk.ResourceData, meta interfac resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewCnameRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeCNAME, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.CNAME) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS CNAME Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_cname_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_cname_record", id.ID()) } } @@ -107,22 +113,22 @@ func resourceDnsCNameRecordCreateUpdate(d *pluginsdk.ResourceData, meta interfac t := d.Get("tags").(map[string]interface{}) targetResourceId := d.Get("target_resource_id").(string) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - CnameRecord: &dns.CnameRecord{}, - TargetResource: &dns.SubResource{}, + CNAMERecord: &recordsets.CnameRecord{}, + TargetResource: &recordsets.SubResource{}, }, } if record != "" { - parameters.RecordSetProperties.CnameRecord.Cname = utils.String(record) + parameters.Properties.CNAMERecord.Cname = utils.String(record) } if targetResourceId != "" { - parameters.RecordSetProperties.TargetResource.ID = utils.String(targetResourceId) + parameters.Properties.TargetResource.Id = utils.String(targetResourceId) } // TODO: this can be removed when the provider SDK is upgraded @@ -130,73 +136,76 @@ func resourceDnsCNameRecordCreateUpdate(d *pluginsdk.ResourceData, meta interfac return fmt.Errorf("One of either `record` or `target_resource_id` must be specified") } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.CNAME, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating CNAME Record %q (DNS Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsCNameRecordRead(d, meta) } func resourceDnsCNameRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CnameRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.CNAMEName, dns.CNAME) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving CNAME Record %s (DNS Zone %q / Resource Group %q): %+v", id.CNAMEName, id.DnszoneName, id.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.CNAMEName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("fqdn", resp.Fqdn) - d.Set("ttl", resp.TTL) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("fqdn", props.Fqdn) + d.Set("ttl", props.TTL) - if props := resp.RecordSetProperties; props != nil { - cname := "" - if props.CnameRecord != nil && props.CnameRecord.Cname != nil { - cname = *props.CnameRecord.Cname - } - d.Set("record", cname) + cname := "" + if props.CNAMERecord != nil && props.CNAMERecord.Cname != nil { + cname = *props.CNAMERecord.Cname + } + d.Set("record", cname) + + targetResourceId := "" + if props.TargetResource != nil && props.TargetResource.Id != nil { + targetResourceId = *props.TargetResource.Id + } + d.Set("target_resource_id", targetResourceId) - targetResourceId := "" - if props.TargetResource != nil && props.TargetResource.ID != nil { - targetResourceId = *props.TargetResource.ID + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } } - d.Set("target_resource_id", targetResourceId) } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } func resourceDnsCNameRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CnameRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.CNAMEName, dns.CNAME, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting CNAME Record %q (DNS Zone %q / Resource Group %q): %+v", id.CNAMEName, id.DnszoneName, id.ResourceGroup, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil diff --git a/internal/services/dns/dns_cname_record_resource_test.go b/internal/services/dns/dns_cname_record_resource_test.go index df4834378f41..352d278df48c 100644 --- a/internal/services/dns/dns_cname_record_resource_test.go +++ b/internal/services/dns/dns_cname_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -183,17 +182,17 @@ func TestAccAzureRMDnsCNameRecord_AliasToRecord(t *testing.T) { } func (DnsCNameRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CnameRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.CNAMEName, dns.CNAME) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS CNAME record %s (resource group: %s): %v", id.CNAMEName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsCNameRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_mx_record_data_source.go b/internal/services/dns/dns_mx_record_data_source.go index d94bff0ecef2..7905f5d600cb 100644 --- a/internal/services/dns/dns_mx_record_data_source.go +++ b/internal/services/dns/dns_mx_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsMxRecord() *pluginsdk.Resource { @@ -65,42 +64,45 @@ func dataSourceDnsMxRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsMxRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeMX, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.MX) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS MX record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS MX record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewMxRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("record", flattenAzureRmDnsMxRecords(resp.MxRecords)); err != nil { - return err + if err := d.Set("record", flattenAzureRmDnsMxRecords(props.MXRecords)); err != nil { + return err + } + + return tags.FlattenAndSet(d, props.Metadata) + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_mx_record_resource.go b/internal/services/dns/dns_mx_record_resource.go index a74cd20754a5..10c8eebe7547 100644 --- a/internal/services/dns/dns_mx_record_resource.go +++ b/internal/services/dns/dns_mx_record_resource.go @@ -3,19 +3,17 @@ package dns import ( "bytes" "fmt" - "net/http" "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceDnsMxRecord() *pluginsdk.Resource { @@ -33,8 +31,14 @@ func resourceDnsMxRecord() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.MxRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeMX { + return fmt.Errorf("this resource only supports 'MX' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -45,11 +49,12 @@ func resourceDnsMxRecord() *pluginsdk.Resource { Default: "@", }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "record": { @@ -82,13 +87,13 @@ func resourceDnsMxRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsMxRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -97,87 +102,92 @@ func resourceDnsMxRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{} resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewMxRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeMX, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.MX) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS MX Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_mx_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_mx_record", id.ID()) } } ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - MxRecords: expandAzureRmDnsMxRecords(d), + MXRecords: expandAzureRmDnsMxRecords(d), }, } - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.MX, parameters, "", ""); err != nil { - return fmt.Errorf("creating/updating DNS MX Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) - + d.SetId(id.ID()) return resourceDnsMxRecordRead(d, meta) } func resourceDnsMxRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MxRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.DnszoneName, id.MXName, dns.MX) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS MX record %s: %v", id.MXName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.MXName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("record", flattenAzureRmDnsMxRecords(resp.MxRecords)); err != nil { - return err + if err := d.Set("record", flattenAzureRmDnsMxRecords(props.MXRecords)); err != nil { + return err + } + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - return tags.FlattenAndSet(d, resp.Metadata) + + return nil } func resourceDnsMxRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MxRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.MXName, dns.MX, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS MX Record %s: %+v", id.MXName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil @@ -186,16 +196,25 @@ func resourceDnsMxRecordDelete(d *pluginsdk.ResourceData, meta interface{}) erro // flatten creates an array of map where preference is a string to suit // the expectations of the ResourceData schema, so that this data can be // managed by Terradata state. -func flattenAzureRmDnsMxRecords(records *[]dns.MxRecord) []map[string]interface{} { +func flattenAzureRmDnsMxRecords(records *[]recordsets.MxRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0) if records != nil { for _, record := range *records { - preferenceI32 := *record.Preference - preference := strconv.Itoa(int(preferenceI32)) + // TODO: convert this to use an int64 + preference := "" + if record.Preference != nil { + preference = strconv.Itoa(int(*record.Preference)) + } + + exchange := "" + if record.Exchange != nil { + exchange = *record.Exchange + } + results = append(results, map[string]interface{}{ "preference": preference, - "exchange": *record.Exchange, + "exchange": exchange, }) } } @@ -206,19 +225,18 @@ func flattenAzureRmDnsMxRecords(records *[]dns.MxRecord) []map[string]interface{ // expand creates an array of dns.MxRecord, that is, the array needed // by azure-sdk-for-go to manipulate azure resources, hence Preference // is an int32 -func expandAzureRmDnsMxRecords(d *pluginsdk.ResourceData) *[]dns.MxRecord { +func expandAzureRmDnsMxRecords(d *pluginsdk.ResourceData) *[]recordsets.MxRecord { recordStrings := d.Get("record").(*pluginsdk.Set).List() - records := make([]dns.MxRecord, len(recordStrings)) + records := make([]recordsets.MxRecord, len(recordStrings)) for i, v := range recordStrings { mxrecord := v.(map[string]interface{}) preference := mxrecord["preference"].(string) i64, _ := strconv.ParseInt(preference, 10, 32) - i32 := int32(i64) exchange := mxrecord["exchange"].(string) - records[i] = dns.MxRecord{ - Preference: &i32, + records[i] = recordsets.MxRecord{ + Preference: &i64, Exchange: &exchange, } } diff --git a/internal/services/dns/dns_mx_record_resource_test.go b/internal/services/dns/dns_mx_record_resource_test.go index 1faacae7c566..3488d59c47f7 100644 --- a/internal/services/dns/dns_mx_record_resource_test.go +++ b/internal/services/dns/dns_mx_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -112,17 +111,17 @@ func TestAccAzureRMDnsMxRecord_withTags(t *testing.T) { } func (DnsMxRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.MxRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.MXName, dns.MX) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS MX record %s (resource group: %s): %v", id.MXName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsMxRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_ns_record_data_source.go b/internal/services/dns/dns_ns_record_data_source.go index 32021e082d36..e2a2cfc6fe85 100644 --- a/internal/services/dns/dns_ns_record_data_source.go +++ b/internal/services/dns/dns_ns_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsNsRecord() *pluginsdk.Resource { @@ -53,42 +52,45 @@ func dataSourceDnsNsRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsNsRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeNS, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.NS) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS NS record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS NS record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewNsRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("records", flattenAzureRmDnsNsRecords(resp.NsRecords)); err != nil { - return fmt.Errorf("settings `records`: %+v", err) + if err := d.Set("records", flattenAzureRmDnsNsRecords(props.NSRecords)); err != nil { + return fmt.Errorf("settings `records`: %+v", err) + } + + return tags.FlattenAndSet(d, props.Metadata) + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_ns_record_resource.go b/internal/services/dns/dns_ns_record_resource.go index afe07c4ba3b3..996448acef7a 100644 --- a/internal/services/dns/dns_ns_record_resource.go +++ b/internal/services/dns/dns_ns_record_resource.go @@ -2,15 +2,14 @@ package dns import ( "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -30,8 +29,14 @@ func resourceDnsNsRecord() *pluginsdk.Resource { Delete: pluginsdk.DefaultTimeout(30 * time.Minute), }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.NsRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeNS { + return fmt.Errorf("this resource only supports 'NS' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ @@ -41,7 +46,7 @@ func resourceDnsNsRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, @@ -67,13 +72,13 @@ func resourceDnsNsRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsNsRecordCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -82,17 +87,16 @@ func resourceDnsNsRecordCreate(d *pluginsdk.ResourceData, meta interface{}) erro resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewNsRecordID(subscriptionId, resGroup, zoneName, name) - - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.NS) + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeNS, name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS NS Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_ns_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_ns_record", id.ID()) } ttl := int64(d.Get("ttl").(int)) @@ -101,123 +105,125 @@ func resourceDnsNsRecordCreate(d *pluginsdk.ResourceData, meta interface{}) erro recordsRaw := d.Get("records").([]interface{}) records := expandAzureRmDnsNsRecords(recordsRaw) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - NsRecords: records, + NSRecords: records, }, } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.NS, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating DNS NS Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } - d.SetId(resourceId.ID()) - + d.SetId(id.ID()) return resourceDnsNsRecordRead(d, meta) } func resourceDnsNsRecordUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NsRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - existing, err := client.Get(ctx, id.ResourceGroup, id.DnszoneName, id.NSName, dns.NS) + existing, err := client.Get(ctx, *id) if err != nil { - return fmt.Errorf("retrieving NS %q (DNS Zone %q / Resource Group %q): %+v", id.NSName, id.DnszoneName, id.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - - if existing.RecordSetProperties == nil { - return fmt.Errorf("retrieving NS %q (DNS Zone %q / Resource Group %q): `properties` was nil", id.NSName, id.DnszoneName, id.ResourceGroup) + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", *id) + } + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", *id) } if d.HasChange("records") { recordsRaw := d.Get("records").([]interface{}) records := expandAzureRmDnsNsRecords(recordsRaw) - existing.RecordSetProperties.NsRecords = records + existing.Model.Properties.NSRecords = records } if d.HasChange("tags") { t := d.Get("tags").(map[string]interface{}) - existing.RecordSetProperties.Metadata = tags.Expand(t) + existing.Model.Properties.Metadata = tags.Expand(t) } if d.HasChange("ttl") { - existing.RecordSetProperties.TTL = utils.Int64(int64(d.Get("ttl").(int))) + existing.Model.Properties.TTL = utils.Int64(int64(d.Get("ttl").(int))) } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.DnszoneName, id.NSName, dns.NS, existing, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("updating DNS NS Record %q (Zone %q / Resource Group %q): %s", id.NSName, id.DnszoneName, id.ResourceGroup, err) + if _, err := client.Update(ctx, *id, *existing.Model, recordsets.DefaultUpdateOperationOptions()); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) } return resourceDnsNsRecordRead(d, meta) } func resourceDnsNsRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NsRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.NSName, dns.NS) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS NS record %s: %+v", id.NSName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.NSName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if props := resp.RecordSetProperties; props != nil { - if err := d.Set("records", flattenAzureRmDnsNsRecords(props.NsRecords)); err != nil { - return fmt.Errorf("settings `records`: %+v", err) + if err := d.Set("records", flattenAzureRmDnsNsRecords(props.NSRecords)); err != nil { + return fmt.Errorf("settings `records`: %+v", err) + } + + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } func resourceDnsNsRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - dnsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NsRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.NSName, dns.NS, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS NS Record %s: %+v", id.NSName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func flattenAzureRmDnsNsRecords(records *[]dns.NsRecord) []interface{} { +func flattenAzureRmDnsNsRecords(records *[]recordsets.NsRecord) []interface{} { if records == nil { return []interface{}{} } @@ -234,16 +240,14 @@ func flattenAzureRmDnsNsRecords(records *[]dns.NsRecord) []interface{} { return results } -func expandAzureRmDnsNsRecords(input []interface{}) *[]dns.NsRecord { - records := make([]dns.NsRecord, len(input)) - for i, v := range input { +func expandAzureRmDnsNsRecords(input []interface{}) *[]recordsets.NsRecord { + records := make([]recordsets.NsRecord, 0) + for _, v := range input { record := v.(string) - nsRecord := dns.NsRecord{ + records = append(records, recordsets.NsRecord{ Nsdname: &record, - } - - records[i] = nsRecord + }) } return &records } diff --git a/internal/services/dns/dns_ns_record_resource_test.go b/internal/services/dns/dns_ns_record_resource_test.go index 4fb91dc6d7c2..a07dd24a9f27 100644 --- a/internal/services/dns/dns_ns_record_resource_test.go +++ b/internal/services/dns/dns_ns_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -96,17 +95,17 @@ func TestAccDnsNsRecord_withTags(t *testing.T) { } func (DnsNsRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.NsRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.NSName, dns.NS) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS NS record %s (resource group: %s): %v", id.NSName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsNsRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_ptr_record_data_source.go b/internal/services/dns/dns_ptr_record_data_source.go index 0fb1a5183de8..b323c1a19069 100644 --- a/internal/services/dns/dns_ptr_record_data_source.go +++ b/internal/services/dns/dns_ptr_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsPtrRecord() *pluginsdk.Resource { @@ -52,42 +51,45 @@ func dataSourceDnsPtrRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsPtrRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypePTR, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.PTR) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS PTR record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS PTR record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewPtrRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("records", flattenAzureRmDnsPtrRecords(resp.PtrRecords)); err != nil { - return err + if err := d.Set("records", flattenAzureRmDnsPtrRecords(props.PTRRecords)); err != nil { + return err + } + + return tags.FlattenAndSet(d, props.Metadata) + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_ptr_record_resource.go b/internal/services/dns/dns_ptr_record_resource.go index de7e5c38e829..4f1756c96cad 100644 --- a/internal/services/dns/dns_ptr_record_resource.go +++ b/internal/services/dns/dns_ptr_record_resource.go @@ -2,18 +2,16 @@ package dns import ( "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceDnsPtrRecord() *pluginsdk.Resource { @@ -31,8 +29,14 @@ func resourceDnsPtrRecord() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.PtrRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypePTR { + return fmt.Errorf("this resource only supports 'PTR' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ "name": { @@ -41,11 +45,12 @@ func resourceDnsPtrRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "records": { @@ -65,13 +70,13 @@ func resourceDnsPtrRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsPtrRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -80,104 +85,106 @@ func resourceDnsPtrRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{ resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewPtrRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypePTR, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.PTR) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS PTR Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_ptr_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_ptr_record", id.ID()) } } ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) - parameters := dns.RecordSet{ - RecordSetProperties: &dns.RecordSetProperties{ + parameters := recordsets.RecordSet{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - PtrRecords: expandAzureRmDnsPtrRecords(d), + PTRRecords: expandAzureRmDnsPtrRecords(d), }, } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.PTR, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS PTR Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) - + d.SetId(id.ID()) return resourceDnsPtrRecordRead(d, meta) } func resourceDnsPtrRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client) - dnsClient := client.Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.PtrRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.PTRName, dns.PTR) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS PTR record %s: %+v", id.PTRName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.PTRName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - if err := d.Set("records", flattenAzureRmDnsPtrRecords(resp.PtrRecords)); err != nil { - return err + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) + + if err := d.Set("records", flattenAzureRmDnsPtrRecords(props.PTRRecords)); err != nil { + return err + } + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - return tags.FlattenAndSet(d, resp.Metadata) + + return nil } func resourceDnsPtrRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client) - dnsClient := client.Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.PtrRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := dnsClient.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.PTRName, dns.PTR, "") - if err != nil { - if resp.StatusCode == http.StatusNotFound { - return nil - } - - return fmt.Errorf("deleting DNS PTR Record %s: %+v", id.PTRName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func flattenAzureRmDnsPtrRecords(records *[]dns.PtrRecord) []string { +func flattenAzureRmDnsPtrRecords(records *[]recordsets.PtrRecord) []string { results := make([]string, 0) if records != nil { for _, record := range *records { + if record.Ptrdname == nil { + continue + } + results = append(results, *record.Ptrdname) } } @@ -185,15 +192,15 @@ func flattenAzureRmDnsPtrRecords(records *[]dns.PtrRecord) []string { return results } -func expandAzureRmDnsPtrRecords(d *pluginsdk.ResourceData) *[]dns.PtrRecord { +func expandAzureRmDnsPtrRecords(d *pluginsdk.ResourceData) *[]recordsets.PtrRecord { recordStrings := d.Get("records").(*pluginsdk.Set).List() - records := make([]dns.PtrRecord, len(recordStrings)) + records := make([]recordsets.PtrRecord, 0) - for i, v := range recordStrings { + for _, v := range recordStrings { fqdn := v.(string) - records[i] = dns.PtrRecord{ + records = append(records, recordsets.PtrRecord{ Ptrdname: &fqdn, - } + }) } return &records diff --git a/internal/services/dns/dns_ptr_record_resource_test.go b/internal/services/dns/dns_ptr_record_resource_test.go index 37e964e91c96..433002f635ed 100644 --- a/internal/services/dns/dns_ptr_record_resource_test.go +++ b/internal/services/dns/dns_ptr_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -98,17 +97,17 @@ func TestAccDnsPtrRecord_withTags(t *testing.T) { } func (DnsPtrRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.PtrRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.PTRName, dns.PTR) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS PTR record %s (resource group: %s): %v", id.PTRName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsPtrRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_soa_record_data_source.go b/internal/services/dns/dns_soa_record_data_source.go index 8e2c37e2552e..119408e67a5d 100644 --- a/internal/services/dns/dns_soa_record_data_source.go +++ b/internal/services/dns/dns_soa_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsSoaRecord() *pluginsdk.Resource { @@ -81,46 +80,50 @@ func dataSourceDnsSoaRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsSoaRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) - - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, "@", dns.SOA) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeSOA, "@") + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS SOA record (zone %s) was not found", zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS SOA record (zone %s): %+v", zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewSoaRecordID(subscriptionId, resourceGroup, zoneName, "@") - d.SetId(resourceId.ID()) + d.SetId(id.ID()) + + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if soaRecord := props.SOARecord; soaRecord != nil { + d.Set("email", soaRecord.Email) + d.Set("host_name", soaRecord.Host) + d.Set("expire_time", soaRecord.ExpireTime) + d.Set("minimum_ttl", soaRecord.MinimumTTL) + d.Set("refresh_time", soaRecord.RefreshTime) + d.Set("retry_time", soaRecord.RetryTime) + d.Set("serial_number", soaRecord.SerialNumber) + } + + return tags.FlattenAndSet(d, props.Metadata) + } - if soaRecord := resp.SoaRecord; soaRecord != nil { - d.Set("email", soaRecord.Email) - d.Set("host_name", soaRecord.Host) - d.Set("expire_time", soaRecord.ExpireTime) - d.Set("minimum_ttl", soaRecord.MinimumTTL) - d.Set("refresh_time", soaRecord.RefreshTime) - d.Set("retry_time", soaRecord.RetryTime) - d.Set("serial_number", soaRecord.SerialNumber) } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_srv_record_data_source.go b/internal/services/dns/dns_srv_record_data_source.go index 2b990f8c7b0c..504f8597c610 100644 --- a/internal/services/dns/dns_srv_record_data_source.go +++ b/internal/services/dns/dns_srv_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsSrvRecord() *pluginsdk.Resource { @@ -74,42 +73,44 @@ func dataSourceDnsSrvRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsSrvRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) - - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.SRV) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeSRV, d.Get("name").(string)) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS SRV record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS SRV record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewSrvRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) + + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if err := d.Set("record", flattenAzureRmDnsSrvRecords(props.SRVRecords)); err != nil { + return err + } - if err := d.Set("record", flattenAzureRmDnsSrvRecords(resp.SrvRecords)); err != nil { - return err + return tags.FlattenAndSet(d, props.Metadata) + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_srv_record_resource.go b/internal/services/dns/dns_srv_record_resource.go index 5616eaeb8047..a069d4c010ce 100644 --- a/internal/services/dns/dns_srv_record_resource.go +++ b/internal/services/dns/dns_srv_record_resource.go @@ -3,18 +3,16 @@ package dns import ( "bytes" "fmt" - "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceDnsSrvRecord() *pluginsdk.Resource { @@ -31,8 +29,14 @@ func resourceDnsSrvRecord() *pluginsdk.Resource { Delete: pluginsdk.DefaultTimeout(30 * time.Minute), }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SrvRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeSRV { + return fmt.Errorf("this resource only supports 'SRV' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ "name": { @@ -41,11 +45,12 @@ func resourceDnsSrvRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "record": { @@ -87,13 +92,13 @@ func resourceDnsSrvRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsSrvRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -102,103 +107,129 @@ func resourceDnsSrvRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{ resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewSrvRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeSRV, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.SRV) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS SRV Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_srv_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_srv_record", id.ID()) } } ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - SrvRecords: expandAzureRmDnsSrvRecords(d), + SRVRecords: expandAzureRmDnsSrvRecords(d), }, } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.SRV, parameters, eTag, ifNoneMatch); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { return fmt.Errorf("creating/updating DNS SRV Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsSrvRecordRead(d, meta) } func resourceDnsSrvRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SrvRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.DnszoneName, id.SRVName, dns.SRV) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS SRV record %s: %v", id.SRVName, err) + + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.SRVName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - if err := d.Set("record", flattenAzureRmDnsSrvRecords(resp.SrvRecords)); err != nil { - return err + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) + + if err := d.Set("record", flattenAzureRmDnsSrvRecords(props.SRVRecords)); err != nil { + return err + } + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - return tags.FlattenAndSet(d, resp.Metadata) + + return nil } func resourceDnsSrvRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SrvRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.SRVName, dns.SRV, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS SRV Record %s: %+v", id.SRVName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func flattenAzureRmDnsSrvRecords(records *[]dns.SrvRecord) []map[string]interface{} { +func flattenAzureRmDnsSrvRecords(records *[]recordsets.SrvRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0) if records != nil { for _, record := range *records { + port := int64(0) + if record.Port != nil { + port = *record.Port + } + + priority := int64(0) + if record.Priority != nil { + priority = *record.Priority + } + + target := "" + if record.Target != nil { + target = *record.Target + } + + weight := int64(0) + if record.Weight != nil { + weight = *record.Weight + } + results = append(results, map[string]interface{}{ - "priority": *record.Priority, - "weight": *record.Weight, - "port": *record.Port, - "target": *record.Target, + "port": port, + "priority": priority, + "target": target, + "weight": weight, }) } } @@ -206,25 +237,23 @@ func flattenAzureRmDnsSrvRecords(records *[]dns.SrvRecord) []map[string]interfac return results } -func expandAzureRmDnsSrvRecords(d *pluginsdk.ResourceData) *[]dns.SrvRecord { +func expandAzureRmDnsSrvRecords(d *pluginsdk.ResourceData) *[]recordsets.SrvRecord { recordStrings := d.Get("record").(*pluginsdk.Set).List() - records := make([]dns.SrvRecord, len(recordStrings)) + records := make([]recordsets.SrvRecord, 0) - for i, v := range recordStrings { + for _, v := range recordStrings { record := v.(map[string]interface{}) - priority := int32(record["priority"].(int)) - weight := int32(record["weight"].(int)) - port := int32(record["port"].(int)) + priority := int64(record["priority"].(int)) + weight := int64(record["weight"].(int)) + port := int64(record["port"].(int)) target := record["target"].(string) - srvRecord := dns.SrvRecord{ + records = append(records, recordsets.SrvRecord{ Priority: &priority, Weight: &weight, Port: &port, Target: &target, - } - - records[i] = srvRecord + }) } return &records diff --git a/internal/services/dns/dns_srv_record_resource_test.go b/internal/services/dns/dns_srv_record_resource_test.go index bbf0f360dc1e..dcda2b2c4e0f 100644 --- a/internal/services/dns/dns_srv_record_resource_test.go +++ b/internal/services/dns/dns_srv_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -96,17 +95,17 @@ func TestAccDnsSrvRecord_withTags(t *testing.T) { } func (DnsSrvRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SrvRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.SRVName, dns.SRV) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS SRV record %s (resource group: %s): %v", id.SRVName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsSrvRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_txt_record_data_source.go b/internal/services/dns/dns_txt_record_data_source.go index 11bb141a27e4..1168e6e66af5 100644 --- a/internal/services/dns/dns_txt_record_data_source.go +++ b/internal/services/dns/dns_txt_record_data_source.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsTxtRecord() *pluginsdk.Resource { @@ -58,42 +57,46 @@ func dataSourceDnsTxtRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsTxtRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() subscriptionId := meta.(*clients.Client).Account.SubscriptionId - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - zoneName := d.Get("zone_name").(string) + id := recordsets.NewRecordTypeID(subscriptionId, d.Get("resource_group_name").(string), d.Get("zone_name").(string), recordsets.RecordTypeTXT, d.Get("name").(string)) - resp, err := recordSetsClient.Get(ctx, resourceGroup, zoneName, name, dns.TXT) + resp, err := recordSetsClient.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS TXT record %s: (zone %s) was not found", name, zoneName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS TXT record %s (zone %s): %+v", name, zoneName, err) + return fmt.Errorf("reading %s: %+v", id, err) } - resourceId := parse.NewTxtRecordID(subscriptionId, resourceGroup, zoneName, name) - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("zone_name", zoneName) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) - if err := d.Set("record", flattenAzureRmDnsTxtRecords(resp.TxtRecords)); err != nil { - return err + if err := d.Set("record", flattenAzureRmDnsTxtRecords(props.TXTRecords)); err != nil { + return err + } + + return tags.FlattenAndSet(d, props.Metadata) + + } } - return tags.FlattenAndSet(d, resp.Metadata) + return nil } diff --git a/internal/services/dns/dns_txt_record_resource.go b/internal/services/dns/dns_txt_record_resource.go index 3d53d2cf318c..748217de4a94 100644 --- a/internal/services/dns/dns_txt_record_resource.go +++ b/internal/services/dns/dns_txt_record_resource.go @@ -2,20 +2,18 @@ package dns import ( "fmt" - "net/http" "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceDnsTxtRecord() *pluginsdk.Resource { @@ -32,8 +30,14 @@ func resourceDnsTxtRecord() *pluginsdk.Resource { Delete: pluginsdk.DefaultTimeout(30 * time.Minute), }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.TxtRecordID(id) - return err + parsed, err := recordsets.ParseRecordTypeID(id) + if err != nil { + return err + } + if parsed.RecordType != recordsets.RecordTypeTXT { + return fmt.Errorf("this resource only supports 'TXT' records") + } + return nil }), Schema: map[string]*pluginsdk.Schema{ "name": { @@ -42,11 +46,12 @@ func resourceDnsTxtRecord() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": commonschema.ResourceGroupName(), "zone_name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, }, "record": { @@ -73,13 +78,13 @@ func resourceDnsTxtRecord() *pluginsdk.Resource { Computed: true, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsTxtRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() @@ -88,115 +93,120 @@ func resourceDnsTxtRecordCreateUpdate(d *pluginsdk.ResourceData, meta interface{ resGroup := d.Get("resource_group_name").(string) zoneName := d.Get("zone_name").(string) - resourceId := parse.NewTxtRecordID(subscriptionId, resGroup, zoneName, name) - + id := recordsets.NewRecordTypeID(subscriptionId, resGroup, zoneName, recordsets.RecordTypeTXT, name) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, zoneName, name, dns.TXT) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS TXT Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_txt_record", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_txt_record", id.ID()) } } ttl := int64(d.Get("ttl").(int)) t := d.Get("tags").(map[string]interface{}) - parameters := dns.RecordSet{ + parameters := recordsets.RecordSet{ Name: &name, - RecordSetProperties: &dns.RecordSetProperties{ + Properties: &recordsets.RecordSetProperties{ Metadata: tags.Expand(t), TTL: &ttl, - TxtRecords: expandAzureRmDnsTxtRecords(d), + TXTRecords: expandAzureRmDnsTxtRecords(d), }, } - eTag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, zoneName, name, dns.TXT, parameters, eTag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS TXT Record %q (Zone %q / Resource Group %q): %s", name, zoneName, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsTxtRecordRead(d, meta) } func resourceDnsTxtRecordRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TxtRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.DnszoneName, id.TXTName, dns.TXT) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS TXT record %s: %+v", id.TXTName, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.TXTName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("zone_name", id.DnszoneName) - d.Set("ttl", resp.TTL) - d.Set("fqdn", resp.Fqdn) + d.Set("name", id.RelativeRecordSetName) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("zone_name", id.ZoneName) - if err := d.Set("record", flattenAzureRmDnsTxtRecords(resp.TxtRecords)); err != nil { - return err + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ttl", props.TTL) + d.Set("fqdn", props.Fqdn) + + if err := d.Set("record", flattenAzureRmDnsTxtRecords(props.TXTRecords)); err != nil { + return err + } + if err := tags.FlattenAndSet(d, props.Metadata); err != nil { + return err + } + } } - return tags.FlattenAndSet(d, resp.Metadata) + + return nil } func resourceDnsTxtRecordDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TxtRecordID(d.Id()) + id, err := recordsets.ParseRecordTypeID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.DnszoneName, id.TXTName, dns.TXT, "") - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("deleting DNS TXT Record %s: %+v", id.TXTName, err) + if _, err := client.Delete(ctx, *id, recordsets.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func flattenAzureRmDnsTxtRecords(records *[]dns.TxtRecord) []map[string]interface{} { +func flattenAzureRmDnsTxtRecords(records *[]recordsets.TxtRecord) []map[string]interface{} { results := make([]map[string]interface{}, 0) if records != nil { for _, record := range *records { - txtRecord := make(map[string]interface{}) - + value := "" if v := record.Value; v != nil { - value := strings.Join(*v, "") - txtRecord["value"] = value + value = strings.Join(*v, "") } - results = append(results, txtRecord) + results = append(results, map[string]interface{}{ + "value": value, + }) } } return results } -func expandAzureRmDnsTxtRecords(d *pluginsdk.ResourceData) *[]dns.TxtRecord { +func expandAzureRmDnsTxtRecords(d *pluginsdk.ResourceData) *[]recordsets.TxtRecord { recordStrings := d.Get("record").(*pluginsdk.Set).List() - records := make([]dns.TxtRecord, len(recordStrings)) + records := make([]recordsets.TxtRecord, len(recordStrings)) segmentLen := 254 for i, v := range recordStrings { @@ -210,11 +220,9 @@ func expandAzureRmDnsTxtRecords(d *pluginsdk.ResourceData) *[]dns.TxtRecord { } value = append(value, v) - txtRecord := dns.TxtRecord{ + records[i] = recordsets.TxtRecord{ Value: &value, } - - records[i] = txtRecord } return &records diff --git a/internal/services/dns/dns_txt_record_resource_test.go b/internal/services/dns/dns_txt_record_resource_test.go index 48bac60156fd..a1ddfef1fbc7 100644 --- a/internal/services/dns/dns_txt_record_resource_test.go +++ b/internal/services/dns/dns_txt_record_resource_test.go @@ -5,11 +5,10 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -96,17 +95,17 @@ func TestAccDnsTxtRecord_withTags(t *testing.T) { } func (DnsTxtRecordResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.TxtRecordID(state.ID) + id, err := recordsets.ParseRecordTypeID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.RecordSetsClient.Get(ctx, id.ResourceGroup, id.DnszoneName, id.TXTName, dns.TXT) + resp, err := clients.Dns.RecordSets.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS TXT record %s (resource group: %s): %v", id.TXTName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.RecordSetProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsTxtRecordResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/dns_zone_data_source.go b/internal/services/dns/dns_zone_data_source.go index b931520edc88..bdd483ad11d5 100644 --- a/internal/services/dns/dns_zone_data_source.go +++ b/internal/services/dns/dns_zone_data_source.go @@ -5,13 +5,14 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceDnsZone() *pluginsdk.Resource { @@ -29,6 +30,7 @@ func dataSourceDnsZone() *pluginsdk.Resource { }, "resource_group_name": { + // TODO: we need a CommonSchema type for this which doesn't have ForceNew Type: pluginsdk.TypeString, Optional: true, Computed: true, @@ -51,54 +53,53 @@ func dataSourceDnsZone() *pluginsdk.Resource { Set: pluginsdk.HashString, }, - "tags": tags.SchemaDataSource(), + "tags": commonschema.TagsDataSource(), }, } } func dataSourceDnsZoneRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.ZonesClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + client := meta.(*clients.Client).Dns.Zones subscriptionId := meta.(*clients.Client).Account.SubscriptionId - + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - - var ( - resp dns.Zone - err error - ) - if resourceGroup != "" { - resp, err = client.Get(ctx, resourceGroup, name) + id := zones.NewDnsZoneID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + var zone *zones.Zone + if id.ResourceGroupName != "" { + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Error: DNS Zone %q (Resource Group %q) was not found", name, resourceGroup) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading DNS Zone %q (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } + + zone = resp.Model } else { - var zone *dns.Zone - zone, resourceGroup, err = findZone(client, ctx, name) + result, resourceGroupName, err := findZone(ctx, client, id.SubscriptionId, id.ZoneName) if err != nil { return err } - if zone == nil { - return fmt.Errorf("Error: DNS Zone %q was not found", name) + if resourceGroupName == nil { + return fmt.Errorf("unable to locate the Resource Group for DNS Zone %q in Subscription %q", id.ResourceGroupName, subscriptionId) } - resp = *zone + zone = result + id.ResourceGroupName = *resourceGroupName } - resourceId := parse.NewDnsZoneID(subscriptionId, resourceGroup, name) - d.SetId(resourceId.ID()) + if zone == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + d.SetId(id.ID()) - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) + d.Set("name", id.ZoneName) + d.Set("resource_group_name", id.ResourceGroupName) - if props := resp.ZoneProperties; props != nil { + if props := zone.Properties; props != nil { d.Set("number_of_record_sets", props.NumberOfRecordSets) d.Set("max_number_of_record_sets", props.MaxNumberOfRecordSets) @@ -111,36 +112,37 @@ func dataSourceDnsZoneRead(d *pluginsdk.ResourceData, meta interface{}) error { } } - return tags.FlattenAndSet(d, resp.Tags) + if err := tags.FlattenAndSet(d, zone.Tags); err != nil { + return err + } + + return nil } -func findZone(client *dns.ZonesClient, ctx context.Context, name string) (*dns.Zone, string, error) { - zonesIterator, err := client.ListComplete(ctx, nil) +func findZone(ctx context.Context, client *zones.ZonesClient, subscriptionId, name string) (*zones.Zone, *string, error) { + subscriptionResourceId := commonids.NewSubscriptionID(subscriptionId) + zonesIterator, err := client.ListComplete(ctx, subscriptionResourceId, zones.DefaultListOperationOptions()) if err != nil { - return nil, "", fmt.Errorf("listing DNS Zones: %+v", err) + return nil, nil, fmt.Errorf("listing DNS Zones: %+v", err) } - var found *dns.Zone - for zonesIterator.NotDone() { - zone := zonesIterator.Value() + var found zones.Zone + for _, zone := range zonesIterator.Items { if zone.Name != nil && *zone.Name == name { - if found != nil { - return nil, "", fmt.Errorf("found multiple DNS zones with name %q, please specify the resource group", name) + if found.Id != nil { + return nil, nil, fmt.Errorf("found multiple DNS zones with name %q, please specify the resource group", name) } - found = &zone - } - if err := zonesIterator.NextWithContext(ctx); err != nil { - return nil, "", fmt.Errorf("listing DNS Zones: %+v", err) + found = zone } } - if found == nil || found.ID == nil { - return nil, "", fmt.Errorf("could not find DNS zone with name: %q", name) + if found.Id == nil { + return nil, nil, fmt.Errorf("could not find DNS zone with name: %q", name) } - id, err := parse.DnsZoneID(*found.ID) + id, err := zones.ParseDnsZoneIDInsensitively(*found.Id) if err != nil { - return nil, "", fmt.Errorf("DNS zone id not valid: %+v", err) + return nil, nil, fmt.Errorf("parsing %q as a DNS Zone ID: %+v", *found.Id, err) } - return found, id.ResourceGroup, nil + return &found, &id.ResourceGroupName, nil } diff --git a/internal/services/dns/dns_zone_resource.go b/internal/services/dns/dns_zone_resource.go index 729fe806dc91..59bc4948da6e 100644 --- a/internal/services/dns/dns_zone_resource.go +++ b/internal/services/dns/dns_zone_resource.go @@ -5,14 +5,16 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -39,7 +41,7 @@ func resourceDnsZone() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.DnsZoneID(id) + _, err := zones.ParseDnsZoneID(id) return err }), Schema: map[string]*pluginsdk.Schema{ @@ -49,7 +51,7 @@ func resourceDnsZone() *pluginsdk.Resource { ForceNew: true, }, - "resource_group_name": azure.SchemaResourceGroupNameDiffSuppress(), + "resource_group_name": commonschema.ResourceGroupName(), "number_of_record_sets": { Type: pluginsdk.TypeInt, @@ -130,7 +132,7 @@ func resourceDnsZone() *pluginsdk.Resource { ValidateFunc: validation.IntBetween(0, 2147483647), }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), "fqdn": { Type: pluginsdk.TypeString, @@ -140,145 +142,142 @@ func resourceDnsZone() *pluginsdk.Resource { }, }, - "tags": tags.Schema(), + "tags": commonschema.Tags(), }, } } func resourceDnsZoneCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.ZonesClient - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + client := meta.(*clients.Client).Dns.Zones + recordSetsClient := meta.(*clients.Client).Dns.RecordSets subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - resGroup := d.Get("resource_group_name").(string) - - resourceId := parse.NewDnsZoneID(subscriptionId, resGroup, name) - + id := zones.NewDnsZoneID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, resGroup, name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing DNS Zone %q (Resource Group %q): %s", name, resGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_dns_zone", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_dns_zone", id.ID()) } } - location := "global" t := d.Get("tags").(map[string]interface{}) - parameters := dns.Zone{ - Location: &location, + parameters := zones.Zone{ + Location: location.Normalize("global"), Tags: tags.Expand(t), } - etag := "" - ifNoneMatch := "" // set to empty to allow updates to records after creation - if _, err := client.CreateOrUpdate(ctx, resGroup, name, parameters, etag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS Zone %q (Resource Group %q): %s", name, resGroup, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters, zones.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } if v, ok := d.GetOk("soa_record"); ok { soaRecord := v.([]interface{})[0].(map[string]interface{}) - rsParameters := dns.RecordSet{ - RecordSetProperties: &dns.RecordSetProperties{ + rsParameters := recordsets.RecordSet{ + Properties: &recordsets.RecordSetProperties{ TTL: utils.Int64(int64(soaRecord["ttl"].(int))), Metadata: tags.Expand(soaRecord["tags"].(map[string]interface{})), - SoaRecord: expandArmDNSZoneSOARecord(soaRecord), + SOARecord: expandArmDNSZoneSOARecord(soaRecord), }, } - if len(name+strings.TrimSuffix(*rsParameters.RecordSetProperties.SoaRecord.Email, ".")) > 253 { + if len(id.ZoneName+strings.TrimSuffix(*rsParameters.Properties.SOARecord.Email, ".")) > 253 { return fmt.Errorf("`email` which is concatenated with DNS Zone `name` cannot exceed 253 characters excluding a trailing period") } - if _, err := recordSetsClient.CreateOrUpdate(ctx, resGroup, name, "@", dns.SOA, rsParameters, etag, ifNoneMatch); err != nil { - return fmt.Errorf("creating/updating DNS SOA Record @ (Zone %q / Resource Group %q): %s", name, resGroup, err) + soaRecordId := recordsets.NewRecordTypeID(id.SubscriptionId, id.ResourceGroupName, id.ZoneName, recordsets.RecordTypeSOA, "@") + if _, err := recordSetsClient.CreateOrUpdate(ctx, soaRecordId, rsParameters, recordsets.DefaultCreateOrUpdateOperationOptions()); err != nil { + return fmt.Errorf("creating/updating %s: %+v", soaRecordId, err) } } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceDnsZoneRead(d, meta) } func resourceDnsZoneRead(d *pluginsdk.ResourceData, meta interface{}) error { - zonesClient := meta.(*clients.Client).Dns.ZonesClient - recordSetsClient := meta.(*clients.Client).Dns.RecordSetsClient + zonesClient := meta.(*clients.Client).Dns.Zones + recordSetsClient := meta.(*clients.Client).Dns.RecordSets ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.DnsZoneID(d.Id()) + id, err := zones.ParseDnsZoneID(d.Id()) if err != nil { return err } - resp, err := zonesClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := zonesClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading DNS Zone %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - - d.Set("number_of_record_sets", resp.NumberOfRecordSets) - d.Set("max_number_of_record_sets", resp.MaxNumberOfRecordSets) - - nameServers := make([]string, 0) - if s := resp.NameServers; s != nil { - nameServers = *s - } - if err := d.Set("name_servers", nameServers); err != nil { - return err - } - - rsResp, err := recordSetsClient.Get(ctx, id.ResourceGroup, id.Name, "@", dns.SOA) + soaRecord := recordsets.NewRecordTypeID(id.SubscriptionId, id.ResourceGroupName, id.ZoneName, recordsets.RecordTypeSOA, "@") + soaRecordResp, err := recordSetsClient.Get(ctx, soaRecord) if err != nil { - return fmt.Errorf("reading DNS SOA record @: %v", err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - if err := d.Set("soa_record", flattenArmDNSZoneSOARecord(&rsResp)); err != nil { + if err := d.Set("soa_record", flattenArmDNSZoneSOARecord(soaRecordResp.Model)); err != nil { return fmt.Errorf("setting `soa_record`: %+v", err) } - return tags.FlattenAndSet(d, resp.Tags) + d.Set("name", id.ZoneName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("number_of_record_sets", props.NumberOfRecordSets) + d.Set("max_number_of_record_sets", props.MaxNumberOfRecordSets) + + nameServers := make([]string, 0) + if s := props.NameServers; s != nil { + nameServers = *s + } + if err := d.Set("name_servers", nameServers); err != nil { + return err + } + } + + if err := tags.FlattenAndSet(d, model.Tags); err != nil { + return err + } + } + + return nil } func resourceDnsZoneDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Dns.ZonesClient + client := meta.(*clients.Client).Dns.Zones ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.DnsZoneID(d.Id()) + id, err := zones.ParseDnsZoneID(d.Id()) if err != nil { return err } - etag := "" - future, err := client.Delete(ctx, id.ResourceGroup, id.Name, etag) - if err != nil { - return fmt.Errorf("deleting DNS Zone %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the deletion of DNS Zone %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + if err := client.DeleteThenPoll(ctx, *id, zones.DefaultDeleteOperationOptions()); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func expandArmDNSZoneSOARecord(input map[string]interface{}) *dns.SoaRecord { - return &dns.SoaRecord{ +func expandArmDNSZoneSOARecord(input map[string]interface{}) *recordsets.SoaRecord { + return &recordsets.SoaRecord{ Email: utils.String(input["email"].(string)), Host: utils.String(input["host_name"].(string)), ExpireTime: utils.Int64(int64(input["expire_time"].(int))), @@ -289,75 +288,76 @@ func expandArmDNSZoneSOARecord(input map[string]interface{}) *dns.SoaRecord { } } -func flattenArmDNSZoneSOARecord(input *dns.RecordSet) []interface{} { - if input == nil { - return make([]interface{}, 0) - } - - ttl := 0 - if input.TTL != nil { - ttl = int(*input.TTL) - } - - metaData := make(map[string]interface{}) - if input.Metadata != nil { - metaData = tags.Flatten(input.Metadata) - } - - fqdn := "" - if input.Fqdn != nil { - fqdn = *input.Fqdn - } - - email := "" - hostName := "" - expireTime := 0 - minimumTTL := 0 - refreshTime := 0 - retryTime := 0 - serialNumber := 0 - if input.SoaRecord != nil { - if input.SoaRecord.Email != nil { - email = *input.SoaRecord.Email - } - - if input.SoaRecord.Host != nil { - hostName = *input.SoaRecord.Host - } - - if input.SoaRecord.ExpireTime != nil { - expireTime = int(*input.SoaRecord.ExpireTime) - } +func flattenArmDNSZoneSOARecord(input *recordsets.RecordSet) []interface{} { + output := make([]interface{}, 0) + if input != nil { + if props := input.Properties; props != nil { + ttl := 0 + if props.TTL != nil { + ttl = int(*props.TTL) + } - if input.SoaRecord.MinimumTTL != nil { - minimumTTL = int(*input.SoaRecord.MinimumTTL) - } + metaData := make(map[string]interface{}) + if props.Metadata != nil { + metaData = tags.Flatten(props.Metadata) + } - if input.SoaRecord.RefreshTime != nil { - refreshTime = int(*input.SoaRecord.RefreshTime) - } + fqdn := "" + if props.Fqdn != nil { + fqdn = *props.Fqdn + } - if input.SoaRecord.RetryTime != nil { - retryTime = int(*input.SoaRecord.RetryTime) - } + email := "" + hostName := "" + expireTime := 0 + minimumTTL := 0 + refreshTime := 0 + retryTime := 0 + serialNumber := 0 + if record := props.SOARecord; record != nil { + if record.Email != nil { + email = *record.Email + } + + if record.Host != nil { + hostName = *record.Host + } + + if record.ExpireTime != nil { + expireTime = int(*record.ExpireTime) + } + + if record.MinimumTTL != nil { + minimumTTL = int(*record.MinimumTTL) + } + + if record.RefreshTime != nil { + refreshTime = int(*record.RefreshTime) + } + + if record.RetryTime != nil { + retryTime = int(*record.RetryTime) + } + + if record.SerialNumber != nil { + serialNumber = int(*record.SerialNumber) + } + } - if input.SoaRecord.SerialNumber != nil { - serialNumber = int(*input.SoaRecord.SerialNumber) + output = append(output, map[string]interface{}{ + "email": email, + "host_name": hostName, + "expire_time": expireTime, + "minimum_ttl": minimumTTL, + "refresh_time": refreshTime, + "retry_time": retryTime, + "serial_number": serialNumber, + "ttl": ttl, + "tags": metaData, + "fqdn": fqdn, + }) } } - return []interface{}{ - map[string]interface{}{ - "email": email, - "host_name": hostName, - "expire_time": expireTime, - "minimum_ttl": minimumTTL, - "refresh_time": refreshTime, - "retry_time": retryTime, - "serial_number": serialNumber, - "ttl": ttl, - "tags": metaData, - "fqdn": fqdn, - }, - } + return output } diff --git a/internal/services/dns/dns_zone_resource_test.go b/internal/services/dns/dns_zone_resource_test.go index db0dc4d6baa7..bd1f167892fd 100644 --- a/internal/services/dns/dns_zone_resource_test.go +++ b/internal/services/dns/dns_zone_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -101,17 +101,17 @@ func TestAccDnsZone_withSOARecord(t *testing.T) { } func (DnsZoneResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.DnsZoneID(state.ID) + id, err := zones.ParseDnsZoneID(state.ID) if err != nil { return nil, err } - resp, err := clients.Dns.ZonesClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Dns.Zones.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("retrieving DNS zone %s (resource group: %s): %v", id.Name, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return utils.Bool(resp.ZoneProperties != nil), nil + return utils.Bool(resp.Model != nil), nil } func (DnsZoneResource) basic(data acceptance.TestData) string { diff --git a/internal/services/dns/migration/dns_zone_V0_to_V1.go b/internal/services/dns/migration/dns_zone_V0_to_V1.go index 9222e7d66d47..d67a5af9c083 100644 --- a/internal/services/dns/migration/dns_zone_V0_to_V1.go +++ b/internal/services/dns/migration/dns_zone_V0_to_V1.go @@ -5,8 +5,8 @@ import ( "fmt" "log" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -129,20 +129,20 @@ func (DnsZoneV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { groupsClient := meta.(*clients.Client).Resource.GroupsClient oldId := rawState["id"].(string) - id, err := parse.DnsZoneID(oldId) + id, err := zones.ParseDnsZoneID(oldId) if err != nil { return rawState, err } - resGroup, err := groupsClient.Get(ctx, id.ResourceGroup) + resGroup, err := groupsClient.Get(ctx, id.ResourceGroupName) if err != nil { return rawState, err } if resGroup.Name == nil { - return rawState, fmt.Errorf("`name` was nil for Resource Group %q", id.ResourceGroup) + return rawState, fmt.Errorf("`name` was nil for Resource Group %q", id.ResourceGroupName) } resourceGroup := *resGroup.Name name := rawState["name"].(string) - newId := parse.NewDnsZoneID(id.SubscriptionId, resourceGroup, name).ID() + newId := zones.NewDnsZoneID(id.SubscriptionId, resourceGroup, name).ID() log.Printf("Updating `id` from %q to %q", oldId, newId) rawState["id"] = newId return rawState, nil diff --git a/internal/services/dns/parse/a_record.go b/internal/services/dns/parse/a_record.go deleted file mode 100644 index cc22cfdc3cde..000000000000 --- a/internal/services/dns/parse/a_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ARecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - AName string -} - -func NewARecordID(subscriptionId, resourceGroup, dnszoneName, aName string) ARecordId { - return ARecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - AName: aName, - } -} - -func (id ARecordId) String() string { - segments := []string{ - fmt.Sprintf("A Name %q", id.AName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "A Record", segmentsStr) -} - -func (id ARecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/A/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.AName) -} - -// ARecordID parses a ARecord ID into an ARecordId struct -func ARecordID(input string) (*ARecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := ARecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.AName, err = id.PopSegment("A"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/a_record_test.go b/internal/services/dns/parse/a_record_test.go deleted file mode 100644 index d7d2894fb685..000000000000 --- a/internal/services/dns/parse/a_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ARecordId{} - -func TestARecordIDFormatter(t *testing.T) { - actual := NewARecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "eh1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/eh1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestARecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ARecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing AName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for AName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/eh1", - Expected: &ARecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - AName: "eh1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/A/EH1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ARecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.AName != v.Expected.AName { - t.Fatalf("Expected %q but got %q for AName", v.Expected.AName, actual.AName) - } - } -} diff --git a/internal/services/dns/parse/aaaa_record.go b/internal/services/dns/parse/aaaa_record.go deleted file mode 100644 index 4c05e28108ca..000000000000 --- a/internal/services/dns/parse/aaaa_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type AaaaRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - AAAAName string -} - -func NewAaaaRecordID(subscriptionId, resourceGroup, dnszoneName, aAAAName string) AaaaRecordId { - return AaaaRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - AAAAName: aAAAName, - } -} - -func (id AaaaRecordId) String() string { - segments := []string{ - fmt.Sprintf("A A A A Name %q", id.AAAAName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Aaaa Record", segmentsStr) -} - -func (id AaaaRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/AAAA/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.AAAAName) -} - -// AaaaRecordID parses a AaaaRecord ID into an AaaaRecordId struct -func AaaaRecordID(input string) (*AaaaRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := AaaaRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.AAAAName, err = id.PopSegment("AAAA"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/aaaa_record_test.go b/internal/services/dns/parse/aaaa_record_test.go deleted file mode 100644 index 0f630220e9cc..000000000000 --- a/internal/services/dns/parse/aaaa_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = AaaaRecordId{} - -func TestAaaaRecordIDFormatter(t *testing.T) { - actual := NewAaaaRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "eheh1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/eheh1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestAaaaRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AaaaRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing AAAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for AAAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/eheh1", - Expected: &AaaaRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - AAAAName: "eheh1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/AAAA/EHEH1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := AaaaRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.AAAAName != v.Expected.AAAAName { - t.Fatalf("Expected %q but got %q for AAAAName", v.Expected.AAAAName, actual.AAAAName) - } - } -} diff --git a/internal/services/dns/parse/caa_record.go b/internal/services/dns/parse/caa_record.go deleted file mode 100644 index 156be086f698..000000000000 --- a/internal/services/dns/parse/caa_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CaaRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - CAAName string -} - -func NewCaaRecordID(subscriptionId, resourceGroup, dnszoneName, cAAName string) CaaRecordId { - return CaaRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - CAAName: cAAName, - } -} - -func (id CaaRecordId) String() string { - segments := []string{ - fmt.Sprintf("C A A Name %q", id.CAAName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Caa Record", segmentsStr) -} - -func (id CaaRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/CAA/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.CAAName) -} - -// CaaRecordID parses a CaaRecord ID into an CaaRecordId struct -func CaaRecordID(input string) (*CaaRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := CaaRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.CAAName, err = id.PopSegment("CAA"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/caa_record_test.go b/internal/services/dns/parse/caa_record_test.go deleted file mode 100644 index 80da422f8ec9..000000000000 --- a/internal/services/dns/parse/caa_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CaaRecordId{} - -func TestCaaRecordIDFormatter(t *testing.T) { - actual := NewCaaRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "caa1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/caa1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCaaRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CaaRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing CAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for CAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/caa1", - Expected: &CaaRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - CAAName: "caa1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/CAA/CAA1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CaaRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.CAAName != v.Expected.CAAName { - t.Fatalf("Expected %q but got %q for CAAName", v.Expected.CAAName, actual.CAAName) - } - } -} diff --git a/internal/services/dns/parse/cname_record.go b/internal/services/dns/parse/cname_record.go deleted file mode 100644 index 1cdf96189e6c..000000000000 --- a/internal/services/dns/parse/cname_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CnameRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - CNAMEName string -} - -func NewCnameRecordID(subscriptionId, resourceGroup, dnszoneName, cNAMEName string) CnameRecordId { - return CnameRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - CNAMEName: cNAMEName, - } -} - -func (id CnameRecordId) String() string { - segments := []string{ - fmt.Sprintf("C N A M E Name %q", id.CNAMEName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Cname Record", segmentsStr) -} - -func (id CnameRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/CNAME/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.CNAMEName) -} - -// CnameRecordID parses a CnameRecord ID into an CnameRecordId struct -func CnameRecordID(input string) (*CnameRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := CnameRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.CNAMEName, err = id.PopSegment("CNAME"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/cname_record_test.go b/internal/services/dns/parse/cname_record_test.go deleted file mode 100644 index ce81768189b3..000000000000 --- a/internal/services/dns/parse/cname_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CnameRecordId{} - -func TestCnameRecordIDFormatter(t *testing.T) { - actual := NewCnameRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "name1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/name1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCnameRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CnameRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing CNAMEName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for CNAMEName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/name1", - Expected: &CnameRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - CNAMEName: "name1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/CNAME/NAME1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CnameRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.CNAMEName != v.Expected.CNAMEName { - t.Fatalf("Expected %q but got %q for CNAMEName", v.Expected.CNAMEName, actual.CNAMEName) - } - } -} diff --git a/internal/services/dns/parse/dns_zone.go b/internal/services/dns/parse/dns_zone.go deleted file mode 100644 index 8f4564b18e99..000000000000 --- a/internal/services/dns/parse/dns_zone.go +++ /dev/null @@ -1,69 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type DnsZoneId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewDnsZoneID(subscriptionId, resourceGroup, name string) DnsZoneId { - return DnsZoneId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id DnsZoneId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Dns Zone", segmentsStr) -} - -func (id DnsZoneId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// DnsZoneID parses a DnsZone ID into an DnsZoneId struct -func DnsZoneID(input string) (*DnsZoneId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := DnsZoneId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/dns_zone_test.go b/internal/services/dns/parse/dns_zone_test.go deleted file mode 100644 index a60db762ba38..000000000000 --- a/internal/services/dns/parse/dns_zone_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = DnsZoneId{} - -func TestDnsZoneIDFormatter(t *testing.T) { - actual := NewDnsZoneID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestDnsZoneID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DnsZoneId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1", - Expected: &DnsZoneId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "zone1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := DnsZoneID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - 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/internal/services/dns/parse/mx_record.go b/internal/services/dns/parse/mx_record.go deleted file mode 100644 index b1c6aa955c50..000000000000 --- a/internal/services/dns/parse/mx_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type MxRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - MXName string -} - -func NewMxRecordID(subscriptionId, resourceGroup, dnszoneName, mXName string) MxRecordId { - return MxRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - MXName: mXName, - } -} - -func (id MxRecordId) String() string { - segments := []string{ - fmt.Sprintf("M X Name %q", id.MXName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Mx Record", segmentsStr) -} - -func (id MxRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/MX/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.MXName) -} - -// MxRecordID parses a MxRecord ID into an MxRecordId struct -func MxRecordID(input string) (*MxRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := MxRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.MXName, err = id.PopSegment("MX"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/mx_record_test.go b/internal/services/dns/parse/mx_record_test.go deleted file mode 100644 index cf4fe1630841..000000000000 --- a/internal/services/dns/parse/mx_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = MxRecordId{} - -func TestMxRecordIDFormatter(t *testing.T) { - actual := NewMxRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "mx1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/mx1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestMxRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *MxRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing MXName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for MXName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/mx1", - Expected: &MxRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - MXName: "mx1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/MX/MX1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := MxRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.MXName != v.Expected.MXName { - t.Fatalf("Expected %q but got %q for MXName", v.Expected.MXName, actual.MXName) - } - } -} diff --git a/internal/services/dns/parse/ns_record.go b/internal/services/dns/parse/ns_record.go deleted file mode 100644 index dd8399f70f59..000000000000 --- a/internal/services/dns/parse/ns_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NsRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - NSName string -} - -func NewNsRecordID(subscriptionId, resourceGroup, dnszoneName, nSName string) NsRecordId { - return NsRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - NSName: nSName, - } -} - -func (id NsRecordId) String() string { - segments := []string{ - fmt.Sprintf("N S Name %q", id.NSName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Ns Record", segmentsStr) -} - -func (id NsRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/NS/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.NSName) -} - -// NsRecordID parses a NsRecord ID into an NsRecordId struct -func NsRecordID(input string) (*NsRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := NsRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.NSName, err = id.PopSegment("NS"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/ns_record_test.go b/internal/services/dns/parse/ns_record_test.go deleted file mode 100644 index 694bf6359516..000000000000 --- a/internal/services/dns/parse/ns_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NsRecordId{} - -func TestNsRecordIDFormatter(t *testing.T) { - actual := NewNsRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "ns1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/ns1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNsRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NsRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing NSName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for NSName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/ns1", - Expected: &NsRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - NSName: "ns1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/NS/NS1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NsRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.NSName != v.Expected.NSName { - t.Fatalf("Expected %q but got %q for NSName", v.Expected.NSName, actual.NSName) - } - } -} diff --git a/internal/services/dns/parse/ptr_record.go b/internal/services/dns/parse/ptr_record.go deleted file mode 100644 index e0b4965f0bd3..000000000000 --- a/internal/services/dns/parse/ptr_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PtrRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - PTRName string -} - -func NewPtrRecordID(subscriptionId, resourceGroup, dnszoneName, pTRName string) PtrRecordId { - return PtrRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - PTRName: pTRName, - } -} - -func (id PtrRecordId) String() string { - segments := []string{ - fmt.Sprintf("P T R Name %q", id.PTRName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Ptr Record", segmentsStr) -} - -func (id PtrRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/PTR/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.PTRName) -} - -// PtrRecordID parses a PtrRecord ID into an PtrRecordId struct -func PtrRecordID(input string) (*PtrRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := PtrRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.PTRName, err = id.PopSegment("PTR"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/ptr_record_test.go b/internal/services/dns/parse/ptr_record_test.go deleted file mode 100644 index f5f0a3fd7ec3..000000000000 --- a/internal/services/dns/parse/ptr_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PtrRecordId{} - -func TestPtrRecordIDFormatter(t *testing.T) { - actual := NewPtrRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "ptr1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/ptr1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPtrRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PtrRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing PTRName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for PTRName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/ptr1", - Expected: &PtrRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - PTRName: "ptr1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/PTR/PTR1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PtrRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.PTRName != v.Expected.PTRName { - t.Fatalf("Expected %q but got %q for PTRName", v.Expected.PTRName, actual.PTRName) - } - } -} diff --git a/internal/services/dns/parse/srv_record.go b/internal/services/dns/parse/srv_record.go deleted file mode 100644 index 2006f14bbd63..000000000000 --- a/internal/services/dns/parse/srv_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SrvRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - SRVName string -} - -func NewSrvRecordID(subscriptionId, resourceGroup, dnszoneName, sRVName string) SrvRecordId { - return SrvRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - SRVName: sRVName, - } -} - -func (id SrvRecordId) String() string { - segments := []string{ - fmt.Sprintf("S R V Name %q", id.SRVName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Srv Record", segmentsStr) -} - -func (id SrvRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/SRV/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.SRVName) -} - -// SrvRecordID parses a SrvRecord ID into an SrvRecordId struct -func SrvRecordID(input string) (*SrvRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := SrvRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.SRVName, err = id.PopSegment("SRV"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/srv_record_test.go b/internal/services/dns/parse/srv_record_test.go deleted file mode 100644 index 14d3f25dab55..000000000000 --- a/internal/services/dns/parse/srv_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SrvRecordId{} - -func TestSrvRecordIDFormatter(t *testing.T) { - actual := NewSrvRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "srv1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/srv1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSrvRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SrvRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing SRVName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for SRVName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/srv1", - Expected: &SrvRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - SRVName: "srv1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/SRV/SRV1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SrvRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.SRVName != v.Expected.SRVName { - t.Fatalf("Expected %q but got %q for SRVName", v.Expected.SRVName, actual.SRVName) - } - } -} diff --git a/internal/services/dns/parse/txt_record.go b/internal/services/dns/parse/txt_record.go deleted file mode 100644 index 57b0bae23501..000000000000 --- a/internal/services/dns/parse/txt_record.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type TxtRecordId struct { - SubscriptionId string - ResourceGroup string - DnszoneName string - TXTName string -} - -func NewTxtRecordID(subscriptionId, resourceGroup, dnszoneName, tXTName string) TxtRecordId { - return TxtRecordId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DnszoneName: dnszoneName, - TXTName: tXTName, - } -} - -func (id TxtRecordId) String() string { - segments := []string{ - fmt.Sprintf("T X T Name %q", id.TXTName), - fmt.Sprintf("Dnszone Name %q", id.DnszoneName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Txt Record", segmentsStr) -} - -func (id TxtRecordId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnszones/%s/TXT/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DnszoneName, id.TXTName) -} - -// TxtRecordID parses a TxtRecord ID into an TxtRecordId struct -func TxtRecordID(input string) (*TxtRecordId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := TxtRecordId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.DnszoneName, err = id.PopSegment("dnszones"); err != nil { - return nil, err - } - if resourceId.TXTName, err = id.PopSegment("TXT"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/dns/parse/txt_record_test.go b/internal/services/dns/parse/txt_record_test.go deleted file mode 100644 index 37b0d53ec2bc..000000000000 --- a/internal/services/dns/parse/txt_record_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = TxtRecordId{} - -func TestTxtRecordIDFormatter(t *testing.T) { - actual := NewTxtRecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "zone1", "txt1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/txt1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestTxtRecordID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *TxtRecordId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Error: true, - }, - - { - // missing TXTName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Error: true, - }, - - { - // missing value for TXTName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/txt1", - Expected: &TxtRecordId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DnszoneName: "zone1", - TXTName: "txt1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/TXT/TXT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := TxtRecordID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DnszoneName != v.Expected.DnszoneName { - t.Fatalf("Expected %q but got %q for DnszoneName", v.Expected.DnszoneName, actual.DnszoneName) - } - if actual.TXTName != v.Expected.TXTName { - t.Fatalf("Expected %q but got %q for TXTName", v.Expected.TXTName, actual.TXTName) - } - } -} diff --git a/internal/services/dns/resourceids.go b/internal/services/dns/resourceids.go deleted file mode 100644 index 4ad419bec34f..000000000000 --- a/internal/services/dns/resourceids.go +++ /dev/null @@ -1,12 +0,0 @@ -package dns - -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=DnsZone -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ARecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/eh1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AaaaRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/eheh1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CaaRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/caa1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CnameRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/name1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=MxRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/mx1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NsRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/ns1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PtrRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/ptr1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SrvRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/srv1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=TxtRecord -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/txt1 diff --git a/internal/services/dns/validate/a_record_id.go b/internal/services/dns/validate/a_record_id.go deleted file mode 100644 index 6d70f11164a0..000000000000 --- a/internal/services/dns/validate/a_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func ARecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ARecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/a_record_id_test.go b/internal/services/dns/validate/a_record_id_test.go deleted file mode 100644 index f6ccc517f5d5..000000000000 --- a/internal/services/dns/validate/a_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestARecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing AName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for AName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/A/eh1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/A/EH1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ARecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/aaaa_record_id.go b/internal/services/dns/validate/aaaa_record_id.go deleted file mode 100644 index dd75910b3a70..000000000000 --- a/internal/services/dns/validate/aaaa_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func AaaaRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.AaaaRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/aaaa_record_id_test.go b/internal/services/dns/validate/aaaa_record_id_test.go deleted file mode 100644 index 89378cfceaf9..000000000000 --- a/internal/services/dns/validate/aaaa_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestAaaaRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing AAAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for AAAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/AAAA/eheh1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/AAAA/EHEH1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := AaaaRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/caa_record_id.go b/internal/services/dns/validate/caa_record_id.go deleted file mode 100644 index 4fd6b17485f7..000000000000 --- a/internal/services/dns/validate/caa_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func CaaRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CaaRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/caa_record_id_test.go b/internal/services/dns/validate/caa_record_id_test.go deleted file mode 100644 index aa05cd29ef88..000000000000 --- a/internal/services/dns/validate/caa_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCaaRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing CAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for CAAName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CAA/caa1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/CAA/CAA1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CaaRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/cname_record_id.go b/internal/services/dns/validate/cname_record_id.go deleted file mode 100644 index a0a20845f322..000000000000 --- a/internal/services/dns/validate/cname_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func CnameRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CnameRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/cname_record_id_test.go b/internal/services/dns/validate/cname_record_id_test.go deleted file mode 100644 index 23c4075e7ccf..000000000000 --- a/internal/services/dns/validate/cname_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCnameRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing CNAMEName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for CNAMEName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/CNAME/name1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/CNAME/NAME1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CnameRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/dns_zone_id.go b/internal/services/dns/validate/dns_zone_id.go deleted file mode 100644 index 32e9b7d30b17..000000000000 --- a/internal/services/dns/validate/dns_zone_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func DnsZoneID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.DnsZoneID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/dns_zone_id_test.go b/internal/services/dns/validate/dns_zone_id_test.go deleted file mode 100644 index e98912a40947..000000000000 --- a/internal/services/dns/validate/dns_zone_id_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestDnsZoneID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := DnsZoneID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/mx_record_id.go b/internal/services/dns/validate/mx_record_id.go deleted file mode 100644 index 5bea8660e56e..000000000000 --- a/internal/services/dns/validate/mx_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func MxRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.MxRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/mx_record_id_test.go b/internal/services/dns/validate/mx_record_id_test.go deleted file mode 100644 index ec999a7d517a..000000000000 --- a/internal/services/dns/validate/mx_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestMxRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing MXName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for MXName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/MX/mx1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/MX/MX1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := MxRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/ns_record_id.go b/internal/services/dns/validate/ns_record_id.go deleted file mode 100644 index 6b808841c897..000000000000 --- a/internal/services/dns/validate/ns_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func NsRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NsRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/ns_record_id_test.go b/internal/services/dns/validate/ns_record_id_test.go deleted file mode 100644 index c9710d386833..000000000000 --- a/internal/services/dns/validate/ns_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNsRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing NSName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for NSName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/NS/ns1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/NS/NS1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NsRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/ptr_record_id.go b/internal/services/dns/validate/ptr_record_id.go deleted file mode 100644 index 444679b22c17..000000000000 --- a/internal/services/dns/validate/ptr_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func PtrRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PtrRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/ptr_record_id_test.go b/internal/services/dns/validate/ptr_record_id_test.go deleted file mode 100644 index 7e526241c55c..000000000000 --- a/internal/services/dns/validate/ptr_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPtrRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing PTRName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for PTRName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/PTR/ptr1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/PTR/PTR1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PtrRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/srv_record_id.go b/internal/services/dns/validate/srv_record_id.go deleted file mode 100644 index 988b99abfc23..000000000000 --- a/internal/services/dns/validate/srv_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func SrvRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SrvRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/srv_record_id_test.go b/internal/services/dns/validate/srv_record_id_test.go deleted file mode 100644 index d48d19c45af8..000000000000 --- a/internal/services/dns/validate/srv_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSrvRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing SRVName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for SRVName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/SRV/srv1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/SRV/SRV1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SrvRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/dns/validate/txt_record_id.go b/internal/services/dns/validate/txt_record_id.go deleted file mode 100644 index d4d2b6abad51..000000000000 --- a/internal/services/dns/validate/txt_record_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/dns/parse" -) - -func TxtRecordID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.TxtRecordID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/dns/validate/txt_record_id_test.go b/internal/services/dns/validate/txt_record_id_test.go deleted file mode 100644 index eb23b2b72f55..000000000000 --- a/internal/services/dns/validate/txt_record_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestTxtRecordID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for DnszoneName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/", - Valid: false, - }, - - { - // missing TXTName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/", - Valid: false, - }, - - { - // missing value for TXTName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/dnszones/zone1/TXT/txt1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/DNSZONES/ZONE1/TXT/TXT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := TxtRecordID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/_meta.json deleted file mode 100644 index f3f56908137e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/dns/resource-manager/readme.md", - "tag": "package-2018-05", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2018-05 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/dns/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go deleted file mode 100644 index 2acecfc15c69..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/client.go +++ /dev/null @@ -1,41 +0,0 @@ -// Package dns implements the Azure ARM Dns service API version 2018-05-01. -// -// The DNS Management Client. -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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 Dns - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Dns. -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/dns/mgmt/2018-05-01/dns/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/enums.go deleted file mode 100644 index 90319affc9b9..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/enums.go +++ /dev/null @@ -1,53 +0,0 @@ -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// RecordType enumerates the values for record type. -type RecordType string - -const ( - // A ... - A RecordType = "A" - // AAAA ... - AAAA RecordType = "AAAA" - // CAA ... - CAA RecordType = "CAA" - // CNAME ... - CNAME RecordType = "CNAME" - // MX ... - MX RecordType = "MX" - // NS ... - NS RecordType = "NS" - // PTR ... - PTR RecordType = "PTR" - // SOA ... - SOA RecordType = "SOA" - // SRV ... - SRV RecordType = "SRV" - // TXT ... - TXT RecordType = "TXT" -) - -// PossibleRecordTypeValues returns an array of possible values for the RecordType const type. -func PossibleRecordTypeValues() []RecordType { - return []RecordType{A, AAAA, CAA, CNAME, MX, NS, PTR, SOA, SRV, TXT} -} - -// ZoneType enumerates the values for zone type. -type ZoneType string - -const ( - // Private ... - Private ZoneType = "Private" - // Public ... - Public ZoneType = "Public" -) - -// PossibleZoneTypeValues returns an array of possible values for the ZoneType const type. -func PossibleZoneTypeValues() []ZoneType { - return []ZoneType{Private, Public} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go deleted file mode 100644 index 50355232b1b5..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/models.go +++ /dev/null @@ -1,961 +0,0 @@ -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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/dns/mgmt/2018-05-01/dns" - -// AaaaRecord an AAAA record. -type AaaaRecord struct { - // Ipv6Address - The IPv6 address of this AAAA record. - Ipv6Address *string `json:"ipv6Address,omitempty"` -} - -// ARecord an A record. -type ARecord struct { - // Ipv4Address - The IPv4 address of this A record. - Ipv4Address *string `json:"ipv4Address,omitempty"` -} - -// CaaRecord a CAA record. -type CaaRecord struct { - // Flags - The flags for this CAA record as an integer between 0 and 255. - Flags *int32 `json:"flags,omitempty"` - // Tag - The tag for this CAA record. - Tag *string `json:"tag,omitempty"` - // Value - The value for this CAA record. - Value *string `json:"value,omitempty"` -} - -// CloudError an error response from the service. -type CloudError struct { - // Error - Cloud error body. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody an error response from the service. -type CloudErrorBody struct { - // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - // Message - A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` - // Target - The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` - // Details - A list of additional details about the error. - Details *[]CloudErrorBody `json:"details,omitempty"` -} - -// CnameRecord a CNAME record. -type CnameRecord struct { - // Cname - The canonical name for this CNAME record. - Cname *string `json:"cname,omitempty"` -} - -// MxRecord an MX record. -type MxRecord struct { - // Preference - The preference value for this MX record. - Preference *int32 `json:"preference,omitempty"` - // Exchange - The domain name of the mail host for this MX record. - Exchange *string `json:"exchange,omitempty"` -} - -// NsRecord an NS record. -type NsRecord struct { - // Nsdname - The name server name for this NS record. - Nsdname *string `json:"nsdname,omitempty"` -} - -// PtrRecord a PTR record. -type PtrRecord struct { - // Ptrdname - The PTR target domain name for this PTR record. - Ptrdname *string `json:"ptrdname,omitempty"` -} - -// RecordSet describes a DNS record set (a collection of DNS records with the same name and type). -type RecordSet struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The ID of the record set. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the record set. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the record set. - Type *string `json:"type,omitempty"` - // Etag - The etag of the record set. - Etag *string `json:"etag,omitempty"` - // RecordSetProperties - The properties of the record set. - *RecordSetProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RecordSet. -func (rs RecordSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rs.Etag != nil { - objectMap["etag"] = rs.Etag - } - if rs.RecordSetProperties != nil { - objectMap["properties"] = rs.RecordSetProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RecordSet struct. -func (rs *RecordSet) 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 "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rs.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rs.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rs.Type = &typeVar - } - case "etag": - if v != nil { - var etag string - err = json.Unmarshal(*v, &etag) - if err != nil { - return err - } - rs.Etag = &etag - } - case "properties": - if v != nil { - var recordSetProperties RecordSetProperties - err = json.Unmarshal(*v, &recordSetProperties) - if err != nil { - return err - } - rs.RecordSetProperties = &recordSetProperties - } - } - } - - return nil -} - -// RecordSetListResult the response to a record set List operation. -type RecordSetListResult struct { - autorest.Response `json:"-"` - // Value - Information about the record sets in the response. - Value *[]RecordSet `json:"value,omitempty"` - // NextLink - READ-ONLY; The continuation token for the next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for RecordSetListResult. -func (rslr RecordSetListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rslr.Value != nil { - objectMap["value"] = rslr.Value - } - return json.Marshal(objectMap) -} - -// RecordSetListResultIterator provides access to a complete listing of RecordSet values. -type RecordSetListResultIterator struct { - i int - page RecordSetListResultPage -} - -// 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 *RecordSetListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetListResultIterator.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 *RecordSetListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RecordSetListResultIterator) 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 RecordSetListResultIterator) Response() RecordSetListResult { - 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 RecordSetListResultIterator) Value() RecordSet { - if !iter.page.NotDone() { - return RecordSet{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RecordSetListResultIterator type. -func NewRecordSetListResultIterator(page RecordSetListResultPage) RecordSetListResultIterator { - return RecordSetListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rslr RecordSetListResult) IsEmpty() bool { - return rslr.Value == nil || len(*rslr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (rslr RecordSetListResult) hasNextLink() bool { - return rslr.NextLink != nil && len(*rslr.NextLink) != 0 -} - -// recordSetListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rslr RecordSetListResult) recordSetListResultPreparer(ctx context.Context) (*http.Request, error) { - if !rslr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rslr.NextLink))) -} - -// RecordSetListResultPage contains a page of RecordSet values. -type RecordSetListResultPage struct { - fn func(context.Context, RecordSetListResult) (RecordSetListResult, error) - rslr RecordSetListResult -} - -// 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 *RecordSetListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetListResultPage.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.rslr) - if err != nil { - return err - } - page.rslr = 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 *RecordSetListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RecordSetListResultPage) NotDone() bool { - return !page.rslr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RecordSetListResultPage) Response() RecordSetListResult { - return page.rslr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RecordSetListResultPage) Values() []RecordSet { - if page.rslr.IsEmpty() { - return nil - } - return *page.rslr.Value -} - -// Creates a new instance of the RecordSetListResultPage type. -func NewRecordSetListResultPage(cur RecordSetListResult, getNextPage func(context.Context, RecordSetListResult) (RecordSetListResult, error)) RecordSetListResultPage { - return RecordSetListResultPage{ - fn: getNextPage, - rslr: cur, - } -} - -// RecordSetProperties represents the properties of the records in the record set. -type RecordSetProperties struct { - // Metadata - The metadata attached to the record set. - Metadata map[string]*string `json:"metadata"` - // TTL - The TTL (time-to-live) of the records in the record set. - TTL *int64 `json:"TTL,omitempty"` - // Fqdn - READ-ONLY; Fully qualified domain name of the record set. - Fqdn *string `json:"fqdn,omitempty"` - // ProvisioningState - READ-ONLY; provisioning State of the record set. - ProvisioningState *string `json:"provisioningState,omitempty"` - // TargetResource - A reference to an azure resource from where the dns resource value is taken. - TargetResource *SubResource `json:"targetResource,omitempty"` - // ARecords - The list of A records in the record set. - ARecords *[]ARecord `json:"ARecords,omitempty"` - // AaaaRecords - The list of AAAA records in the record set. - AaaaRecords *[]AaaaRecord `json:"AAAARecords,omitempty"` - // MxRecords - The list of MX records in the record set. - MxRecords *[]MxRecord `json:"MXRecords,omitempty"` - // NsRecords - The list of NS records in the record set. - NsRecords *[]NsRecord `json:"NSRecords,omitempty"` - // PtrRecords - The list of PTR records in the record set. - PtrRecords *[]PtrRecord `json:"PTRRecords,omitempty"` - // SrvRecords - The list of SRV records in the record set. - SrvRecords *[]SrvRecord `json:"SRVRecords,omitempty"` - // TxtRecords - The list of TXT records in the record set. - TxtRecords *[]TxtRecord `json:"TXTRecords,omitempty"` - // CnameRecord - The CNAME record in the record set. - CnameRecord *CnameRecord `json:"CNAMERecord,omitempty"` - // SoaRecord - The SOA record in the record set. - SoaRecord *SoaRecord `json:"SOARecord,omitempty"` - // CaaRecords - The list of CAA records in the record set. - CaaRecords *[]CaaRecord `json:"caaRecords,omitempty"` -} - -// MarshalJSON is the custom marshaler for RecordSetProperties. -func (rsp RecordSetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rsp.Metadata != nil { - objectMap["metadata"] = rsp.Metadata - } - if rsp.TTL != nil { - objectMap["TTL"] = rsp.TTL - } - if rsp.TargetResource != nil { - objectMap["targetResource"] = rsp.TargetResource - } - if rsp.ARecords != nil { - objectMap["ARecords"] = rsp.ARecords - } - if rsp.AaaaRecords != nil { - objectMap["AAAARecords"] = rsp.AaaaRecords - } - if rsp.MxRecords != nil { - objectMap["MXRecords"] = rsp.MxRecords - } - if rsp.NsRecords != nil { - objectMap["NSRecords"] = rsp.NsRecords - } - if rsp.PtrRecords != nil { - objectMap["PTRRecords"] = rsp.PtrRecords - } - if rsp.SrvRecords != nil { - objectMap["SRVRecords"] = rsp.SrvRecords - } - if rsp.TxtRecords != nil { - objectMap["TXTRecords"] = rsp.TxtRecords - } - if rsp.CnameRecord != nil { - objectMap["CNAMERecord"] = rsp.CnameRecord - } - if rsp.SoaRecord != nil { - objectMap["SOARecord"] = rsp.SoaRecord - } - if rsp.CaaRecords != nil { - objectMap["caaRecords"] = rsp.CaaRecords - } - return json.Marshal(objectMap) -} - -// RecordSetUpdateParameters parameters supplied to update a record set. -type RecordSetUpdateParameters struct { - // RecordSet - Specifies information about the record set being updated. - RecordSet *RecordSet `json:"RecordSet,omitempty"` -} - -// Resource common properties of an Azure Resource Manager resource -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"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// ResourceReference represents a single Azure resource and its referencing DNS records. -type ResourceReference struct { - // DNSResources - A list of dns Records - DNSResources *[]SubResource `json:"dnsResources,omitempty"` - // TargetResource - A reference to an azure resource from where the dns resource value is taken. - TargetResource *SubResource `json:"targetResource,omitempty"` -} - -// ResourceReferenceRequest represents the properties of the Dns Resource Reference Request. -type ResourceReferenceRequest struct { - // ResourceReferenceRequestProperties - The properties of the Resource Reference Request. - *ResourceReferenceRequestProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ResourceReferenceRequest. -func (rrr ResourceReferenceRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rrr.ResourceReferenceRequestProperties != nil { - objectMap["properties"] = rrr.ResourceReferenceRequestProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ResourceReferenceRequest struct. -func (rrr *ResourceReferenceRequest) 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 resourceReferenceRequestProperties ResourceReferenceRequestProperties - err = json.Unmarshal(*v, &resourceReferenceRequestProperties) - if err != nil { - return err - } - rrr.ResourceReferenceRequestProperties = &resourceReferenceRequestProperties - } - } - } - - return nil -} - -// ResourceReferenceRequestProperties represents the properties of the Dns Resource Reference Request. -type ResourceReferenceRequestProperties struct { - // TargetResources - A list of references to azure resources for which referencing dns records need to be queried. - TargetResources *[]SubResource `json:"targetResources,omitempty"` -} - -// ResourceReferenceResult represents the properties of the Dns Resource Reference Result. -type ResourceReferenceResult struct { - autorest.Response `json:"-"` - // ResourceReferenceResultProperties - The result of dns resource reference request. Returns a list of dns resource references for each of the azure resource in the request. - *ResourceReferenceResultProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ResourceReferenceResult. -func (rrr ResourceReferenceResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rrr.ResourceReferenceResultProperties != nil { - objectMap["properties"] = rrr.ResourceReferenceResultProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ResourceReferenceResult struct. -func (rrr *ResourceReferenceResult) 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 resourceReferenceResultProperties ResourceReferenceResultProperties - err = json.Unmarshal(*v, &resourceReferenceResultProperties) - if err != nil { - return err - } - rrr.ResourceReferenceResultProperties = &resourceReferenceResultProperties - } - } - } - - return nil -} - -// ResourceReferenceResultProperties the result of dns resource reference request. Returns a list of dns -// resource references for each of the azure resource in the request. -type ResourceReferenceResultProperties struct { - // DNSResourceReferences - The result of dns resource reference request. A list of dns resource references for each of the azure resource in the request - DNSResourceReferences *[]ResourceReference `json:"dnsResourceReferences,omitempty"` -} - -// SoaRecord an SOA record. -type SoaRecord struct { - // Host - The domain name of the authoritative name server for this SOA record. - Host *string `json:"host,omitempty"` - // Email - The email contact for this SOA record. - Email *string `json:"email,omitempty"` - // SerialNumber - The serial number for this SOA record. - SerialNumber *int64 `json:"serialNumber,omitempty"` - // RefreshTime - The refresh value for this SOA record. - RefreshTime *int64 `json:"refreshTime,omitempty"` - // RetryTime - The retry time for this SOA record. - RetryTime *int64 `json:"retryTime,omitempty"` - // ExpireTime - The expire time for this SOA record. - ExpireTime *int64 `json:"expireTime,omitempty"` - // MinimumTTL - The minimum value for this SOA record. By convention this is used to determine the negative caching duration. - MinimumTTL *int64 `json:"minimumTTL,omitempty"` -} - -// SrvRecord an SRV record. -type SrvRecord struct { - // Priority - The priority value for this SRV record. - Priority *int32 `json:"priority,omitempty"` - // Weight - The weight value for this SRV record. - Weight *int32 `json:"weight,omitempty"` - // Port - The port value for this SRV record. - Port *int32 `json:"port,omitempty"` - // Target - The target domain name for this SRV record. - Target *string `json:"target,omitempty"` -} - -// SubResource a reference to a another resource -type SubResource struct { - // ID - Resource Id. - ID *string `json:"id,omitempty"` -} - -// TxtRecord a TXT record. -type TxtRecord struct { - // Value - The text value of this TXT record. - Value *[]string `json:"value,omitempty"` -} - -// Zone describes a DNS zone. -type Zone struct { - autorest.Response `json:"-"` - // Etag - The etag of the zone. - Etag *string `json:"etag,omitempty"` - // ZoneProperties - The properties of the zone. - *ZoneProperties `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"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Zone. -func (z Zone) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if z.Etag != nil { - objectMap["etag"] = z.Etag - } - if z.ZoneProperties != nil { - objectMap["properties"] = z.ZoneProperties - } - if z.Location != nil { - objectMap["location"] = z.Location - } - if z.Tags != nil { - objectMap["tags"] = z.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Zone struct. -func (z *Zone) 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 "etag": - if v != nil { - var etag string - err = json.Unmarshal(*v, &etag) - if err != nil { - return err - } - z.Etag = &etag - } - case "properties": - if v != nil { - var zoneProperties ZoneProperties - err = json.Unmarshal(*v, &zoneProperties) - if err != nil { - return err - } - z.ZoneProperties = &zoneProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - z.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - z.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - z.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - z.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - z.Tags = tags - } - } - } - - return nil -} - -// ZoneListResult the response to a Zone List or ListAll operation. -type ZoneListResult struct { - autorest.Response `json:"-"` - // Value - Information about the DNS zones. - Value *[]Zone `json:"value,omitempty"` - // NextLink - READ-ONLY; The continuation token for the next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ZoneListResult. -func (zlr ZoneListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if zlr.Value != nil { - objectMap["value"] = zlr.Value - } - return json.Marshal(objectMap) -} - -// ZoneListResultIterator provides access to a complete listing of Zone values. -type ZoneListResultIterator struct { - i int - page ZoneListResultPage -} - -// 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 *ZoneListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZoneListResultIterator.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 *ZoneListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ZoneListResultIterator) 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 ZoneListResultIterator) Response() ZoneListResult { - 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 ZoneListResultIterator) Value() Zone { - if !iter.page.NotDone() { - return Zone{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ZoneListResultIterator type. -func NewZoneListResultIterator(page ZoneListResultPage) ZoneListResultIterator { - return ZoneListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (zlr ZoneListResult) IsEmpty() bool { - return zlr.Value == nil || len(*zlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (zlr ZoneListResult) hasNextLink() bool { - return zlr.NextLink != nil && len(*zlr.NextLink) != 0 -} - -// zoneListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (zlr ZoneListResult) zoneListResultPreparer(ctx context.Context) (*http.Request, error) { - if !zlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(zlr.NextLink))) -} - -// ZoneListResultPage contains a page of Zone values. -type ZoneListResultPage struct { - fn func(context.Context, ZoneListResult) (ZoneListResult, error) - zlr ZoneListResult -} - -// 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 *ZoneListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZoneListResultPage.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.zlr) - if err != nil { - return err - } - page.zlr = 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 *ZoneListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ZoneListResultPage) NotDone() bool { - return !page.zlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ZoneListResultPage) Response() ZoneListResult { - return page.zlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ZoneListResultPage) Values() []Zone { - if page.zlr.IsEmpty() { - return nil - } - return *page.zlr.Value -} - -// Creates a new instance of the ZoneListResultPage type. -func NewZoneListResultPage(cur ZoneListResult, getNextPage func(context.Context, ZoneListResult) (ZoneListResult, error)) ZoneListResultPage { - return ZoneListResultPage{ - fn: getNextPage, - zlr: cur, - } -} - -// ZoneProperties represents the properties of the zone. -type ZoneProperties struct { - // MaxNumberOfRecordSets - READ-ONLY; The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - MaxNumberOfRecordSets *int64 `json:"maxNumberOfRecordSets,omitempty"` - // MaxNumberOfRecordsPerRecordSet - READ-ONLY; The maximum number of records per record set that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - MaxNumberOfRecordsPerRecordSet *int64 `json:"maxNumberOfRecordsPerRecordSet,omitempty"` - // NumberOfRecordSets - READ-ONLY; The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - NumberOfRecordSets *int64 `json:"numberOfRecordSets,omitempty"` - // NameServers - READ-ONLY; The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - NameServers *[]string `json:"nameServers,omitempty"` - // ZoneType - The type of this DNS zone (Public or Private). Possible values include: 'Public', 'Private' - ZoneType ZoneType `json:"zoneType,omitempty"` - // RegistrationVirtualNetworks - A list of references to virtual networks that register hostnames in this DNS zone. This is a only when ZoneType is Private. - RegistrationVirtualNetworks *[]SubResource `json:"registrationVirtualNetworks,omitempty"` - // ResolutionVirtualNetworks - A list of references to virtual networks that resolve records in this DNS zone. This is a only when ZoneType is Private. - ResolutionVirtualNetworks *[]SubResource `json:"resolutionVirtualNetworks,omitempty"` -} - -// MarshalJSON is the custom marshaler for ZoneProperties. -func (zp ZoneProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if zp.ZoneType != "" { - objectMap["zoneType"] = zp.ZoneType - } - if zp.RegistrationVirtualNetworks != nil { - objectMap["registrationVirtualNetworks"] = zp.RegistrationVirtualNetworks - } - if zp.ResolutionVirtualNetworks != nil { - objectMap["resolutionVirtualNetworks"] = zp.ResolutionVirtualNetworks - } - return json.Marshal(objectMap) -} - -// ZonesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type ZonesDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ZonesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ZonesDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ZonesDeleteFuture.Result. -func (future *ZonesDeleteFuture) result(client ZonesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("dns.ZonesDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ZoneUpdate describes a request to update a DNS zone. -type ZoneUpdate struct { - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ZoneUpdate. -func (zu ZoneUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if zu.Tags != nil { - objectMap["tags"] = zu.Tags - } - return json.Marshal(objectMap) -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go deleted file mode 100644 index d3aa10e26d2a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/recordsets.go +++ /dev/null @@ -1,774 +0,0 @@ -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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" -) - -// RecordSetsClient is the the DNS Management Client. -type RecordSetsClient struct { - BaseClient -} - -// NewRecordSetsClient creates an instance of the RecordSetsClient client. -func NewRecordSetsClient(subscriptionID string) RecordSetsClient { - return NewRecordSetsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRecordSetsClientWithBaseURI creates an instance of the RecordSetsClient 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 NewRecordSetsClientWithBaseURI(baseURI string, subscriptionID string) RecordSetsClient { - return RecordSetsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates a record set within a DNS zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// relativeRecordSetName - the name of the record set, relative to the name of the zone. -// recordType - the type of DNS record in this record set. Record sets of type SOA can be updated but not -// created (they are created when the DNS zone is created). -// parameters - parameters supplied to the CreateOrUpdate operation. -// ifMatch - the etag of the record set. Omit this value to always overwrite the current record set. Specify -// the last-seen etag value to prevent accidentally overwriting any concurrent changes. -// ifNoneMatch - set to '*' to allow a new record set to be created, but to prevent updating an existing record -// set. Other values will be ignored. -func (client RecordSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string, ifNoneMatch string) (result RecordSet, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch, ifNoneMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RecordSetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string, ifNoneMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "recordType": autorest.Encode("path", recordType), - "relativeRecordSetName": relativeRecordSetName, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Name = nil - parameters.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - if len(ifNoneMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) - } - 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 RecordSetsClient) 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 RecordSetsClient) CreateOrUpdateResponder(resp *http.Response) (result RecordSet, 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 deletes a record set from a DNS zone. This operation cannot be undone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// relativeRecordSetName - the name of the record set, relative to the name of the zone. -// recordType - the type of DNS record in this record set. Record sets of type SOA cannot be deleted (they are -// deleted when the DNS zone is deleted). -// ifMatch - the etag of the record set. Omit this value to always delete the current record set. Specify the -// last-seen etag value to prevent accidentally deleting any concurrent changes. -func (client RecordSetsClient) Delete(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, ifMatch string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, ifMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RecordSetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, ifMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "recordType": autorest.Encode("path", recordType), - "relativeRecordSetName": relativeRecordSetName, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - 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 RecordSetsClient) 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 RecordSetsClient) 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 gets a record set. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// relativeRecordSetName - the name of the record set, relative to the name of the zone. -// recordType - the type of DNS record in this record set. -func (client RecordSetsClient) Get(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType) (result RecordSet, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client RecordSetsClient) GetPreparer(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "recordType": autorest.Encode("path", recordType), - "relativeRecordSetName": relativeRecordSetName, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", 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 RecordSetsClient) 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 RecordSetsClient) GetResponder(resp *http.Response) (result RecordSet, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListAllByDNSZone lists all record sets in a DNS zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. -// recordSetNameSuffix - the suffix label of the record set name that has to be used to filter the record set -// enumerations. If this parameter is specified, Enumeration will return only records that end with -// . -func (client RecordSetsClient) ListAllByDNSZone(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordSetNameSuffix string) (result RecordSetListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListAllByDNSZone") - defer func() { - sc := -1 - if result.rslr.Response.Response != nil { - sc = result.rslr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listAllByDNSZoneNextResults - req, err := client.ListAllByDNSZonePreparer(ctx, resourceGroupName, zoneName, top, recordSetNameSuffix) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAllByDNSZone", nil, "Failure preparing request") - return - } - - resp, err := client.ListAllByDNSZoneSender(req) - if err != nil { - result.rslr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAllByDNSZone", resp, "Failure sending request") - return - } - - result.rslr, err = client.ListAllByDNSZoneResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAllByDNSZone", resp, "Failure responding to request") - return - } - if result.rslr.hasNextLink() && result.rslr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAllByDNSZonePreparer prepares the ListAllByDNSZone request. -func (client RecordSetsClient) ListAllByDNSZonePreparer(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordSetNameSuffix string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(recordSetNameSuffix) > 0 { - queryParameters["$recordsetnamesuffix"] = autorest.Encode("query", recordSetNameSuffix) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAllByDNSZoneSender sends the ListAllByDNSZone request. The method will close the -// http.Response Body if it receives an error. -func (client RecordSetsClient) ListAllByDNSZoneSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAllByDNSZoneResponder handles the response to the ListAllByDNSZone request. The method always -// closes the http.Response Body. -func (client RecordSetsClient) ListAllByDNSZoneResponder(resp *http.Response) (result RecordSetListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAllByDNSZoneNextResults retrieves the next set of results, if any. -func (client RecordSetsClient) listAllByDNSZoneNextResults(ctx context.Context, lastResults RecordSetListResult) (result RecordSetListResult, err error) { - req, err := lastResults.recordSetListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllByDNSZoneNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAllByDNSZoneSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllByDNSZoneNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAllByDNSZoneResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllByDNSZoneNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAllByDNSZoneComplete enumerates all values, automatically crossing page boundaries as required. -func (client RecordSetsClient) ListAllByDNSZoneComplete(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordSetNameSuffix string) (result RecordSetListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListAllByDNSZone") - 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.ListAllByDNSZone(ctx, resourceGroupName, zoneName, top, recordSetNameSuffix) - return -} - -// ListByDNSZone lists all record sets in a DNS zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. -// recordsetnamesuffix - the suffix label of the record set name that has to be used to filter the record set -// enumerations. If this parameter is specified, Enumeration will return only records that end with -// . -func (client RecordSetsClient) ListByDNSZone(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordsetnamesuffix string) (result RecordSetListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListByDNSZone") - defer func() { - sc := -1 - if result.rslr.Response.Response != nil { - sc = result.rslr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByDNSZoneNextResults - req, err := client.ListByDNSZonePreparer(ctx, resourceGroupName, zoneName, top, recordsetnamesuffix) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", nil, "Failure preparing request") - return - } - - resp, err := client.ListByDNSZoneSender(req) - if err != nil { - result.rslr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", resp, "Failure sending request") - return - } - - result.rslr, err = client.ListByDNSZoneResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", resp, "Failure responding to request") - return - } - if result.rslr.hasNextLink() && result.rslr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByDNSZonePreparer prepares the ListByDNSZone request. -func (client RecordSetsClient) ListByDNSZonePreparer(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordsetnamesuffix string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(recordsetnamesuffix) > 0 { - queryParameters["$recordsetnamesuffix"] = autorest.Encode("query", recordsetnamesuffix) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByDNSZoneSender sends the ListByDNSZone request. The method will close the -// http.Response Body if it receives an error. -func (client RecordSetsClient) ListByDNSZoneSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByDNSZoneResponder handles the response to the ListByDNSZone request. The method always -// closes the http.Response Body. -func (client RecordSetsClient) ListByDNSZoneResponder(resp *http.Response) (result RecordSetListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByDNSZoneNextResults retrieves the next set of results, if any. -func (client RecordSetsClient) listByDNSZoneNextResults(ctx context.Context, lastResults RecordSetListResult) (result RecordSetListResult, err error) { - req, err := lastResults.recordSetListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByDNSZoneNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByDNSZoneSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByDNSZoneNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByDNSZoneResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByDNSZoneNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByDNSZoneComplete enumerates all values, automatically crossing page boundaries as required. -func (client RecordSetsClient) ListByDNSZoneComplete(ctx context.Context, resourceGroupName string, zoneName string, top *int32, recordsetnamesuffix string) (result RecordSetListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListByDNSZone") - 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.ListByDNSZone(ctx, resourceGroupName, zoneName, top, recordsetnamesuffix) - return -} - -// ListByType lists the record sets of a specified type in a DNS zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// recordType - the type of record sets to enumerate. -// top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. -// recordsetnamesuffix - the suffix label of the record set name that has to be used to filter the record set -// enumerations. If this parameter is specified, Enumeration will return only records that end with -// . -func (client RecordSetsClient) ListByType(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top *int32, recordsetnamesuffix string) (result RecordSetListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListByType") - defer func() { - sc := -1 - if result.rslr.Response.Response != nil { - sc = result.rslr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByTypeNextResults - req, err := client.ListByTypePreparer(ctx, resourceGroupName, zoneName, recordType, top, recordsetnamesuffix) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", nil, "Failure preparing request") - return - } - - resp, err := client.ListByTypeSender(req) - if err != nil { - result.rslr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", resp, "Failure sending request") - return - } - - result.rslr, err = client.ListByTypeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", resp, "Failure responding to request") - return - } - if result.rslr.hasNextLink() && result.rslr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByTypePreparer prepares the ListByType request. -func (client RecordSetsClient) ListByTypePreparer(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top *int32, recordsetnamesuffix string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "recordType": autorest.Encode("path", recordType), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(recordsetnamesuffix) > 0 { - queryParameters["$recordsetnamesuffix"] = autorest.Encode("query", recordsetnamesuffix) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByTypeSender sends the ListByType request. The method will close the -// http.Response Body if it receives an error. -func (client RecordSetsClient) ListByTypeSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByTypeResponder handles the response to the ListByType request. The method always -// closes the http.Response Body. -func (client RecordSetsClient) ListByTypeResponder(resp *http.Response) (result RecordSetListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByTypeNextResults retrieves the next set of results, if any. -func (client RecordSetsClient) listByTypeNextResults(ctx context.Context, lastResults RecordSetListResult) (result RecordSetListResult, err error) { - req, err := lastResults.recordSetListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByTypeNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByTypeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByTypeNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByTypeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listByTypeNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByTypeComplete enumerates all values, automatically crossing page boundaries as required. -func (client RecordSetsClient) ListByTypeComplete(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top *int32, recordsetnamesuffix string) (result RecordSetListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListByType") - 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.ListByType(ctx, resourceGroupName, zoneName, recordType, top, recordsetnamesuffix) - return -} - -// Update updates a record set within a DNS zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// relativeRecordSetName - the name of the record set, relative to the name of the zone. -// recordType - the type of DNS record in this record set. -// parameters - parameters supplied to the Update operation. -// ifMatch - the etag of the record set. Omit this value to always overwrite the current record set. Specify -// the last-seen etag value to prevent accidentally overwriting concurrent changes. -func (client RecordSetsClient) Update(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string) (result RecordSet, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.Update") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UpdatePreparer(ctx, resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", resp, "Failure responding to request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client RecordSetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "recordType": autorest.Encode("path", recordType), - "relativeRecordSetName": relativeRecordSetName, - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Name = nil - parameters.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - 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 RecordSetsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client RecordSetsClient) UpdateResponder(resp *http.Response) (result RecordSet, 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/dns/mgmt/2018-05-01/dns/resourcereference.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go deleted file mode 100644 index 875735853f35..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/resourcereference.go +++ /dev/null @@ -1,107 +0,0 @@ -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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" -) - -// ResourceReferenceClient is the the DNS Management Client. -type ResourceReferenceClient struct { - BaseClient -} - -// NewResourceReferenceClient creates an instance of the ResourceReferenceClient client. -func NewResourceReferenceClient(subscriptionID string) ResourceReferenceClient { - return NewResourceReferenceClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewResourceReferenceClientWithBaseURI creates an instance of the ResourceReferenceClient 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 NewResourceReferenceClientWithBaseURI(baseURI string, subscriptionID string) ResourceReferenceClient { - return ResourceReferenceClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// GetByTargetResources returns the DNS records specified by the referencing targetResourceIds. -// Parameters: -// parameters - properties for dns resource reference request. -func (client ResourceReferenceClient) GetByTargetResources(ctx context.Context, parameters ResourceReferenceRequest) (result ResourceReferenceResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ResourceReferenceClient.GetByTargetResources") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetByTargetResourcesPreparer(ctx, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", nil, "Failure preparing request") - return - } - - resp, err := client.GetByTargetResourcesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", resp, "Failure sending request") - return - } - - result, err = client.GetByTargetResourcesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ResourceReferenceClient", "GetByTargetResources", resp, "Failure responding to request") - return - } - - return -} - -// GetByTargetResourcesPreparer prepares the GetByTargetResources request. -func (client ResourceReferenceClient) GetByTargetResourcesPreparer(ctx context.Context, parameters ResourceReferenceRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByTargetResourcesSender sends the GetByTargetResources request. The method will close the -// http.Response Body if it receives an error. -func (client ResourceReferenceClient) GetByTargetResourcesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetByTargetResourcesResponder handles the response to the GetByTargetResources request. The method always -// closes the http.Response Body. -func (client ResourceReferenceClient) GetByTargetResourcesResponder(resp *http.Response) (result ResourceReferenceResult, 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/dns/mgmt/2018-05-01/dns/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/version.go deleted file mode 100644 index 940b45d22f90..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package dns - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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() + " dns/2018-05-01" -} - -// 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/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go b/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go deleted file mode 100644 index e004a7253541..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns/zones.go +++ /dev/null @@ -1,606 +0,0 @@ -package dns - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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" -) - -// ZonesClient is the the DNS Management Client. -type ZonesClient struct { - BaseClient -} - -// NewZonesClient creates an instance of the ZonesClient client. -func NewZonesClient(subscriptionID string) ZonesClient { - return NewZonesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewZonesClientWithBaseURI creates an instance of the ZonesClient 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 NewZonesClientWithBaseURI(baseURI string, subscriptionID string) ZonesClient { - return ZonesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates a DNS zone. Does not modify DNS records within the zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// parameters - parameters supplied to the CreateOrUpdate operation. -// ifMatch - the etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the -// last-seen etag value to prevent accidentally overwriting any concurrent changes. -// ifNoneMatch - set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. -// Other values will be ignored. -func (client ZonesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, parameters Zone, ifMatch string, ifNoneMatch string) (result Zone, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, zoneName, parameters, ifMatch, ifNoneMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ZonesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, zoneName string, parameters Zone, ifMatch string, ifNoneMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - 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.Network/dnsZones/{zoneName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - if len(ifNoneMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) - } - 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 ZonesClient) 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 ZonesClient) CreateOrUpdateResponder(resp *http.Response) (result Zone, 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 deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be -// undone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// ifMatch - the etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen -// etag value to prevent accidentally deleting any concurrent changes. -func (client ZonesClient) Delete(ctx context.Context, resourceGroupName string, zoneName string, ifMatch string) (result ZonesDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, resourceGroupName, zoneName, ifMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client ZonesClient) DeletePreparer(ctx context.Context, resourceGroupName string, zoneName string, ifMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - 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 ZonesClient) DeleteSender(req *http.Request) (future ZonesDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client ZonesClient) 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 gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -func (client ZonesClient) Get(ctx context.Context, resourceGroupName string, zoneName string) (result Zone, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceGroupName, zoneName) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client ZonesClient) GetPreparer(ctx context.Context, resourceGroupName string, zoneName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", 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 ZonesClient) 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 ZonesClient) GetResponder(resp *http.Response) (result Zone, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List lists the DNS zones in all resource groups in a subscription. -// Parameters: -// top - the maximum number of DNS zones to return. If not specified, returns up to 100 zones. -func (client ZonesClient) List(ctx context.Context, top *int32) (result ZoneListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.List") - defer func() { - sc := -1 - if result.zlr.Response.Response != nil { - sc = result.zlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, top) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.zlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "List", resp, "Failure sending request") - return - } - - result.zlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "List", resp, "Failure responding to request") - return - } - if result.zlr.hasNextLink() && result.zlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client ZonesClient) ListPreparer(ctx context.Context, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones", 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 ZonesClient) 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 ZonesClient) ListResponder(resp *http.Response) (result ZoneListResult, 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 ZonesClient) listNextResults(ctx context.Context, lastResults ZoneListResult) (result ZoneListResult, err error) { - req, err := lastResults.zoneListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "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, "dns.ZonesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ZonesClient) ListComplete(ctx context.Context, top *int32) (result ZoneListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.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, top) - return -} - -// ListByResourceGroup lists the DNS zones within a resource group. -// Parameters: -// resourceGroupName - the name of the resource group. -// top - the maximum number of record sets to return. If not specified, returns up to 100 record sets. -func (client ZonesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32) (result ZoneListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.zlr.Response.Response != nil { - sc = result.zlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, top) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.zlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result.zlr, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", resp, "Failure responding to request") - return - } - if result.zlr.hasNextLink() && result.zlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client ZonesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client ZonesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client ZonesClient) ListByResourceGroupResponder(resp *http.Response) (result ZoneListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client ZonesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ZoneListResult) (result ZoneListResult, err error) { - req, err := lastResults.zoneListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client ZonesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, top *int32) (result ZoneListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.ListByResourceGroup") - 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.ListByResourceGroup(ctx, resourceGroupName, top) - return -} - -// Update updates a DNS zone. Does not modify DNS records within the zone. -// Parameters: -// resourceGroupName - the name of the resource group. -// zoneName - the name of the DNS zone (without a terminating dot). -// parameters - parameters supplied to the Update operation. -// ifMatch - the etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the -// last-seen etag value to prevent accidentally overwriting any concurrent changes. -func (client ZonesClient) Update(ctx context.Context, resourceGroupName string, zoneName string, parameters ZoneUpdate, ifMatch string) (result Zone, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ZonesClient.Update") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UpdatePreparer(ctx, resourceGroupName, zoneName, parameters, ifMatch) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Update", resp, "Failure responding to request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client ZonesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, zoneName string, parameters ZoneUpdate, ifMatch string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "zoneName": autorest.Encode("path", zoneName), - } - - const APIVersion = "2018-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - if len(ifMatch) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("If-Match", autorest.String(ifMatch))) - } - 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 ZonesClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client ZonesClient) UpdateResponder(resp *http.Response) (result Zone, 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/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/client.go new file mode 100644 index 000000000000..047a134e3f5e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/client.go @@ -0,0 +1,32 @@ +package v2018_05_01 + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" + "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" +) + +type Client struct { + Dns *dns.DnsClient + RecordSets *recordsets.RecordSetsClient + Zones *zones.ZonesClient +} + +func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { + + dnsClient := dns.NewDnsClientWithBaseURI(endpoint) + configureAuthFunc(&dnsClient.Client) + + recordSetsClient := recordsets.NewRecordSetsClientWithBaseURI(endpoint) + configureAuthFunc(&recordSetsClient.Client) + + zonesClient := zones.NewZonesClientWithBaseURI(endpoint) + configureAuthFunc(&zonesClient.Client) + + return Client{ + Dns: &dnsClient, + RecordSets: &recordSetsClient, + Zones: &zonesClient, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/README.md new file mode 100644 index 000000000000..131c3b69a376 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns` Documentation + +The `dns` SDK allows for interaction with the Azure Resource Manager Service `dns` (API Version `2018-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns" +``` + + +### Client Initialization + +```go +client := dns.NewDnsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DnsClient.DnsResourceReferenceGetByTargetResources` + +```go +ctx := context.TODO() +id := dns.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := dns.DnsResourceReferenceRequest{ + // ... +} + + +read, err := client.DnsResourceReferenceGetByTargetResources(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/client.go new file mode 100644 index 000000000000..89e764095abc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/client.go @@ -0,0 +1,18 @@ +package dns + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsClient struct { + Client autorest.Client + baseUri string +} + +func NewDnsClientWithBaseURI(endpoint string) DnsClient { + return DnsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/method_dnsresourcereferencegetbytargetresources_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/method_dnsresourcereferencegetbytargetresources_autorest.go new file mode 100644 index 000000000000..677c81cc4b85 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/method_dnsresourcereferencegetbytargetresources_autorest.go @@ -0,0 +1,71 @@ +package dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReferenceGetByTargetResourcesOperationResponse struct { + HttpResponse *http.Response + Model *DnsResourceReferenceResult +} + +// DnsResourceReferenceGetByTargetResources ... +func (c DnsClient) DnsResourceReferenceGetByTargetResources(ctx context.Context, id commonids.SubscriptionId, input DnsResourceReferenceRequest) (result DnsResourceReferenceGetByTargetResourcesOperationResponse, err error) { + req, err := c.preparerForDnsResourceReferenceGetByTargetResources(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.DnsClient", "DnsResourceReferenceGetByTargetResources", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.DnsClient", "DnsResourceReferenceGetByTargetResources", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDnsResourceReferenceGetByTargetResources(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.DnsClient", "DnsResourceReferenceGetByTargetResources", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDnsResourceReferenceGetByTargetResources prepares the DnsResourceReferenceGetByTargetResources request. +func (c DnsClient) preparerForDnsResourceReferenceGetByTargetResources(ctx context.Context, id commonids.SubscriptionId, input DnsResourceReferenceRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/getDnsResourceReference", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDnsResourceReferenceGetByTargetResources handles the response to the DnsResourceReferenceGetByTargetResources request. The method always +// closes the http.Response Body. +func (c DnsClient) responderForDnsResourceReferenceGetByTargetResources(resp *http.Response) (result DnsResourceReferenceGetByTargetResourcesOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereference.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereference.go new file mode 100644 index 000000000000..251d3502e53e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereference.go @@ -0,0 +1,9 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReference struct { + DnsResources *[]SubResource `json:"dnsResources,omitempty"` + TargetResource *SubResource `json:"targetResource,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequest.go new file mode 100644 index 000000000000..235891e18d70 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequest.go @@ -0,0 +1,8 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReferenceRequest struct { + Properties *DnsResourceReferenceRequestProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequestproperties.go new file mode 100644 index 000000000000..5b97f49db18b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferencerequestproperties.go @@ -0,0 +1,8 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReferenceRequestProperties struct { + TargetResources *[]SubResource `json:"targetResources,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresult.go new file mode 100644 index 000000000000..e38b5769f2d5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresult.go @@ -0,0 +1,8 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReferenceResult struct { + Properties *DnsResourceReferenceResultProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresultproperties.go new file mode 100644 index 000000000000..50e2df8fb878 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_dnsresourcereferenceresultproperties.go @@ -0,0 +1,8 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsResourceReferenceResultProperties struct { + DnsResourceReferences *[]DnsResourceReference `json:"dnsResourceReferences,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_subresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_subresource.go new file mode 100644 index 000000000000..c0dc97fe59a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/model_subresource.go @@ -0,0 +1,8 @@ +package dns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/version.go new file mode 100644 index 000000000000..dee2e101b8e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns/version.go @@ -0,0 +1,12 @@ +package dns + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2018-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dns/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/README.md new file mode 100644 index 000000000000..9f4dd1a28150 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/README.md @@ -0,0 +1,145 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets` Documentation + +The `recordsets` SDK allows for interaction with the Azure Resource Manager Service `dns` (API Version `2018-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets" +``` + + +### Client Initialization + +```go +client := recordsets.NewRecordSetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecordSetsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := recordsets.NewRecordTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue", "A", "relativeRecordSetValue") + +payload := recordsets.RecordSet{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, recordsets.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecordSetsClient.Delete` + +```go +ctx := context.TODO() +id := recordsets.NewRecordTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue", "A", "relativeRecordSetValue") + +read, err := client.Delete(ctx, id, recordsets.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecordSetsClient.Get` + +```go +ctx := context.TODO() +id := recordsets.NewRecordTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue", "A", "relativeRecordSetValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecordSetsClient.ListAllByDnsZone` + +```go +ctx := context.TODO() +id := recordsets.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +// alternatively `client.ListAllByDnsZone(ctx, id, recordsets.DefaultListAllByDnsZoneOperationOptions())` can be used to do batched pagination +items, err := client.ListAllByDnsZoneComplete(ctx, id, recordsets.DefaultListAllByDnsZoneOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecordSetsClient.ListByDnsZone` + +```go +ctx := context.TODO() +id := recordsets.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +// alternatively `client.ListByDnsZone(ctx, id, recordsets.DefaultListByDnsZoneOperationOptions())` can be used to do batched pagination +items, err := client.ListByDnsZoneComplete(ctx, id, recordsets.DefaultListByDnsZoneOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecordSetsClient.ListByType` + +```go +ctx := context.TODO() +id := recordsets.NewZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue", "A") + +// alternatively `client.ListByType(ctx, id, recordsets.DefaultListByTypeOperationOptions())` can be used to do batched pagination +items, err := client.ListByTypeComplete(ctx, id, recordsets.DefaultListByTypeOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecordSetsClient.Update` + +```go +ctx := context.TODO() +id := recordsets.NewRecordTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue", "A", "relativeRecordSetValue") + +payload := recordsets.RecordSet{ + // ... +} + + +read, err := client.Update(ctx, id, payload, recordsets.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/client.go new file mode 100644 index 000000000000..64dcacc59849 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/client.go @@ -0,0 +1,18 @@ +package recordsets + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecordSetsClient struct { + Client autorest.Client + baseUri string +} + +func NewRecordSetsClientWithBaseURI(endpoint string) RecordSetsClient { + return RecordSetsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/constants.go new file mode 100644 index 000000000000..5586596d244d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/constants.go @@ -0,0 +1,58 @@ +package recordsets + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecordType string + +const ( + RecordTypeA RecordType = "A" + RecordTypeAAAA RecordType = "AAAA" + RecordTypeCAA RecordType = "CAA" + RecordTypeCNAME RecordType = "CNAME" + RecordTypeMX RecordType = "MX" + RecordTypeNS RecordType = "NS" + RecordTypePTR RecordType = "PTR" + RecordTypeSOA RecordType = "SOA" + RecordTypeSRV RecordType = "SRV" + RecordTypeTXT RecordType = "TXT" +) + +func PossibleValuesForRecordType() []string { + return []string{ + string(RecordTypeA), + string(RecordTypeAAAA), + string(RecordTypeCAA), + string(RecordTypeCNAME), + string(RecordTypeMX), + string(RecordTypeNS), + string(RecordTypePTR), + string(RecordTypeSOA), + string(RecordTypeSRV), + string(RecordTypeTXT), + } +} + +func parseRecordType(input string) (*RecordType, error) { + vals := map[string]RecordType{ + "a": RecordTypeA, + "aaaa": RecordTypeAAAA, + "caa": RecordTypeCAA, + "cname": RecordTypeCNAME, + "mx": RecordTypeMX, + "ns": RecordTypeNS, + "ptr": RecordTypePTR, + "soa": RecordTypeSOA, + "srv": RecordTypeSRV, + "txt": RecordTypeTXT, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecordType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_dnszone.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_dnszone.go new file mode 100644 index 000000000000..106e7a4319c2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_dnszone.go @@ -0,0 +1,124 @@ +package recordsets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = DnsZoneId{} + +// DnsZoneId is a struct representing the Resource ID for a Dns Zone +type DnsZoneId struct { + SubscriptionId string + ResourceGroupName string + ZoneName string +} + +// NewDnsZoneID returns a new DnsZoneId struct +func NewDnsZoneID(subscriptionId string, resourceGroupName string, zoneName string) DnsZoneId { + return DnsZoneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ZoneName: zoneName, + } +} + +// ParseDnsZoneID parses 'input' into a DnsZoneId +func ParseDnsZoneID(input string) (*DnsZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(DnsZoneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DnsZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseDnsZoneIDInsensitively parses 'input' case-insensitively into a DnsZoneId +// note: this method should only be used for API response data and not user input +func ParseDnsZoneIDInsensitively(input string) (*DnsZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(DnsZoneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DnsZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateDnsZoneID checks that 'input' can be parsed as a Dns Zone ID +func ValidateDnsZoneID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDnsZoneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dns Zone ID +func (id DnsZoneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnsZones/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ZoneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dns Zone ID +func (id DnsZoneId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDnsZones", "dnsZones", "dnsZones"), + resourceids.UserSpecifiedSegment("zoneName", "zoneValue"), + } +} + +// String returns a human-readable description of this Dns Zone ID +func (id DnsZoneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Zone Name: %q", id.ZoneName), + } + return fmt.Sprintf("Dns Zone (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_recordtype.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_recordtype.go new file mode 100644 index 000000000000..8b8a6ca07bda --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_recordtype.go @@ -0,0 +1,164 @@ +package recordsets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = RecordTypeId{} + +// RecordTypeId is a struct representing the Resource ID for a Record Type +type RecordTypeId struct { + SubscriptionId string + ResourceGroupName string + ZoneName string + RecordType RecordType + RelativeRecordSetName string +} + +// NewRecordTypeID returns a new RecordTypeId struct +func NewRecordTypeID(subscriptionId string, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string) RecordTypeId { + return RecordTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ZoneName: zoneName, + RecordType: recordType, + RelativeRecordSetName: relativeRecordSetName, + } +} + +// ParseRecordTypeID parses 'input' into a RecordTypeId +func ParseRecordTypeID(input string) (*RecordTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(RecordTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RecordTypeId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + if v, ok := parsed.Parsed["recordType"]; true { + if !ok { + return nil, fmt.Errorf("the segment 'recordType' was not found in the resource id %q", input) + } + + recordType, err := parseRecordType(v) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", v, err) + } + id.RecordType = *recordType + } + + if id.RelativeRecordSetName, ok = parsed.Parsed["relativeRecordSetName"]; !ok { + return nil, fmt.Errorf("the segment 'relativeRecordSetName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseRecordTypeIDInsensitively parses 'input' case-insensitively into a RecordTypeId +// note: this method should only be used for API response data and not user input +func ParseRecordTypeIDInsensitively(input string) (*RecordTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(RecordTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RecordTypeId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + if v, ok := parsed.Parsed["recordType"]; true { + if !ok { + return nil, fmt.Errorf("the segment 'recordType' was not found in the resource id %q", input) + } + + recordType, err := parseRecordType(v) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", v, err) + } + id.RecordType = *recordType + } + + if id.RelativeRecordSetName, ok = parsed.Parsed["relativeRecordSetName"]; !ok { + return nil, fmt.Errorf("the segment 'relativeRecordSetName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateRecordTypeID checks that 'input' can be parsed as a Record Type ID +func ValidateRecordTypeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecordTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Record Type ID +func (id RecordTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnsZones/%s/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ZoneName, string(id.RecordType), id.RelativeRecordSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Record Type ID +func (id RecordTypeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDnsZones", "dnsZones", "dnsZones"), + resourceids.UserSpecifiedSegment("zoneName", "zoneValue"), + resourceids.ConstantSegment("recordType", PossibleValuesForRecordType(), "A"), + resourceids.UserSpecifiedSegment("relativeRecordSetName", "relativeRecordSetValue"), + } +} + +// String returns a human-readable description of this Record Type ID +func (id RecordTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Zone Name: %q", id.ZoneName), + fmt.Sprintf("Record Type: %q", string(id.RecordType)), + fmt.Sprintf("Relative Record Set Name: %q", id.RelativeRecordSetName), + } + return fmt.Sprintf("Record Type (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_zone.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_zone.go new file mode 100644 index 000000000000..17d92e82ceb4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/id_zone.go @@ -0,0 +1,152 @@ +package recordsets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ZoneId{} + +// ZoneId is a struct representing the Resource ID for a Zone +type ZoneId struct { + SubscriptionId string + ResourceGroupName string + ZoneName string + RecordType RecordType +} + +// NewZoneID returns a new ZoneId struct +func NewZoneID(subscriptionId string, resourceGroupName string, zoneName string, recordType RecordType) ZoneId { + return ZoneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ZoneName: zoneName, + RecordType: recordType, + } +} + +// ParseZoneID parses 'input' into a ZoneId +func ParseZoneID(input string) (*ZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(ZoneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + if v, ok := parsed.Parsed["recordType"]; true { + if !ok { + return nil, fmt.Errorf("the segment 'recordType' was not found in the resource id %q", input) + } + + recordType, err := parseRecordType(v) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", v, err) + } + id.RecordType = *recordType + } + + return &id, nil +} + +// ParseZoneIDInsensitively parses 'input' case-insensitively into a ZoneId +// note: this method should only be used for API response data and not user input +func ParseZoneIDInsensitively(input string) (*ZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(ZoneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + if v, ok := parsed.Parsed["recordType"]; true { + if !ok { + return nil, fmt.Errorf("the segment 'recordType' was not found in the resource id %q", input) + } + + recordType, err := parseRecordType(v) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", v, err) + } + id.RecordType = *recordType + } + + return &id, nil +} + +// ValidateZoneID checks that 'input' can be parsed as a Zone ID +func ValidateZoneID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseZoneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Zone ID +func (id ZoneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnsZones/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ZoneName, string(id.RecordType)) +} + +// Segments returns a slice of Resource ID Segments which comprise this Zone ID +func (id ZoneId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDnsZones", "dnsZones", "dnsZones"), + resourceids.UserSpecifiedSegment("zoneName", "zoneValue"), + resourceids.ConstantSegment("recordType", PossibleValuesForRecordType(), "A"), + } +} + +// String returns a human-readable description of this Zone ID +func (id ZoneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Zone Name: %q", id.ZoneName), + fmt.Sprintf("Record Type: %q", string(id.RecordType)), + } + return fmt.Sprintf("Zone (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_createorupdate_autorest.go new file mode 100644 index 000000000000..115189971b80 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_createorupdate_autorest.go @@ -0,0 +1,103 @@ +package recordsets + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *RecordSet +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + if o.IfNoneMatch != nil { + out["If-None-Match"] = *o.IfNoneMatch + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c RecordSetsClient) CreateOrUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c RecordSetsClient) preparerForCreateOrUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options CreateOrUpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_delete_autorest.go new file mode 100644 index 000000000000..705826e0a5ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_delete_autorest.go @@ -0,0 +1,95 @@ +package recordsets + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + return out +} + +func (o DeleteOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Delete ... +func (c RecordSetsClient) Delete(ctx context.Context, id RecordTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c RecordSetsClient) preparerForDelete(ctx context.Context, id RecordTypeId, options DeleteOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_get_autorest.go new file mode 100644 index 000000000000..0a8532477291 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_get_autorest.go @@ -0,0 +1,68 @@ +package recordsets + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *RecordSet +} + +// Get ... +func (c RecordSetsClient) Get(ctx context.Context, id RecordTypeId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c RecordSetsClient) preparerForGet(ctx context.Context, id RecordTypeId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listallbydnszone_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listallbydnszone_autorest.go new file mode 100644 index 000000000000..c7da04165543 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listallbydnszone_autorest.go @@ -0,0 +1,220 @@ +package recordsets + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllByDnsZoneOperationResponse struct { + HttpResponse *http.Response + Model *[]RecordSet + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAllByDnsZoneOperationResponse, error) +} + +type ListAllByDnsZoneCompleteResult struct { + Items []RecordSet +} + +func (r ListAllByDnsZoneOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAllByDnsZoneOperationResponse) LoadMore(ctx context.Context) (resp ListAllByDnsZoneOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListAllByDnsZoneOperationOptions struct { + Recordsetnamesuffix *string + Top *int64 +} + +func DefaultListAllByDnsZoneOperationOptions() ListAllByDnsZoneOperationOptions { + return ListAllByDnsZoneOperationOptions{} +} + +func (o ListAllByDnsZoneOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListAllByDnsZoneOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Recordsetnamesuffix != nil { + out["$recordsetnamesuffix"] = *o.Recordsetnamesuffix + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListAllByDnsZone ... +func (c RecordSetsClient) ListAllByDnsZone(ctx context.Context, id DnsZoneId, options ListAllByDnsZoneOperationOptions) (resp ListAllByDnsZoneOperationResponse, err error) { + req, err := c.preparerForListAllByDnsZone(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAllByDnsZone(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListAllByDnsZone prepares the ListAllByDnsZone request. +func (c RecordSetsClient) preparerForListAllByDnsZone(ctx context.Context, id DnsZoneId, options ListAllByDnsZoneOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/all", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAllByDnsZoneWithNextLink prepares the ListAllByDnsZone request with the given nextLink token. +func (c RecordSetsClient) preparerForListAllByDnsZoneWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListAllByDnsZone handles the response to the ListAllByDnsZone request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForListAllByDnsZone(resp *http.Response) (result ListAllByDnsZoneOperationResponse, err error) { + type page struct { + Values []RecordSet `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAllByDnsZoneOperationResponse, err error) { + req, err := c.preparerForListAllByDnsZoneWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAllByDnsZone(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListAllByDnsZone", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListAllByDnsZoneComplete retrieves all of the results into a single object +func (c RecordSetsClient) ListAllByDnsZoneComplete(ctx context.Context, id DnsZoneId, options ListAllByDnsZoneOperationOptions) (ListAllByDnsZoneCompleteResult, error) { + return c.ListAllByDnsZoneCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) +} + +// ListAllByDnsZoneCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecordSetsClient) ListAllByDnsZoneCompleteMatchingPredicate(ctx context.Context, id DnsZoneId, options ListAllByDnsZoneOperationOptions, predicate RecordSetOperationPredicate) (resp ListAllByDnsZoneCompleteResult, err error) { + items := make([]RecordSet, 0) + + page, err := c.ListAllByDnsZone(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListAllByDnsZoneCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbydnszone_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbydnszone_autorest.go new file mode 100644 index 000000000000..b369625fedc5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbydnszone_autorest.go @@ -0,0 +1,220 @@ +package recordsets + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByDnsZoneOperationResponse struct { + HttpResponse *http.Response + Model *[]RecordSet + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByDnsZoneOperationResponse, error) +} + +type ListByDnsZoneCompleteResult struct { + Items []RecordSet +} + +func (r ListByDnsZoneOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByDnsZoneOperationResponse) LoadMore(ctx context.Context) (resp ListByDnsZoneOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByDnsZoneOperationOptions struct { + Recordsetnamesuffix *string + Top *int64 +} + +func DefaultListByDnsZoneOperationOptions() ListByDnsZoneOperationOptions { + return ListByDnsZoneOperationOptions{} +} + +func (o ListByDnsZoneOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByDnsZoneOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Recordsetnamesuffix != nil { + out["$recordsetnamesuffix"] = *o.Recordsetnamesuffix + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByDnsZone ... +func (c RecordSetsClient) ListByDnsZone(ctx context.Context, id DnsZoneId, options ListByDnsZoneOperationOptions) (resp ListByDnsZoneOperationResponse, err error) { + req, err := c.preparerForListByDnsZone(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByDnsZone(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByDnsZone prepares the ListByDnsZone request. +func (c RecordSetsClient) preparerForListByDnsZone(ctx context.Context, id DnsZoneId, options ListByDnsZoneOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/recordsets", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByDnsZoneWithNextLink prepares the ListByDnsZone request with the given nextLink token. +func (c RecordSetsClient) preparerForListByDnsZoneWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByDnsZone handles the response to the ListByDnsZone request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForListByDnsZone(resp *http.Response) (result ListByDnsZoneOperationResponse, err error) { + type page struct { + Values []RecordSet `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByDnsZoneOperationResponse, err error) { + req, err := c.preparerForListByDnsZoneWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByDnsZone(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByDnsZone", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByDnsZoneComplete retrieves all of the results into a single object +func (c RecordSetsClient) ListByDnsZoneComplete(ctx context.Context, id DnsZoneId, options ListByDnsZoneOperationOptions) (ListByDnsZoneCompleteResult, error) { + return c.ListByDnsZoneCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) +} + +// ListByDnsZoneCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecordSetsClient) ListByDnsZoneCompleteMatchingPredicate(ctx context.Context, id DnsZoneId, options ListByDnsZoneOperationOptions, predicate RecordSetOperationPredicate) (resp ListByDnsZoneCompleteResult, err error) { + items := make([]RecordSet, 0) + + page, err := c.ListByDnsZone(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByDnsZoneCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbytype_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbytype_autorest.go new file mode 100644 index 000000000000..50ced26d8e1d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_listbytype_autorest.go @@ -0,0 +1,220 @@ +package recordsets + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByTypeOperationResponse struct { + HttpResponse *http.Response + Model *[]RecordSet + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByTypeOperationResponse, error) +} + +type ListByTypeCompleteResult struct { + Items []RecordSet +} + +func (r ListByTypeOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByTypeOperationResponse) LoadMore(ctx context.Context) (resp ListByTypeOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByTypeOperationOptions struct { + Recordsetnamesuffix *string + Top *int64 +} + +func DefaultListByTypeOperationOptions() ListByTypeOperationOptions { + return ListByTypeOperationOptions{} +} + +func (o ListByTypeOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByTypeOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Recordsetnamesuffix != nil { + out["$recordsetnamesuffix"] = *o.Recordsetnamesuffix + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByType ... +func (c RecordSetsClient) ListByType(ctx context.Context, id ZoneId, options ListByTypeOperationOptions) (resp ListByTypeOperationResponse, err error) { + req, err := c.preparerForListByType(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByType(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByType prepares the ListByType request. +func (c RecordSetsClient) preparerForListByType(ctx context.Context, id ZoneId, options ListByTypeOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByTypeWithNextLink prepares the ListByType request with the given nextLink token. +func (c RecordSetsClient) preparerForListByTypeWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByType handles the response to the ListByType request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForListByType(resp *http.Response) (result ListByTypeOperationResponse, err error) { + type page struct { + Values []RecordSet `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByTypeOperationResponse, err error) { + req, err := c.preparerForListByTypeWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByType(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByTypeComplete retrieves all of the results into a single object +func (c RecordSetsClient) ListByTypeComplete(ctx context.Context, id ZoneId, options ListByTypeOperationOptions) (ListByTypeCompleteResult, error) { + return c.ListByTypeCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) +} + +// ListByTypeCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecordSetsClient) ListByTypeCompleteMatchingPredicate(ctx context.Context, id ZoneId, options ListByTypeOperationOptions, predicate RecordSetOperationPredicate) (resp ListByTypeCompleteResult, err error) { + items := make([]RecordSet, 0) + + page, err := c.ListByType(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByTypeCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_update_autorest.go new file mode 100644 index 000000000000..2fac5ae40428 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/method_update_autorest.go @@ -0,0 +1,98 @@ +package recordsets + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *RecordSet +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + return out +} + +func (o UpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Update ... +func (c RecordSetsClient) Update(ctx context.Context, id RecordTypeId, input RecordSet, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c RecordSetsClient) preparerForUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options UpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c RecordSetsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_aaaarecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_aaaarecord.go new file mode 100644 index 000000000000..ab849f34d41a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_aaaarecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AaaaRecord struct { + IPv6Address *string `json:"ipv6Address,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_arecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_arecord.go new file mode 100644 index 000000000000..878b5d761d5b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_arecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ARecord struct { + IPv4Address *string `json:"ipv4Address,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_caarecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_caarecord.go new file mode 100644 index 000000000000..5ed36722ae2a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_caarecord.go @@ -0,0 +1,10 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CaaRecord struct { + Flags *int64 `json:"flags,omitempty"` + Tag *string `json:"tag,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_cnamerecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_cnamerecord.go new file mode 100644 index 000000000000..911f2640c054 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_cnamerecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CnameRecord struct { + Cname *string `json:"cname,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_mxrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_mxrecord.go new file mode 100644 index 000000000000..54903e902e4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_mxrecord.go @@ -0,0 +1,9 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MxRecord struct { + Exchange *string `json:"exchange,omitempty"` + Preference *int64 `json:"preference,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_nsrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_nsrecord.go new file mode 100644 index 000000000000..e8ecb9f9ef4f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_nsrecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NsRecord struct { + Nsdname *string `json:"nsdname,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_ptrrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_ptrrecord.go new file mode 100644 index 000000000000..f05e7f6dd8cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_ptrrecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PtrRecord struct { + Ptrdname *string `json:"ptrdname,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordset.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordset.go new file mode 100644 index 000000000000..5b44bdb53645 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordset.go @@ -0,0 +1,12 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecordSet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecordSetProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordsetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordsetproperties.go new file mode 100644 index 000000000000..a02004816a24 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_recordsetproperties.go @@ -0,0 +1,22 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecordSetProperties struct { + AAAARecords *[]AaaaRecord `json:"AAAARecords,omitempty"` + ARecords *[]ARecord `json:"ARecords,omitempty"` + CNAMERecord *CnameRecord `json:"CNAMERecord,omitempty"` + CaaRecords *[]CaaRecord `json:"caaRecords,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + MXRecords *[]MxRecord `json:"MXRecords,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + NSRecords *[]NsRecord `json:"NSRecords,omitempty"` + PTRRecords *[]PtrRecord `json:"PTRRecords,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + SOARecord *SoaRecord `json:"SOARecord,omitempty"` + SRVRecords *[]SrvRecord `json:"SRVRecords,omitempty"` + TTL *int64 `json:"TTL,omitempty"` + TXTRecords *[]TxtRecord `json:"TXTRecords,omitempty"` + TargetResource *SubResource `json:"targetResource,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_soarecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_soarecord.go new file mode 100644 index 000000000000..973b2929c374 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_soarecord.go @@ -0,0 +1,14 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SoaRecord struct { + Email *string `json:"email,omitempty"` + ExpireTime *int64 `json:"expireTime,omitempty"` + Host *string `json:"host,omitempty"` + MinimumTTL *int64 `json:"minimumTTL,omitempty"` + RefreshTime *int64 `json:"refreshTime,omitempty"` + RetryTime *int64 `json:"retryTime,omitempty"` + SerialNumber *int64 `json:"serialNumber,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_srvrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_srvrecord.go new file mode 100644 index 000000000000..98d79cdea1df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_srvrecord.go @@ -0,0 +1,11 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SrvRecord struct { + Port *int64 `json:"port,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Target *string `json:"target,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_subresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_subresource.go new file mode 100644 index 000000000000..8e480245b50e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_subresource.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_txtrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_txtrecord.go new file mode 100644 index 000000000000..a55b70eade17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/model_txtrecord.go @@ -0,0 +1,8 @@ +package recordsets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TxtRecord struct { + Value *[]string `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/predicates.go new file mode 100644 index 000000000000..f4ab833e9bf6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/predicates.go @@ -0,0 +1,29 @@ +package recordsets + +type RecordSetOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RecordSetOperationPredicate) Matches(input RecordSet) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/version.go new file mode 100644 index 000000000000..691500e20078 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets/version.go @@ -0,0 +1,12 @@ +package recordsets + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2018-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recordsets/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/README.md new file mode 100644 index 000000000000..3fad79a0b70f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/README.md @@ -0,0 +1,124 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones` Documentation + +The `zones` SDK allows for interaction with the Azure Resource Manager Service `dns` (API Version `2018-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" +``` + + +### Client Initialization + +```go +client := zones.NewZonesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ZonesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := zones.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +payload := zones.Zone{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, zones.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ZonesClient.Delete` + +```go +ctx := context.TODO() +id := zones.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +if err := client.DeleteThenPoll(ctx, id, zones.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ZonesClient.Get` + +```go +ctx := context.TODO() +id := zones.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ZonesClient.List` + +```go +ctx := context.TODO() +id := zones.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, zones.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, zones.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ZonesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := zones.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, zones.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, zones.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ZonesClient.Update` + +```go +ctx := context.TODO() +id := zones.NewDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "zoneValue") + +payload := zones.ZoneUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload, zones.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/client.go new file mode 100644 index 000000000000..e36c39abb89d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/client.go @@ -0,0 +1,18 @@ +package zones + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ZonesClient struct { + Client autorest.Client + baseUri string +} + +func NewZonesClientWithBaseURI(endpoint string) ZonesClient { + return ZonesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/constants.go new file mode 100644 index 000000000000..6150a4c67b34 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/constants.go @@ -0,0 +1,34 @@ +package zones + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ZoneType string + +const ( + ZoneTypePrivate ZoneType = "Private" + ZoneTypePublic ZoneType = "Public" +) + +func PossibleValuesForZoneType() []string { + return []string{ + string(ZoneTypePrivate), + string(ZoneTypePublic), + } +} + +func parseZoneType(input string) (*ZoneType, error) { + vals := map[string]ZoneType{ + "private": ZoneTypePrivate, + "public": ZoneTypePublic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/id_dnszone.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/id_dnszone.go new file mode 100644 index 000000000000..cde7778f9a2f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/id_dnszone.go @@ -0,0 +1,124 @@ +package zones + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = DnsZoneId{} + +// DnsZoneId is a struct representing the Resource ID for a Dns Zone +type DnsZoneId struct { + SubscriptionId string + ResourceGroupName string + ZoneName string +} + +// NewDnsZoneID returns a new DnsZoneId struct +func NewDnsZoneID(subscriptionId string, resourceGroupName string, zoneName string) DnsZoneId { + return DnsZoneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ZoneName: zoneName, + } +} + +// ParseDnsZoneID parses 'input' into a DnsZoneId +func ParseDnsZoneID(input string) (*DnsZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(DnsZoneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DnsZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseDnsZoneIDInsensitively parses 'input' case-insensitively into a DnsZoneId +// note: this method should only be used for API response data and not user input +func ParseDnsZoneIDInsensitively(input string) (*DnsZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(DnsZoneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DnsZoneId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ZoneName, ok = parsed.Parsed["zoneName"]; !ok { + return nil, fmt.Errorf("the segment 'zoneName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateDnsZoneID checks that 'input' can be parsed as a Dns Zone ID +func ValidateDnsZoneID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDnsZoneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dns Zone ID +func (id DnsZoneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dnsZones/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ZoneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dns Zone ID +func (id DnsZoneId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDnsZones", "dnsZones", "dnsZones"), + resourceids.UserSpecifiedSegment("zoneName", "zoneValue"), + } +} + +// String returns a human-readable description of this Dns Zone ID +func (id DnsZoneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Zone Name: %q", id.ZoneName), + } + return fmt.Sprintf("Dns Zone (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_createorupdate_autorest.go new file mode 100644 index 000000000000..9f756912c6d6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_createorupdate_autorest.go @@ -0,0 +1,103 @@ +package zones + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *Zone +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + if o.IfNoneMatch != nil { + out["If-None-Match"] = *o.IfNoneMatch + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c ZonesClient) CreateOrUpdate(ctx context.Context, id DnsZoneId, input Zone, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ZonesClient) preparerForCreateOrUpdate(ctx context.Context, id DnsZoneId, input Zone, options CreateOrUpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ZonesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_delete_autorest.go new file mode 100644 index 000000000000..d28060357b0c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_delete_autorest.go @@ -0,0 +1,107 @@ +package zones + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + return out +} + +func (o DeleteOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Delete ... +func (c ZonesClient) Delete(ctx context.Context, id DnsZoneId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ZonesClient) DeleteThenPoll(ctx context.Context, id DnsZoneId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c ZonesClient) preparerForDelete(ctx context.Context, id DnsZoneId, options DeleteOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c ZonesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_get_autorest.go new file mode 100644 index 000000000000..b583472a3a8e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_get_autorest.go @@ -0,0 +1,68 @@ +package zones + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *Zone +} + +// Get ... +func (c ZonesClient) Get(ctx context.Context, id DnsZoneId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ZonesClient) preparerForGet(ctx context.Context, id DnsZoneId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ZonesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_list_autorest.go new file mode 100644 index 000000000000..d20a35acddee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_list_autorest.go @@ -0,0 +1,216 @@ +package zones + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]Zone + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []Zone +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// List ... +func (c ZonesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c ZonesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/dnszones", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c ZonesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c ZonesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []Zone `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c ZonesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ZoneOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ZonesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ZoneOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]Zone, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..0e7ce808b01e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_listbyresourcegroup_autorest.go @@ -0,0 +1,216 @@ +package zones + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]Zone + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []Zone +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByResourceGroup ... +func (c ZonesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c ZonesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/dnsZones", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c ZonesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c ZonesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []Zone `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c ZonesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, ZoneOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ZonesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate ZoneOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]Zone, 0) + + page, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_update_autorest.go new file mode 100644 index 000000000000..6f013c7352ac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/method_update_autorest.go @@ -0,0 +1,98 @@ +package zones + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *Zone +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.IfMatch != nil { + out["If-Match"] = *o.IfMatch + } + + return out +} + +func (o UpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Update ... +func (c ZonesClient) Update(ctx context.Context, id DnsZoneId, input ZoneUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "zones.ZonesClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c ZonesClient) preparerForUpdate(ctx context.Context, id DnsZoneId, input ZoneUpdate, options UpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c ZonesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_subresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_subresource.go new file mode 100644 index 000000000000..325bcfb56e5b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_subresource.go @@ -0,0 +1,8 @@ +package zones + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zone.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zone.go new file mode 100644 index 000000000000..1d4232227705 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zone.go @@ -0,0 +1,14 @@ +package zones + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Zone struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ZoneProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneproperties.go new file mode 100644 index 000000000000..f1c8b2e780e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneproperties.go @@ -0,0 +1,14 @@ +package zones + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ZoneProperties struct { + MaxNumberOfRecordSets *int64 `json:"maxNumberOfRecordSets,omitempty"` + MaxNumberOfRecordsPerRecordSet *int64 `json:"maxNumberOfRecordsPerRecordSet,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + NumberOfRecordSets *int64 `json:"numberOfRecordSets,omitempty"` + RegistrationVirtualNetworks *[]SubResource `json:"registrationVirtualNetworks,omitempty"` + ResolutionVirtualNetworks *[]SubResource `json:"resolutionVirtualNetworks,omitempty"` + ZoneType *ZoneType `json:"zoneType,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneupdate.go new file mode 100644 index 000000000000..6cfc17369a75 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/model_zoneupdate.go @@ -0,0 +1,8 @@ +package zones + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ZoneUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/predicates.go new file mode 100644 index 000000000000..1254cb7e830d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/predicates.go @@ -0,0 +1,34 @@ +package zones + +type ZoneOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ZoneOperationPredicate) Matches(input Zone) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/version.go new file mode 100644 index 000000000000..97c17a20e3aa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones/version.go @@ -0,0 +1,12 @@ +package zones + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2018-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/zones/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ef60c10ba479..3563ac0d9af6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -20,7 +20,6 @@ github.com/Azure/azure-sdk-for-go/services/datamigration/mgmt/2018-04-19/datamig github.com/Azure/azure-sdk-for-go/services/datashare/mgmt/2019-11-01/datashare github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl github.com/Azure/azure-sdk-for-go/services/digitaltwins/mgmt/2020-12-01/digitaltwins -github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2021-12-01/eventgrid github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac @@ -222,6 +221,10 @@ github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2021-09 github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2021-09-03-preview/scalingplan github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2021-09-03-preview/sessionhost github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2021-09-03-preview/workspace +github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01 +github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/dns +github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/recordsets +github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones github.com/hashicorp/go-azure-sdk/resource-manager/elastic/2020-07-01/monitorsresource github.com/hashicorp/go-azure-sdk/resource-manager/elastic/2020-07-01/rules github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/authorizationruleseventhubs