From 9f9a3879542cee12fc22ddbca319f951d6ed4de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 2 Jun 2024 10:17:09 +0200 Subject: [PATCH 01/13] New Resource: `azurerm_email_communication_service_domain` --- .../services/communication/client/client.go | 9 + .../communication_service_resource.go | 9 +- .../communication_service_resource_test.go | 17 +- .../email_service_domain_resource.go | 319 ++++++++++++++++++ .../email_service_domain_resource_test.go | 194 +++++++++++ .../communication/helper/domain_record.go | 53 +++ .../services/communication/registration.go | 1 + .../2023-03-31/domains/README.md | 133 ++++++++ .../2023-03-31/domains/client.go | 26 ++ .../2023-03-31/domains/constants.go | 260 ++++++++++++++ .../2023-03-31/domains/id_domain.go | 139 ++++++++ .../2023-03-31/domains/id_emailservice.go | 130 +++++++ .../domains/method_cancelverification.go | 73 ++++ .../domains/method_createorupdate.go | 75 ++++ .../2023-03-31/domains/method_delete.go | 71 ++++ .../2023-03-31/domains/method_get.go | 54 +++ .../domains/method_initiateverification.go | 73 ++++ .../method_listbyemailserviceresource.go | 92 +++++ .../2023-03-31/domains/method_update.go | 75 ++++ .../2023-03-31/domains/model_dnsrecord.go | 11 + .../domains/model_domainproperties.go | 15 + ...del_domainpropertiesverificationrecords.go | 12 + ...odel_domainpropertiesverificationstates.go | 12 + .../domains/model_domainresource.go | 18 + .../domains/model_updatedomainproperties.go | 8 + .../model_updatedomainrequestparameters.go | 9 + .../domains/model_verificationparameter.go | 8 + .../domains/model_verificationstatusrecord.go | 9 + .../2023-03-31/domains/predicates.go | 32 ++ .../2023-03-31/domains/version.go | 12 + vendor/modules.txt | 1 + .../r/communication_service.html.markdown | 2 + ...communication_service_domain.html.markdown | 143 ++++++++ 33 files changed, 2093 insertions(+), 2 deletions(-) create mode 100644 internal/services/communication/email_service_domain_resource.go create mode 100644 internal/services/communication/email_service_domain_resource_test.go create mode 100644 internal/services/communication/helper/domain_record.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_domain.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_emailservice.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_cancelverification.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_initiateverification.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_listbyemailserviceresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_dnsrecord.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationrecords.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationstates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainrequestparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationparameter.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationstatusrecord.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/version.go create mode 100644 website/docs/r/email_communication_service_domain.html.markdown diff --git a/internal/services/communication/client/client.go b/internal/services/communication/client/client.go index 07c8fe461f2c..cd37e5b1713c 100644 --- a/internal/services/communication/client/client.go +++ b/internal/services/communication/client/client.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/emailservices" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -15,6 +16,7 @@ type Client struct { ServiceClient *communicationservices.CommunicationServicesClient EmailServicesClient *emailservices.EmailServicesClient + DomainClient *domains.DomainsClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -30,8 +32,15 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(emailServicesClient.Client, o.Authorizers.ResourceManager) + domainsClient, err := domains.NewDomainsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Domain Service client: %+v", err) + } + o.Configure(domainsClient.Client, o.Authorizers.ResourceManager) + return &Client{ ServiceClient: servicesClient, EmailServicesClient: emailServicesClient, + DomainClient: domainsClient, }, nil } diff --git a/internal/services/communication/communication_service_resource.go b/internal/services/communication/communication_service_resource.go index f7878b47676a..61b20a7cbf49 100644 --- a/internal/services/communication/communication_service_resource.go +++ b/internal/services/communication/communication_service_resource.go @@ -29,6 +29,7 @@ type CommunicationServiceResourceModel struct { Name string `tfschema:"name"` ResourceGroupName string `tfschema:"resource_group_name"` DataLocation string `tfschema:"data_location"` + LinkedDomains []string `tfschema:"linked_domains"` Tags map[string]string `tfschema:"tags"` PrimaryConnectionString string `tfschema:"primary_connection_string"` @@ -146,7 +147,8 @@ func (r CommunicationServiceResource) Create() sdk.ResourceFunc { // The location is always `global` from the Azure Portal Location: location.Normalize("global"), Properties: &communicationservices.CommunicationServiceProperties{ - DataLocation: model.DataLocation, + DataLocation: model.DataLocation, + LinkedDomains: pointer.To(model.LinkedDomains), }, Tags: pointer.To(model.Tags), } @@ -191,6 +193,10 @@ func (r CommunicationServiceResource) Update() sdk.ResourceFunc { props.DataLocation = model.DataLocation } + if metadata.ResourceData.HasChange("linked_domains") { + props.LinkedDomains = pointer.To(model.LinkedDomains) + } + existing.Model.Properties = &props if metadata.ResourceData.HasChange("tags") { @@ -239,6 +245,7 @@ func (CommunicationServiceResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if props := model.Properties; props != nil { state.DataLocation = props.DataLocation + state.LinkedDomains = pointer.From(props.LinkedDomains) } state.Tags = pointer.From(model.Tags) diff --git a/internal/services/communication/communication_service_resource_test.go b/internal/services/communication/communication_service_resource_test.go index bcb5284f8c6b..60f16440afd4 100644 --- a/internal/services/communication/communication_service_resource_test.go +++ b/internal/services/communication/communication_service_resource_test.go @@ -137,10 +137,25 @@ func (r CommunicationServiceTestResource) complete(data acceptance.TestData) str return fmt.Sprintf(` %s +resource "azurerm_email_communication_service" "test" { + name = "acctest-CommunicationService-%[2]d" + resource_group_name = azurerm_resource_group.test.name + data_location = "United States" +} + +resource "azurerm_email_communication_service_domain" "test" { + name = azurerm_email_communication_service_domain.test.name + resource_group_name = azurerm_email_communication_service_domain.test.resource_group_name + email_service_name = azurerm_email_communication_service_domain.test.email_service_name + + domain_management = azurerm_email_communication_service_domain.test.domain_management +} + resource "azurerm_communication_service" "test" { - name = "acctest-CommunicationService-%d" + name = "acctest-CommunicationService-%[2]d" resource_group_name = azurerm_resource_group.test.name data_location = "United States" + linked_domains = [azurerm_email_communication_service_domain.test.id] tags = { env = "Test" diff --git a/internal/services/communication/email_service_domain_resource.go b/internal/services/communication/email_service_domain_resource.go new file mode 100644 index 000000000000..83c4c47affb3 --- /dev/null +++ b/internal/services/communication/email_service_domain_resource.go @@ -0,0 +1,319 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package communication + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "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-sdk/resource-manager/communication/2023-03-31/domains" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/helper" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +var _ sdk.ResourceWithUpdate = EmailCommunicationServiceDomainResource{} + +type EmailCommunicationServiceDomainResource struct{} + +type EmailCommunicationServiceDomainResourceModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + EMailServiceName string `tfschema:"email_service_name"` + DomainManagement string `tfschema:"domain_management"` + UserEngagementTracking bool `tfschema:"user_engagement_tracking"` + Tags map[string]string `tfschema:"tags"` + + FromSenderDomain string `tfschema:"from_sender_domain"` + MailFromSenderDomain string `tfschema:"mail_from_sender_domain"` + VerificationRecords []EmailDomainVerificationRecords `tfschema:"verification_records"` +} + +type EmailDomainVerificationRecords struct { + Domain []helper.DomainVerificationRecords `tfschema:"domain"` + SPF []helper.DomainVerificationRecords `tfschema:"spf"` + DMARC []helper.DomainVerificationRecords `tfschema:"dmarc"` + DKIM []helper.DomainVerificationRecords `tfschema:"dkim"` + DKIM2 []helper.DomainVerificationRecords `tfschema:"dkim2"` +} + +func (EmailCommunicationServiceDomainResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "email_service_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CommunicationServiceName, + }, + + "domain_management": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(domains.PossibleValuesForDomainManagement(), false), + }, + + "user_engagement_tracking": { + Type: pluginsdk.TypeBool, + Optional: true, + Computed: true, + }, + + "tags": commonschema.Tags(), + } +} + +func (EmailCommunicationServiceDomainResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "from_sender_domain": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "mail_from_sender_domain": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "verification_records": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "domain": helper.DomainVerificationRecordsCommonSchema(), + "dkim": helper.DomainVerificationRecordsCommonSchema(), + "dkim2": helper.DomainVerificationRecordsCommonSchema(), + "dmarc": helper.DomainVerificationRecordsCommonSchema(), + "spf": helper.DomainVerificationRecordsCommonSchema(), + }, + }, + }, + } +} + +func (EmailCommunicationServiceDomainResource) ModelObject() interface{} { + return &EmailCommunicationServiceDomainResourceModel{} +} + +func (EmailCommunicationServiceDomainResource) ResourceType() string { + return "azurerm_email_communication_service_domain" +} + +func (r EmailCommunicationServiceDomainResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + subscriptionId := metadata.Client.Account.SubscriptionId + client := metadata.Client.Communication.DomainClient + + var model EmailCommunicationServiceDomainResourceModel + if err := metadata.Decode(&model); err != nil { + return err + } + + id := domains.NewDomainID(subscriptionId, model.ResourceGroupName, model.EMailServiceName, model.Name) + + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := &domains.DomainProperties{ + DomainManagement: domains.DomainManagement(model.DomainManagement), + } + + properties.UserEngagementTracking = pointer.To(domains.UserEngagementTrackingDisabled) + if model.UserEngagementTracking { + properties.UserEngagementTracking = pointer.To(domains.UserEngagementTrackingEnabled) + } + + param := domains.DomainResource{ + // The location is always `global` from the Azure Portal + Location: location.Normalize("global"), + Properties: properties, + Tags: pointer.To(model.Tags), + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, param); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r EmailCommunicationServiceDomainResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Communication.DomainClient + + var model EmailCommunicationServiceDomainResourceModel + + if err := metadata.Decode(&model); err != nil { + return err + } + + id, err := domains.ParseDomainID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + existing, err := client.Get(ctx, *id) + if err != nil || existing.Model == nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + domain := *existing.Model + + props := pointer.From(domain.Properties) + + if metadata.ResourceData.HasChange("user_engagement_tracking") { + userEngagementTracking := domains.UserEngagementTrackingDisabled + if model.UserEngagementTracking { + userEngagementTracking = domains.UserEngagementTrackingEnabled + } + + props.UserEngagementTracking = pointer.To(userEngagementTracking) + } + + if metadata.ResourceData.HasChange("tags") { + domain.Tags = pointer.To(model.Tags) + } + + domain.Properties = &props + + if err := client.CreateOrUpdateThenPoll(ctx, *id, domain); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + return nil + }, + } +} + +func (EmailCommunicationServiceDomainResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Communication.DomainClient + + state := EmailCommunicationServiceDomainResourceModel{} + + id, err := domains.ParseDomainID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + state.Name = id.DomainName + state.ResourceGroupName = id.ResourceGroupName + state.EMailServiceName = id.EmailServiceName + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + state.DomainManagement = string(props.DomainManagement) + + if props.FromSenderDomain != nil { + state.FromSenderDomain = pointer.From(props.FromSenderDomain) + } + + if props.MailFromSenderDomain != nil { + state.MailFromSenderDomain = pointer.From(props.MailFromSenderDomain) + } + + if props.UserEngagementTracking != nil { + state.UserEngagementTracking = false + if *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled { + state.UserEngagementTracking = true + } + } + + domainVerificationRecords := EmailDomainVerificationRecords{} + + if verificationRecords := props.VerificationRecords; verificationRecords != nil { + if record := verificationRecords.DKIM; record != nil { + domainVerificationRecords.DKIM = helper.DomainVerificationRecordsToModel(record) + } + + if record := verificationRecords.DKIM2; record != nil { + domainVerificationRecords.DKIM2 = helper.DomainVerificationRecordsToModel(record) + } + + if record := verificationRecords.DMARC; record != nil { + domainVerificationRecords.DMARC = helper.DomainVerificationRecordsToModel(record) + } + + if record := verificationRecords.Domain; record != nil { + domainVerificationRecords.Domain = helper.DomainVerificationRecordsToModel(record) + } + + if record := verificationRecords.SPF; record != nil { + domainVerificationRecords.SPF = helper.DomainVerificationRecordsToModel(record) + } + } + + state.VerificationRecords = []EmailDomainVerificationRecords{domainVerificationRecords} + } + + state.Tags = pointer.From(model.Tags) + } + + return metadata.Encode(&state) + }, + } +} + +func (EmailCommunicationServiceDomainResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Communication.DomainClient + + id, err := domains.ParseDomainID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (EmailCommunicationServiceDomainResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return domains.ValidateDomainID +} diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go new file mode 100644 index 000000000000..d68fd374fa09 --- /dev/null +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -0,0 +1,194 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package communication_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type EmailServiceDomainTestResource struct{} + +func TestAccEmailServiceDomain_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_email_communication_service_domain", "test") + r := EmailServiceDomainTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccEmailServiceDomain_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_email_communication_service_domain", "test") + r := EmailServiceDomainTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccEmailServiceDomain_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_email_communication_service_domain", "test") + r := EmailServiceDomainTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data, "false"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("user_engagement_tracking").HasValue("false"), + check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.domain.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.domain.0.type").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.domain.0.name").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.domain.0.value").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.domain.0.ttl").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.dkim.0.type").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim.0.name").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim.0.value").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim.0.ttl").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim2.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.dkim2.0.type").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim2.0.name").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim2.0.value").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.dkim2.0.ttl").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.spf.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.spf.0.type").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.spf.0.name").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.spf.0.value").IsNotEmpty(), + check.That(data.ResourceName).Key("verification_records.0.spf.0.ttl").IsNotEmpty(), + ), + }, + data.ImportStep(), + { + Config: r.complete(data, "true"), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), + check.That(data.ResourceName).Key("user_engagement_tracking").HasValue("true"), + check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.domain.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.dkim.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.dkim2.#").HasValue("1"), + check.That(data.ResourceName).Key("verification_records.0.spf.#").HasValue("1"), + ), + }, + data.ImportStep(), + }) +} + +func (r EmailServiceDomainTestResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + domainClient := client.Communication.DomainClient + id, err := domains.ParseDomainID(state.ID) + if err != nil { + return nil, err + } + + resp, err := domainClient.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + + return nil, fmt.Errorf("retrieving Email Domain Communication Service %q: %+v", state.ID, err) + } + + return utils.Bool(resp.Model != nil), nil +} + +func (r EmailServiceDomainTestResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_email_communication_service_domain" "test" { + name = "AzureManagedDomain" + resource_group_name = azurerm_resource_group.test.name + email_service_name = azurerm_email_communication_service.test.name + + domain_management = "AzureManaged" +} +`, r.template(data)) +} + +func (r EmailServiceDomainTestResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_email_communication_service_domain" "import" { + name = azurerm_email_communication_service_domain.test.name + resource_group_name = azurerm_email_communication_service_domain.test.resource_group_name + email_service_name = azurerm_email_communication_service_domain.test.email_service_name + + domain_management = azurerm_email_communication_service_domain.test.domain_management +} +`, config) +} + +func (r EmailServiceDomainTestResource) complete(data acceptance.TestData, userTrackingEnabled string) string { + return fmt.Sprintf(` +%s + +resource "azurerm_email_communication_service_domain" "test" { + name = "example.com" + resource_group_name = azurerm_resource_group.test.name + email_service_name = azurerm_email_communication_service.test.name + + domain_management = "CustomerManaged" + user_engagement_tracking = %s + + tags = { + env = "Test" + } +} +`, r.template(data), userTrackingEnabled) +} + +func (r EmailServiceDomainTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-communicationservice-%[1]d" + location = "%[2]s" +} + +resource "azurerm_email_communication_service" "test" { + name = "acctest-CommunicationService-%[1]d" + resource_group_name = azurerm_resource_group.test.name + data_location = "United States" +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/communication/helper/domain_record.go b/internal/services/communication/helper/domain_record.go new file mode 100644 index 000000000000..22b54f6ec76b --- /dev/null +++ b/internal/services/communication/helper/domain_record.go @@ -0,0 +1,53 @@ +package helper + +import ( + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type DomainVerificationRecords struct { + Type string `tfschema:"type"` + Name string `tfschema:"name"` + Value string `tfschema:"value"` + TTL int `tfschema:"ttl"` +} + +func DomainVerificationRecordsCommonSchema() *pluginsdk.Schema { + return &pluginsdk.Schema{ + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "value": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "ttl": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + }, + }, + } +} + +func DomainVerificationRecordsToModel(record *domains.DnsRecord) []DomainVerificationRecords { + return []DomainVerificationRecords{{ + Name: pointer.From(record.Name), + Type: pointer.From(record.Type), + Value: pointer.From(record.Value), + TTL: int(pointer.From(record.Ttl)), + }} +} diff --git a/internal/services/communication/registration.go b/internal/services/communication/registration.go index a6fcf26f36ec..e5c2ba26e497 100644 --- a/internal/services/communication/registration.go +++ b/internal/services/communication/registration.go @@ -35,6 +35,7 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ + EmailCommunicationServiceDomainResource{}, EmailCommunicationServiceResource{}, CommunicationServiceResource{}, } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/README.md new file mode 100644 index 000000000000..08eddd35707b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains` Documentation + +The `domains` SDK allows for interaction with the Azure Resource Manager Service `communication` (API Version `2023-03-31`). + +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/communication/2023-03-31/domains" +``` + + +### Client Initialization + +```go +client := domains.NewDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DomainsClient.CancelVerification` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +payload := domains.VerificationParameter{ + // ... +} + + +if err := client.CancelVerificationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +payload := domains.DomainResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.Delete` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.Get` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +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: `DomainsClient.InitiateVerification` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +payload := domains.VerificationParameter{ + // ... +} + + +if err := client.InitiateVerificationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.ListByEmailServiceResource` + +```go +ctx := context.TODO() +id := domains.NewEmailServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue") + +// alternatively `client.ListByEmailServiceResource(ctx, id)` can be used to do batched pagination +items, err := client.ListByEmailServiceResourceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.Update` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "emailServiceValue", "domainValue") + +payload := domains.UpdateDomainRequestParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/client.go new file mode 100644 index 000000000000..2ce822d248f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/client.go @@ -0,0 +1,26 @@ +package domains + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainsClient struct { + Client *resourcemanager.Client +} + +func NewDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*DomainsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "domains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DomainsClient: %+v", err) + } + + return &DomainsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/constants.go new file mode 100644 index 000000000000..ba6b61ee3d2b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/constants.go @@ -0,0 +1,260 @@ +package domains + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainManagement string + +const ( + DomainManagementAzureManaged DomainManagement = "AzureManaged" + DomainManagementCustomerManaged DomainManagement = "CustomerManaged" + DomainManagementCustomerManagedInExchangeOnline DomainManagement = "CustomerManagedInExchangeOnline" +) + +func PossibleValuesForDomainManagement() []string { + return []string{ + string(DomainManagementAzureManaged), + string(DomainManagementCustomerManaged), + string(DomainManagementCustomerManagedInExchangeOnline), + } +} + +func (s *DomainManagement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainManagement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainManagement(input string) (*DomainManagement, error) { + vals := map[string]DomainManagement{ + "azuremanaged": DomainManagementAzureManaged, + "customermanaged": DomainManagementCustomerManaged, + "customermanagedinexchangeonline": DomainManagementCustomerManagedInExchangeOnline, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainManagement(input) + return &out, nil +} + +type DomainsProvisioningState string + +const ( + DomainsProvisioningStateCanceled DomainsProvisioningState = "Canceled" + DomainsProvisioningStateCreating DomainsProvisioningState = "Creating" + DomainsProvisioningStateDeleting DomainsProvisioningState = "Deleting" + DomainsProvisioningStateFailed DomainsProvisioningState = "Failed" + DomainsProvisioningStateMoving DomainsProvisioningState = "Moving" + DomainsProvisioningStateRunning DomainsProvisioningState = "Running" + DomainsProvisioningStateSucceeded DomainsProvisioningState = "Succeeded" + DomainsProvisioningStateUnknown DomainsProvisioningState = "Unknown" + DomainsProvisioningStateUpdating DomainsProvisioningState = "Updating" +) + +func PossibleValuesForDomainsProvisioningState() []string { + return []string{ + string(DomainsProvisioningStateCanceled), + string(DomainsProvisioningStateCreating), + string(DomainsProvisioningStateDeleting), + string(DomainsProvisioningStateFailed), + string(DomainsProvisioningStateMoving), + string(DomainsProvisioningStateRunning), + string(DomainsProvisioningStateSucceeded), + string(DomainsProvisioningStateUnknown), + string(DomainsProvisioningStateUpdating), + } +} + +func (s *DomainsProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainsProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainsProvisioningState(input string) (*DomainsProvisioningState, error) { + vals := map[string]DomainsProvisioningState{ + "canceled": DomainsProvisioningStateCanceled, + "creating": DomainsProvisioningStateCreating, + "deleting": DomainsProvisioningStateDeleting, + "failed": DomainsProvisioningStateFailed, + "moving": DomainsProvisioningStateMoving, + "running": DomainsProvisioningStateRunning, + "succeeded": DomainsProvisioningStateSucceeded, + "unknown": DomainsProvisioningStateUnknown, + "updating": DomainsProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainsProvisioningState(input) + return &out, nil +} + +type UserEngagementTracking string + +const ( + UserEngagementTrackingDisabled UserEngagementTracking = "Disabled" + UserEngagementTrackingEnabled UserEngagementTracking = "Enabled" +) + +func PossibleValuesForUserEngagementTracking() []string { + return []string{ + string(UserEngagementTrackingDisabled), + string(UserEngagementTrackingEnabled), + } +} + +func (s *UserEngagementTracking) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserEngagementTracking(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUserEngagementTracking(input string) (*UserEngagementTracking, error) { + vals := map[string]UserEngagementTracking{ + "disabled": UserEngagementTrackingDisabled, + "enabled": UserEngagementTrackingEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UserEngagementTracking(input) + return &out, nil +} + +type VerificationStatus string + +const ( + VerificationStatusCancellationRequested VerificationStatus = "CancellationRequested" + VerificationStatusNotStarted VerificationStatus = "NotStarted" + VerificationStatusVerificationFailed VerificationStatus = "VerificationFailed" + VerificationStatusVerificationInProgress VerificationStatus = "VerificationInProgress" + VerificationStatusVerificationRequested VerificationStatus = "VerificationRequested" + VerificationStatusVerified VerificationStatus = "Verified" +) + +func PossibleValuesForVerificationStatus() []string { + return []string{ + string(VerificationStatusCancellationRequested), + string(VerificationStatusNotStarted), + string(VerificationStatusVerificationFailed), + string(VerificationStatusVerificationInProgress), + string(VerificationStatusVerificationRequested), + string(VerificationStatusVerified), + } +} + +func (s *VerificationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerificationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVerificationStatus(input string) (*VerificationStatus, error) { + vals := map[string]VerificationStatus{ + "cancellationrequested": VerificationStatusCancellationRequested, + "notstarted": VerificationStatusNotStarted, + "verificationfailed": VerificationStatusVerificationFailed, + "verificationinprogress": VerificationStatusVerificationInProgress, + "verificationrequested": VerificationStatusVerificationRequested, + "verified": VerificationStatusVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VerificationStatus(input) + return &out, nil +} + +type VerificationType string + +const ( + VerificationTypeDKIM VerificationType = "DKIM" + VerificationTypeDKIMTwo VerificationType = "DKIM2" + VerificationTypeDMARC VerificationType = "DMARC" + VerificationTypeDomain VerificationType = "Domain" + VerificationTypeSPF VerificationType = "SPF" +) + +func PossibleValuesForVerificationType() []string { + return []string{ + string(VerificationTypeDKIM), + string(VerificationTypeDKIMTwo), + string(VerificationTypeDMARC), + string(VerificationTypeDomain), + string(VerificationTypeSPF), + } +} + +func (s *VerificationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerificationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVerificationType(input string) (*VerificationType, error) { + vals := map[string]VerificationType{ + "dkim": VerificationTypeDKIM, + "dkim2": VerificationTypeDKIMTwo, + "dmarc": VerificationTypeDMARC, + "domain": VerificationTypeDomain, + "spf": VerificationTypeSPF, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VerificationType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_domain.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_domain.go new file mode 100644 index 000000000000..412b08fcdf35 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_domain.go @@ -0,0 +1,139 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainId{}) +} + +var _ resourceids.ResourceId = &DomainId{} + +// DomainId is a struct representing the Resource ID for a Domain +type DomainId struct { + SubscriptionId string + ResourceGroupName string + EmailServiceName string + DomainName string +} + +// NewDomainID returns a new DomainId struct +func NewDomainID(subscriptionId string, resourceGroupName string, emailServiceName string, domainName string) DomainId { + return DomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + EmailServiceName: emailServiceName, + DomainName: domainName, + } +} + +// ParseDomainID parses 'input' into a DomainId +func ParseDomainID(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainIDInsensitively parses 'input' case-insensitively into a DomainId +// note: this method should only be used for API response data and not user input +func ParseDomainIDInsensitively(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.EmailServiceName, ok = input.Parsed["emailServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "emailServiceName", input) + } + + if id.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + return nil +} + +// ValidateDomainID checks that 'input' can be parsed as a Domain ID +func ValidateDomainID(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 := ParseDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain ID +func (id DomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Communication/emailServices/%s/domains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.EmailServiceName, id.DomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain ID +func (id DomainId) 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("staticMicrosoftCommunication", "Microsoft.Communication", "Microsoft.Communication"), + resourceids.StaticSegment("staticEmailServices", "emailServices", "emailServices"), + resourceids.UserSpecifiedSegment("emailServiceName", "emailServiceValue"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainValue"), + } +} + +// String returns a human-readable description of this Domain ID +func (id DomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Email Service Name: %q", id.EmailServiceName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + } + return fmt.Sprintf("Domain (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_emailservice.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_emailservice.go new file mode 100644 index 000000000000..130ee50d6e49 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/id_emailservice.go @@ -0,0 +1,130 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&EmailServiceId{}) +} + +var _ resourceids.ResourceId = &EmailServiceId{} + +// EmailServiceId is a struct representing the Resource ID for a Email Service +type EmailServiceId struct { + SubscriptionId string + ResourceGroupName string + EmailServiceName string +} + +// NewEmailServiceID returns a new EmailServiceId struct +func NewEmailServiceID(subscriptionId string, resourceGroupName string, emailServiceName string) EmailServiceId { + return EmailServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + EmailServiceName: emailServiceName, + } +} + +// ParseEmailServiceID parses 'input' into a EmailServiceId +func ParseEmailServiceID(input string) (*EmailServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&EmailServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EmailServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEmailServiceIDInsensitively parses 'input' case-insensitively into a EmailServiceId +// note: this method should only be used for API response data and not user input +func ParseEmailServiceIDInsensitively(input string) (*EmailServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&EmailServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EmailServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EmailServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.EmailServiceName, ok = input.Parsed["emailServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "emailServiceName", input) + } + + return nil +} + +// ValidateEmailServiceID checks that 'input' can be parsed as a Email Service ID +func ValidateEmailServiceID(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 := ParseEmailServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Email Service ID +func (id EmailServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Communication/emailServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.EmailServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Email Service ID +func (id EmailServiceId) 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("staticMicrosoftCommunication", "Microsoft.Communication", "Microsoft.Communication"), + resourceids.StaticSegment("staticEmailServices", "emailServices", "emailServices"), + resourceids.UserSpecifiedSegment("emailServiceName", "emailServiceValue"), + } +} + +// String returns a human-readable description of this Email Service ID +func (id EmailServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Email Service Name: %q", id.EmailServiceName), + } + return fmt.Sprintf("Email Service (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_cancelverification.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_cancelverification.go new file mode 100644 index 000000000000..5d135514ed14 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_cancelverification.go @@ -0,0 +1,73 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CancelVerificationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CancelVerification ... +func (c DomainsClient) CancelVerification(ctx context.Context, id DomainId, input VerificationParameter) (result CancelVerificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelVerification", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CancelVerificationThenPoll performs CancelVerification then polls until it's completed +func (c DomainsClient) CancelVerificationThenPoll(ctx context.Context, id DomainId, input VerificationParameter) error { + result, err := c.CancelVerification(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CancelVerification: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CancelVerification: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_createorupdate.go new file mode 100644 index 000000000000..dfddf73c38d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_createorupdate.go @@ -0,0 +1,75 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DomainResource +} + +// CreateOrUpdate ... +func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input DomainResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input DomainResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_delete.go new file mode 100644 index 000000000000..ee4c9195547e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_delete.go @@ -0,0 +1,71 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DomainsClient) Delete(ctx context.Context, id DomainId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DomainsClient) DeleteThenPoll(ctx context.Context, id DomainId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_get.go new file mode 100644 index 000000000000..5aaff4ba93e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_get.go @@ -0,0 +1,54 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainResource +} + +// Get ... +func (c DomainsClient) Get(ctx context.Context, id DomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_initiateverification.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_initiateverification.go new file mode 100644 index 000000000000..4f861945eb70 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_initiateverification.go @@ -0,0 +1,73 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitiateVerificationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InitiateVerification ... +func (c DomainsClient) InitiateVerification(ctx context.Context, id DomainId, input VerificationParameter) (result InitiateVerificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/initiateVerification", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// InitiateVerificationThenPoll performs InitiateVerification then polls until it's completed +func (c DomainsClient) InitiateVerificationThenPoll(ctx context.Context, id DomainId, input VerificationParameter) error { + result, err := c.InitiateVerification(ctx, id, input) + if err != nil { + return fmt.Errorf("performing InitiateVerification: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InitiateVerification: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_listbyemailserviceresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_listbyemailserviceresource.go new file mode 100644 index 000000000000..43d1a8a32a5a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_listbyemailserviceresource.go @@ -0,0 +1,92 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByEmailServiceResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DomainResource +} + +type ListByEmailServiceResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []DomainResource +} + +// ListByEmailServiceResource ... +func (c DomainsClient) ListByEmailServiceResource(ctx context.Context, id EmailServiceId) (result ListByEmailServiceResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DomainResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByEmailServiceResourceComplete retrieves all the results into a single object +func (c DomainsClient) ListByEmailServiceResourceComplete(ctx context.Context, id EmailServiceId) (ListByEmailServiceResourceCompleteResult, error) { + return c.ListByEmailServiceResourceCompleteMatchingPredicate(ctx, id, DomainResourceOperationPredicate{}) +} + +// ListByEmailServiceResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListByEmailServiceResourceCompleteMatchingPredicate(ctx context.Context, id EmailServiceId, predicate DomainResourceOperationPredicate) (result ListByEmailServiceResourceCompleteResult, err error) { + items := make([]DomainResource, 0) + + resp, err := c.ListByEmailServiceResource(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByEmailServiceResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_update.go new file mode 100644 index 000000000000..514572d1e24b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/method_update.go @@ -0,0 +1,75 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DomainResource +} + +// Update ... +func (c DomainsClient) Update(ctx context.Context, id DomainId, input UpdateDomainRequestParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c DomainsClient) UpdateThenPoll(ctx context.Context, id DomainId, input UpdateDomainRequestParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_dnsrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_dnsrecord.go new file mode 100644 index 000000000000..ccac3965f93c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_dnsrecord.go @@ -0,0 +1,11 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsRecord struct { + Name *string `json:"name,omitempty"` + Ttl *int64 `json:"ttl,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainproperties.go new file mode 100644 index 000000000000..02f1bdf6be4f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainproperties.go @@ -0,0 +1,15 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainProperties struct { + DataLocation *string `json:"dataLocation,omitempty"` + DomainManagement DomainManagement `json:"domainManagement"` + FromSenderDomain *string `json:"fromSenderDomain,omitempty"` + MailFromSenderDomain *string `json:"mailFromSenderDomain,omitempty"` + ProvisioningState *DomainsProvisioningState `json:"provisioningState,omitempty"` + UserEngagementTracking *UserEngagementTracking `json:"userEngagementTracking,omitempty"` + VerificationRecords *DomainPropertiesVerificationRecords `json:"verificationRecords,omitempty"` + VerificationStates *DomainPropertiesVerificationStates `json:"verificationStates,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationrecords.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationrecords.go new file mode 100644 index 000000000000..d43f27dfc663 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationrecords.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPropertiesVerificationRecords struct { + DKIM *DnsRecord `json:"DKIM,omitempty"` + DKIM2 *DnsRecord `json:"DKIM2,omitempty"` + DMARC *DnsRecord `json:"DMARC,omitempty"` + Domain *DnsRecord `json:"Domain,omitempty"` + SPF *DnsRecord `json:"SPF,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationstates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationstates.go new file mode 100644 index 000000000000..03d6eb7f1c56 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainpropertiesverificationstates.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPropertiesVerificationStates struct { + DKIM *VerificationStatusRecord `json:"DKIM,omitempty"` + DKIM2 *VerificationStatusRecord `json:"DKIM2,omitempty"` + DMARC *VerificationStatusRecord `json:"DMARC,omitempty"` + Domain *VerificationStatusRecord `json:"Domain,omitempty"` + SPF *VerificationStatusRecord `json:"SPF,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainresource.go new file mode 100644 index 000000000000..a1d7b1ee8aa5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_domainresource.go @@ -0,0 +1,18 @@ +package domains + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainResource struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DomainProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,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/communication/2023-03-31/domains/model_updatedomainproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainproperties.go new file mode 100644 index 000000000000..9859b9769d2f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainproperties.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDomainProperties struct { + UserEngagementTracking *UserEngagementTracking `json:"userEngagementTracking,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainrequestparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainrequestparameters.go new file mode 100644 index 000000000000..0b737758f108 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_updatedomainrequestparameters.go @@ -0,0 +1,9 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDomainRequestParameters struct { + Properties *UpdateDomainProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationparameter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationparameter.go new file mode 100644 index 000000000000..9f3ee31fd48d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationparameter.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerificationParameter struct { + VerificationType VerificationType `json:"verificationType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationstatusrecord.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationstatusrecord.go new file mode 100644 index 000000000000..50a1025ff7a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/model_verificationstatusrecord.go @@ -0,0 +1,9 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerificationStatusRecord struct { + ErrorCode *string `json:"errorCode,omitempty"` + Status *VerificationStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/predicates.go new file mode 100644 index 000000000000..4ce2a03ba6e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/predicates.go @@ -0,0 +1,32 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DomainResourceOperationPredicate) Matches(input DomainResource) bool { + + 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/communication/2023-03-31/domains/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/version.go new file mode 100644 index 000000000000..81aadaf4b3db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains/version.go @@ -0,0 +1,12 @@ +package domains + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-03-31" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/domains/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 57bd93353578..4726e42c7d78 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -320,6 +320,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/target github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/deployments github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices +github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/emailservices github.com/hashicorp/go-azure-sdk/resource-manager/compute/2021-07-01/skus github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-01/capacityreservationgroups diff --git a/website/docs/r/communication_service.html.markdown b/website/docs/r/communication_service.html.markdown index 9d5aae8f44a8..2f138f0db2ec 100644 --- a/website/docs/r/communication_service.html.markdown +++ b/website/docs/r/communication_service.html.markdown @@ -35,6 +35,8 @@ The following arguments are supported: --- +* `linked_domains` - (Optional) A list of email domain resource IDs + * `data_location` - (Optional) The location where the Communication service stores its data at rest. Possible values are `Africa`, `Asia Pacific`, `Australia`, `Brazil`, `Canada`, `Europe`, `France`, `Germany`, `India`, `Japan`, `Korea`, `Norway`, `Switzerland`, `UAE`, `UK` and `United States`. Defaults to `United States`. Changing this forces a new Communication Service to be created. * `tags` - (Optional) A mapping of tags which should be assigned to the Communication Service. diff --git a/website/docs/r/email_communication_service_domain.html.markdown b/website/docs/r/email_communication_service_domain.html.markdown new file mode 100644 index 000000000000..d646c6a6c645 --- /dev/null +++ b/website/docs/r/email_communication_service_domain.html.markdown @@ -0,0 +1,143 @@ +--- +subcategory: "Communication" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_email_communication_service_domain" +description: |- + Manages an Email Communication Service Domain. +--- + +# azurerm_email_communication_service_domain + +Manages an Email Communication Service Domain. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_email_communication_service" "example" { + name = "example-emailcommunicationservice" + resource_group_name = azurerm_resource_group.example.name + data_location = "United States" +} + +resource "azurerm_email_communication_service_domain" "example" { + name = "AzureManagedDomain" + resource_group_name = azurerm_resource_group.example.name + email_service_name = azurerm_email_communication_service.example.name + + domain_management = "AzureManaged" +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Email Communication Service resource. If `domain_management` is `AzureManaged`, the name must be `AzureManagedDomain`. Changing this forces a new Email Communication Service to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Email Communication Service should exist. Changing this forces a new Email Communication Service to be created. + +* `email_service_name` - (Required) The name of the Email Communication Service where the Domain belongs to. Changing this forces a new Email Communication Service to be created. + +* `domain_management` - (Required) Describes how a Domains resource is being managed. Possible values are `AzureManaged`, `CustomerManaged`, `CustomerManagedInExchangeOnline`. Changing this forces a new Email Communication Service to be created. + +--- + +* `user_engagement_tracking` - (Optional) Describes user engagement tracking is enabled or disabled. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Email Communication Service. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Email Communication Service. + +* `from_sender_domain` - P2 sender domain that is displayed to the email recipients [RFC 5322]. + +* `mail_from_sender_domain` - P1 sender domain that is present on the email envelope [RFC 5321]. + +* `verification_records` - (Optional) An `verification_records` block as defined below. + +An `verification_records` block supports the following arguments: + +* `domain` - (Optional) An `domain` block as defined below. + +* `dkim` - (Optional) An `dkim` block as defined below. + +* `dkim2` - (Optional) An `dkim2` block as defined below. + +* `dmarc` - (Optional) An `dmarc` block as defined below. + +* `spf` - (Optional) An `spf` block as defined below. + +An `domain` block supports the following arguments: + +* `name` - Name of the DNS record. + +* `ttl` - Represents an expiry time in seconds to represent how long this entry can be cached by the resolver, default = 3600sec. + +* `type` - Type of the DNS record. Example: TXT + +* `value` - Value of the DNS record. + +An `dkim` block supports the following arguments: + +* `name` - Name of the DNS record. + +* `ttl` - Represents an expiry time in seconds to represent how long this entry can be cached by the resolver, default = 3600sec. + +* `type` - Type of the DNS record. Example: TXT + +* `value` - Value of the DNS record. + +An `dkim2` block supports the following arguments: + +* `name` - Name of the DNS record. + +* `ttl` - Represents an expiry time in seconds to represent how long this entry can be cached by the resolver, default = 3600sec. + +* `type` - Type of the DNS record. Example: TXT + +* `value` - Value of the DNS record. + +An `dmarc` block supports the following arguments: + +* `name` - Name of the DNS record. + +* `ttl` - Represents an expiry time in seconds to represent how long this entry can be cached by the resolver, default = 3600sec. + +* `type` - Type of the DNS record. Example: TXT + +* `value` - Value of the DNS record. + +An `spf` block supports the following arguments: + +* `name` - Name of the DNS record. + +* `ttl` - Represents an expiry time in seconds to represent how long this entry can be cached by the resolver, default = 3600sec. + +* `type` - Type of the DNS record. Example: TXT + +* `value` - Value of the DNS record. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Email Communication Service Domain. +* `read` - (Defaults to 5 minutes) Used when retrieving the Email Communication Service Domain. +* `update` - (Defaults to 30 minutes) Used when updating the Email Communication Service Domain. +* `delete` - (Defaults to 30 minutes) Used when deleting the Email Communication Service Domain. + +## Import + +Communication Services can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_email_communication_service.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Communication/emailServices/emailCommunicationService1/domains/domain1 +``` From 0e99e0eb7770e1ea5b26335549678157ce11f212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:51:40 +0200 Subject: [PATCH 02/13] Update internal/services/communication/client/client.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- internal/services/communication/client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/communication/client/client.go b/internal/services/communication/client/client.go index cd37e5b1713c..ba377d7edd64 100644 --- a/internal/services/communication/client/client.go +++ b/internal/services/communication/client/client.go @@ -34,7 +34,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { domainsClient, err := domains.NewDomainsClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building Domain Service client: %+v", err) + return nil, fmt.Errorf("building Domais client: %+v", err) } o.Configure(domainsClient.Client, o.Authorizers.ResourceManager) From e0e3f9005f92eee7cfb27d7ec0c1f53223647444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:51:53 +0200 Subject: [PATCH 03/13] Update internal/services/communication/helper/domain_record.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- internal/services/communication/helper/domain_record.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/communication/helper/domain_record.go b/internal/services/communication/helper/domain_record.go index 22b54f6ec76b..7dfae17e0c44 100644 --- a/internal/services/communication/helper/domain_record.go +++ b/internal/services/communication/helper/domain_record.go @@ -10,7 +10,7 @@ type DomainVerificationRecords struct { Type string `tfschema:"type"` Name string `tfschema:"name"` Value string `tfschema:"value"` - TTL int `tfschema:"ttl"` + TTL int64 `tfschema:"ttl"` } func DomainVerificationRecordsCommonSchema() *pluginsdk.Schema { From e0c0b0ff0a3d433026c7907386be386fc9acfdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:01 +0200 Subject: [PATCH 04/13] Update internal/services/communication/email_service_domain_resource_test.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- .../communication/email_service_domain_resource_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go index d68fd374fa09..2f221cbc8da5 100644 --- a/internal/services/communication/email_service_domain_resource_test.go +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -93,14 +93,6 @@ func TestAccEmailServiceDomain_update(t *testing.T) { Config: r.complete(data, "true"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("user_engagement_tracking").HasValue("true"), - check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.domain.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.dkim.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.dkim2.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.spf.#").HasValue("1"), ), }, data.ImportStep(), From 7352ac0ba0c9e846f29449c8003b811a4d95a263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:07 +0200 Subject: [PATCH 05/13] Update internal/services/communication/email_service_domain_resource_test.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- .../email_service_domain_resource_test.go | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go index 2f221cbc8da5..b171ccbe4abb 100644 --- a/internal/services/communication/email_service_domain_resource_test.go +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -61,31 +61,6 @@ func TestAccEmailServiceDomain_update(t *testing.T) { Config: r.complete(data, "false"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("user_engagement_tracking").HasValue("false"), - check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.domain.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.domain.0.type").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.domain.0.name").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.domain.0.value").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.domain.0.ttl").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.dkim.0.type").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim.0.name").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim.0.value").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim.0.ttl").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim2.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.dkim2.0.type").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim2.0.name").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim2.0.value").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.dkim2.0.ttl").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.spf.#").HasValue("1"), - check.That(data.ResourceName).Key("verification_records.0.spf.0.type").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.spf.0.name").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.spf.0.value").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.0.spf.0.ttl").IsNotEmpty(), ), }, data.ImportStep(), From ede454537e8e06680b7880b765e629d1d33c7986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:14 +0200 Subject: [PATCH 06/13] Update internal/services/communication/email_service_domain_resource_test.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- .../communication/email_service_domain_resource_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go index b171ccbe4abb..af8b202c2af3 100644 --- a/internal/services/communication/email_service_domain_resource_test.go +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -28,9 +28,6 @@ func TestAccEmailServiceDomain_basic(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("mail_from_sender_domain").IsNotEmpty(), - check.That(data.ResourceName).Key("verification_records.#").HasValue("1"), ), }, data.ImportStep(), From 76a50dd383f123caf51923a40fce70ecd05400ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:28 +0200 Subject: [PATCH 07/13] Update internal/services/communication/email_service_domain_resource.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- .../services/communication/email_service_domain_resource.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/services/communication/email_service_domain_resource.go b/internal/services/communication/email_service_domain_resource.go index 83c4c47affb3..0e93a5025de5 100644 --- a/internal/services/communication/email_service_domain_resource.go +++ b/internal/services/communication/email_service_domain_resource.go @@ -253,10 +253,8 @@ func (EmailCommunicationServiceDomainResource) Read() sdk.ResourceFunc { } if props.UserEngagementTracking != nil { - state.UserEngagementTracking = false - if *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled { - state.UserEngagementTracking = true - } + state.UserEngagementTracking = *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled + } domainVerificationRecords := EmailDomainVerificationRecords{} From ef01457b841114e9d3024037d53618df18f1672c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:41 +0200 Subject: [PATCH 08/13] Update internal/services/communication/email_service_domain_resource.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- .../communication/email_service_domain_resource.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/services/communication/email_service_domain_resource.go b/internal/services/communication/email_service_domain_resource.go index 0e93a5025de5..4b4cec685bbf 100644 --- a/internal/services/communication/email_service_domain_resource.go +++ b/internal/services/communication/email_service_domain_resource.go @@ -244,13 +244,9 @@ func (EmailCommunicationServiceDomainResource) Read() sdk.ResourceFunc { if props := model.Properties; props != nil { state.DomainManagement = string(props.DomainManagement) - if props.FromSenderDomain != nil { - state.FromSenderDomain = pointer.From(props.FromSenderDomain) - } + state.FromSenderDomain = pointer.From(props.FromSenderDomain) - if props.MailFromSenderDomain != nil { - state.MailFromSenderDomain = pointer.From(props.MailFromSenderDomain) - } + state.MailFromSenderDomain = pointer.From(props.MailFromSenderDomain) if props.UserEngagementTracking != nil { state.UserEngagementTracking = *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled From ae6e9b8ceceefe86d4276f95820a0ecb04954c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 19:52:51 +0200 Subject: [PATCH 09/13] Update internal/services/communication/helper/domain_record.go Co-authored-by: jackofallops <11830746+jackofallops@users.noreply.github.com> --- internal/services/communication/helper/domain_record.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/communication/helper/domain_record.go b/internal/services/communication/helper/domain_record.go index 7dfae17e0c44..de89f424fcef 100644 --- a/internal/services/communication/helper/domain_record.go +++ b/internal/services/communication/helper/domain_record.go @@ -48,6 +48,6 @@ func DomainVerificationRecordsToModel(record *domains.DnsRecord) []DomainVerific Name: pointer.From(record.Name), Type: pointer.From(record.Type), Value: pointer.From(record.Value), - TTL: int(pointer.From(record.Ttl)), + TTL: pointer.From(record.Ttl), }} } From 9ca3017c15d185e837132562f9281b5ca1ac59c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 21:23:04 +0200 Subject: [PATCH 10/13] New Resource: `azurerm_email_communication_service_domain` --- .../communication_service_resource.go | 10 +++++ .../communication_service_resource_test.go | 8 ++-- .../email_service_domain_resource.go | 41 ++++++++++--------- .../email_service_domain_resource_test.go | 13 +++--- ...communication_service_domain.html.markdown | 6 +-- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/internal/services/communication/communication_service_resource.go b/internal/services/communication/communication_service_resource.go index 61b20a7cbf49..e4fbdbcfd593 100644 --- a/internal/services/communication/communication_service_resource.go +++ b/internal/services/communication/communication_service_resource.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/validate" @@ -84,6 +85,15 @@ func (CommunicationServiceResource) Arguments() map[string]*pluginsdk.Schema { }, false), }, + "linked_domains": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: domains.ValidateDomainID, + }, + }, + "tags": commonschema.Tags(), } } diff --git a/internal/services/communication/communication_service_resource_test.go b/internal/services/communication/communication_service_resource_test.go index 60f16440afd4..0b1e11c5137b 100644 --- a/internal/services/communication/communication_service_resource_test.go +++ b/internal/services/communication/communication_service_resource_test.go @@ -144,11 +144,9 @@ resource "azurerm_email_communication_service" "test" { } resource "azurerm_email_communication_service_domain" "test" { - name = azurerm_email_communication_service_domain.test.name - resource_group_name = azurerm_email_communication_service_domain.test.resource_group_name - email_service_name = azurerm_email_communication_service_domain.test.email_service_name - - domain_management = azurerm_email_communication_service_domain.test.domain_management + name = "AzureManagedDomain" + email_service_id = azurerm_email_communication_service.test.id + domain_management = "AzureManaged" } resource "azurerm_communication_service" "test" { diff --git a/internal/services/communication/email_service_domain_resource.go b/internal/services/communication/email_service_domain_resource.go index 4b4cec685bbf..99e43e14f8a7 100644 --- a/internal/services/communication/email_service_domain_resource.go +++ b/internal/services/communication/email_service_domain_resource.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" + "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/emailservices" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/helper" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) @@ -25,12 +25,11 @@ var _ sdk.ResourceWithUpdate = EmailCommunicationServiceDomainResource{} type EmailCommunicationServiceDomainResource struct{} type EmailCommunicationServiceDomainResourceModel struct { - Name string `tfschema:"name"` - ResourceGroupName string `tfschema:"resource_group_name"` - EMailServiceName string `tfschema:"email_service_name"` - DomainManagement string `tfschema:"domain_management"` - UserEngagementTracking bool `tfschema:"user_engagement_tracking"` - Tags map[string]string `tfschema:"tags"` + Name string `tfschema:"name"` + EMailServiceID string `tfschema:"email_service_id"` + DomainManagement string `tfschema:"domain_management"` + UserEngagementTrackingEnabled bool `tfschema:"user_engagement_tracking_enabled"` + Tags map[string]string `tfschema:"tags"` FromSenderDomain string `tfschema:"from_sender_domain"` MailFromSenderDomain string `tfschema:"mail_from_sender_domain"` @@ -53,13 +52,11 @@ func (EmailCommunicationServiceDomainResource) Arguments() map[string]*pluginsdk ForceNew: true, }, - "resource_group_name": commonschema.ResourceGroupName(), - - "email_service_name": { + "email_service_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.CommunicationServiceName, + ValidateFunc: domains.ValidateEmailServiceID, }, "domain_management": { @@ -69,10 +66,10 @@ func (EmailCommunicationServiceDomainResource) Arguments() map[string]*pluginsdk ValidateFunc: validation.StringInSlice(domains.PossibleValuesForDomainManagement(), false), }, - "user_engagement_tracking": { + "user_engagement_tracking_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Computed: true, + Default: false, }, "tags": commonschema.Tags(), @@ -127,7 +124,12 @@ func (r EmailCommunicationServiceDomainResource) Create() sdk.ResourceFunc { return err } - id := domains.NewDomainID(subscriptionId, model.ResourceGroupName, model.EMailServiceName, model.Name) + eMailServiceID, err := emailservices.ParseEmailServiceID(model.EMailServiceID) + if err != nil { + return fmt.Errorf("parsing parent email_service_id: %+v", err) + } + + id := domains.NewDomainID(subscriptionId, eMailServiceID.ResourceGroupName, eMailServiceID.EmailServiceName, model.Name) existing, err := client.Get(ctx, id) if err != nil && !response.WasNotFound(existing.HttpResponse) { @@ -142,7 +144,7 @@ func (r EmailCommunicationServiceDomainResource) Create() sdk.ResourceFunc { } properties.UserEngagementTracking = pointer.To(domains.UserEngagementTrackingDisabled) - if model.UserEngagementTracking { + if model.UserEngagementTrackingEnabled { properties.UserEngagementTracking = pointer.To(domains.UserEngagementTrackingEnabled) } @@ -190,9 +192,9 @@ func (r EmailCommunicationServiceDomainResource) Update() sdk.ResourceFunc { props := pointer.From(domain.Properties) - if metadata.ResourceData.HasChange("user_engagement_tracking") { + if metadata.ResourceData.HasChange("user_engagement_tracking_enabled") { userEngagementTracking := domains.UserEngagementTrackingDisabled - if model.UserEngagementTracking { + if model.UserEngagementTrackingEnabled { userEngagementTracking = domains.UserEngagementTrackingEnabled } @@ -237,8 +239,7 @@ func (EmailCommunicationServiceDomainResource) Read() sdk.ResourceFunc { } state.Name = id.DomainName - state.ResourceGroupName = id.ResourceGroupName - state.EMailServiceName = id.EmailServiceName + state.EMailServiceID = emailservices.NewEmailServiceID(id.SubscriptionId, id.ResourceGroupName, id.EmailServiceName).ID() if model := resp.Model; model != nil { if props := model.Properties; props != nil { @@ -249,7 +250,7 @@ func (EmailCommunicationServiceDomainResource) Read() sdk.ResourceFunc { state.MailFromSenderDomain = pointer.From(props.MailFromSenderDomain) if props.UserEngagementTracking != nil { - state.UserEngagementTracking = *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled + state.UserEngagementTrackingEnabled = *props.UserEngagementTracking == domains.UserEngagementTrackingEnabled } diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go index af8b202c2af3..6a7f508a4d69 100644 --- a/internal/services/communication/email_service_domain_resource_test.go +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -96,8 +96,7 @@ func (r EmailServiceDomainTestResource) basic(data acceptance.TestData) string { resource "azurerm_email_communication_service_domain" "test" { name = "AzureManagedDomain" - resource_group_name = azurerm_resource_group.test.name - email_service_name = azurerm_email_communication_service.test.name + email_service_id = azurerm_email_communication_service.test.id domain_management = "AzureManaged" } @@ -111,8 +110,7 @@ func (r EmailServiceDomainTestResource) requiresImport(data acceptance.TestData) resource "azurerm_email_communication_service_domain" "import" { name = azurerm_email_communication_service_domain.test.name - resource_group_name = azurerm_email_communication_service_domain.test.resource_group_name - email_service_name = azurerm_email_communication_service_domain.test.email_service_name + email_service_id = azurerm_email_communication_service_domain.test.email_service_id domain_management = azurerm_email_communication_service_domain.test.domain_management } @@ -125,11 +123,10 @@ func (r EmailServiceDomainTestResource) complete(data acceptance.TestData, userT resource "azurerm_email_communication_service_domain" "test" { name = "example.com" - resource_group_name = azurerm_resource_group.test.name - email_service_name = azurerm_email_communication_service.test.name + email_service_id = azurerm_email_communication_service.test.id - domain_management = "CustomerManaged" - user_engagement_tracking = %s + domain_management = "CustomerManaged" + user_engagement_tracking_enabled = %s tags = { env = "Test" diff --git a/website/docs/r/email_communication_service_domain.html.markdown b/website/docs/r/email_communication_service_domain.html.markdown index d646c6a6c645..962f716e0f53 100644 --- a/website/docs/r/email_communication_service_domain.html.markdown +++ b/website/docs/r/email_communication_service_domain.html.markdown @@ -39,15 +39,13 @@ The following arguments are supported: * `name` - (Required) The name of the Email Communication Service resource. If `domain_management` is `AzureManaged`, the name must be `AzureManagedDomain`. Changing this forces a new Email Communication Service to be created. -* `resource_group_name` - (Required) The name of the Resource Group where the Email Communication Service should exist. Changing this forces a new Email Communication Service to be created. - -* `email_service_name` - (Required) The name of the Email Communication Service where the Domain belongs to. Changing this forces a new Email Communication Service to be created. +* `email_service_id` - (Required) The resource ID of the Email Communication Service where the Domain belongs to. Changing this forces a new Email Communication Service to be created. * `domain_management` - (Required) Describes how a Domains resource is being managed. Possible values are `AzureManaged`, `CustomerManaged`, `CustomerManagedInExchangeOnline`. Changing this forces a new Email Communication Service to be created. --- -* `user_engagement_tracking` - (Optional) Describes user engagement tracking is enabled or disabled. +* `user_engagement_tracking_enabled` - (Optional) Describes user engagement tracking is enabled or disabled. Defaults to `false`. * `tags` - (Optional) A mapping of tags which should be assigned to the Email Communication Service. From dcba8832600ab0823c906bfd62911a8341b8010b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 3 Jun 2024 21:53:53 +0200 Subject: [PATCH 11/13] make terrafmt --- .../communication_service_resource_test.go | 6 +++--- .../email_service_domain_resource_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/services/communication/communication_service_resource_test.go b/internal/services/communication/communication_service_resource_test.go index 0b1e11c5137b..5f9680fc1381 100644 --- a/internal/services/communication/communication_service_resource_test.go +++ b/internal/services/communication/communication_service_resource_test.go @@ -144,9 +144,9 @@ resource "azurerm_email_communication_service" "test" { } resource "azurerm_email_communication_service_domain" "test" { - name = "AzureManagedDomain" - email_service_id = azurerm_email_communication_service.test.id - domain_management = "AzureManaged" + name = "AzureManagedDomain" + email_service_id = azurerm_email_communication_service.test.id + domain_management = "AzureManaged" } resource "azurerm_communication_service" "test" { diff --git a/internal/services/communication/email_service_domain_resource_test.go b/internal/services/communication/email_service_domain_resource_test.go index 6a7f508a4d69..5a7f7c8e5eab 100644 --- a/internal/services/communication/email_service_domain_resource_test.go +++ b/internal/services/communication/email_service_domain_resource_test.go @@ -95,8 +95,8 @@ func (r EmailServiceDomainTestResource) basic(data acceptance.TestData) string { %s resource "azurerm_email_communication_service_domain" "test" { - name = "AzureManagedDomain" - email_service_id = azurerm_email_communication_service.test.id + name = "AzureManagedDomain" + email_service_id = azurerm_email_communication_service.test.id domain_management = "AzureManaged" } @@ -109,8 +109,8 @@ func (r EmailServiceDomainTestResource) requiresImport(data acceptance.TestData) %s resource "azurerm_email_communication_service_domain" "import" { - name = azurerm_email_communication_service_domain.test.name - email_service_id = azurerm_email_communication_service_domain.test.email_service_id + name = azurerm_email_communication_service_domain.test.name + email_service_id = azurerm_email_communication_service_domain.test.email_service_id domain_management = azurerm_email_communication_service_domain.test.domain_management } @@ -122,8 +122,8 @@ func (r EmailServiceDomainTestResource) complete(data acceptance.TestData, userT %s resource "azurerm_email_communication_service_domain" "test" { - name = "example.com" - email_service_id = azurerm_email_communication_service.test.id + name = "example.com" + email_service_id = azurerm_email_communication_service.test.id domain_management = "CustomerManaged" user_engagement_tracking_enabled = %s From 118ccc1b386f34df3deedd1282620bac0880a620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Tue, 4 Jun 2024 08:58:07 +0200 Subject: [PATCH 12/13] added empty list test --- .../communication_service_resource_test.go | 33 +++++++++++++++++++ .../email_service_domain_resource.go | 1 - 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/internal/services/communication/communication_service_resource_test.go b/internal/services/communication/communication_service_resource_test.go index 5f9680fc1381..e81db1fdcfce 100644 --- a/internal/services/communication/communication_service_resource_test.go +++ b/internal/services/communication/communication_service_resource_test.go @@ -82,6 +82,22 @@ func TestAccCommunicationService_update(t *testing.T) { data.ImportStep(), { Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("linked_domains").DoesNotExist(), + ), + }, + data.ImportStep(), + }) +} + +func TestAccCommunicationService_linkedDomainsEmpty(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_communication_service", "test") + r := CommunicationServiceTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.emptyLinkedDomains(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -178,6 +194,23 @@ resource "azurerm_communication_service" "test" { `, r.template(data), data.RandomInteger) } +func (r CommunicationServiceTestResource) emptyLinkedDomains(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_communication_service" "test" { + name = "acctest-CommunicationService-%d" + resource_group_name = azurerm_resource_group.test.name + data_location = "United States" + linked_domains = [] + + tags = { + env = "Test2" + } +} +`, r.template(data), data.RandomInteger) +} + func (r CommunicationServiceTestResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/communication/email_service_domain_resource.go b/internal/services/communication/email_service_domain_resource.go index 99e43e14f8a7..6a782eb30bc9 100644 --- a/internal/services/communication/email_service_domain_resource.go +++ b/internal/services/communication/email_service_domain_resource.go @@ -69,7 +69,6 @@ func (EmailCommunicationServiceDomainResource) Arguments() map[string]*pluginsdk "user_engagement_tracking_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Default: false, }, "tags": commonschema.Tags(), From 49848569e797ce3f1f8f5988cb1c92d0d566bb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Wed, 5 Jun 2024 16:40:43 +0200 Subject: [PATCH 13/13] remove linked_domain property --- .../communication_service_resource.go | 19 +------- .../communication_service_resource_test.go | 48 +------------------ .../r/communication_service.html.markdown | 2 - 3 files changed, 2 insertions(+), 67 deletions(-) diff --git a/internal/services/communication/communication_service_resource.go b/internal/services/communication/communication_service_resource.go index e4fbdbcfd593..f7878b47676a 100644 --- a/internal/services/communication/communication_service_resource.go +++ b/internal/services/communication/communication_service_resource.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices" - "github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/communication/validate" @@ -30,7 +29,6 @@ type CommunicationServiceResourceModel struct { Name string `tfschema:"name"` ResourceGroupName string `tfschema:"resource_group_name"` DataLocation string `tfschema:"data_location"` - LinkedDomains []string `tfschema:"linked_domains"` Tags map[string]string `tfschema:"tags"` PrimaryConnectionString string `tfschema:"primary_connection_string"` @@ -85,15 +83,6 @@ func (CommunicationServiceResource) Arguments() map[string]*pluginsdk.Schema { }, false), }, - "linked_domains": { - Type: pluginsdk.TypeList, - Optional: true, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - ValidateFunc: domains.ValidateDomainID, - }, - }, - "tags": commonschema.Tags(), } } @@ -157,8 +146,7 @@ func (r CommunicationServiceResource) Create() sdk.ResourceFunc { // The location is always `global` from the Azure Portal Location: location.Normalize("global"), Properties: &communicationservices.CommunicationServiceProperties{ - DataLocation: model.DataLocation, - LinkedDomains: pointer.To(model.LinkedDomains), + DataLocation: model.DataLocation, }, Tags: pointer.To(model.Tags), } @@ -203,10 +191,6 @@ func (r CommunicationServiceResource) Update() sdk.ResourceFunc { props.DataLocation = model.DataLocation } - if metadata.ResourceData.HasChange("linked_domains") { - props.LinkedDomains = pointer.To(model.LinkedDomains) - } - existing.Model.Properties = &props if metadata.ResourceData.HasChange("tags") { @@ -255,7 +239,6 @@ func (CommunicationServiceResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if props := model.Properties; props != nil { state.DataLocation = props.DataLocation - state.LinkedDomains = pointer.From(props.LinkedDomains) } state.Tags = pointer.From(model.Tags) diff --git a/internal/services/communication/communication_service_resource_test.go b/internal/services/communication/communication_service_resource_test.go index e81db1fdcfce..bcb5284f8c6b 100644 --- a/internal/services/communication/communication_service_resource_test.go +++ b/internal/services/communication/communication_service_resource_test.go @@ -82,22 +82,6 @@ func TestAccCommunicationService_update(t *testing.T) { data.ImportStep(), { Config: r.update(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("linked_domains").DoesNotExist(), - ), - }, - data.ImportStep(), - }) -} - -func TestAccCommunicationService_linkedDomainsEmpty(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_communication_service", "test") - r := CommunicationServiceTestResource{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.emptyLinkedDomains(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -153,23 +137,10 @@ func (r CommunicationServiceTestResource) complete(data acceptance.TestData) str return fmt.Sprintf(` %s -resource "azurerm_email_communication_service" "test" { - name = "acctest-CommunicationService-%[2]d" - resource_group_name = azurerm_resource_group.test.name - data_location = "United States" -} - -resource "azurerm_email_communication_service_domain" "test" { - name = "AzureManagedDomain" - email_service_id = azurerm_email_communication_service.test.id - domain_management = "AzureManaged" -} - resource "azurerm_communication_service" "test" { - name = "acctest-CommunicationService-%[2]d" + name = "acctest-CommunicationService-%d" resource_group_name = azurerm_resource_group.test.name data_location = "United States" - linked_domains = [azurerm_email_communication_service_domain.test.id] tags = { env = "Test" @@ -194,23 +165,6 @@ resource "azurerm_communication_service" "test" { `, r.template(data), data.RandomInteger) } -func (r CommunicationServiceTestResource) emptyLinkedDomains(data acceptance.TestData) string { - return fmt.Sprintf(` -%s - -resource "azurerm_communication_service" "test" { - name = "acctest-CommunicationService-%d" - resource_group_name = azurerm_resource_group.test.name - data_location = "United States" - linked_domains = [] - - tags = { - env = "Test2" - } -} -`, r.template(data), data.RandomInteger) -} - func (r CommunicationServiceTestResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/communication_service.html.markdown b/website/docs/r/communication_service.html.markdown index 2f138f0db2ec..9d5aae8f44a8 100644 --- a/website/docs/r/communication_service.html.markdown +++ b/website/docs/r/communication_service.html.markdown @@ -35,8 +35,6 @@ The following arguments are supported: --- -* `linked_domains` - (Optional) A list of email domain resource IDs - * `data_location` - (Optional) The location where the Communication service stores its data at rest. Possible values are `Africa`, `Asia Pacific`, `Australia`, `Brazil`, `Canada`, `Europe`, `France`, `Germany`, `India`, `Japan`, `Korea`, `Norway`, `Switzerland`, `UAE`, `UK` and `United States`. Defaults to `United States`. Changing this forces a new Communication Service to be created. * `tags` - (Optional) A mapping of tags which should be assigned to the Communication Service.