From 425b3aaaf617a611024b4c818baf1bee496fae3c Mon Sep 17 00:00:00 2001 From: Charlie Conneely Date: Tue, 24 Dec 2024 18:03:35 +0000 Subject: [PATCH] converting from TypeList to TypeSet --- docs/resources/outbound_campaign.md | 2 +- docs/resources/outbound_messagingcampaign.md | 2 +- ...cloud_outbound_messagingcampaign_schema.go | 2 +- ...genesyscloud_outbound_messagingcampaign.go | 2 +- ...resource_genesyscloud_outbound_campaign.go | 2 +- ...e_genesyscloud_outbound_campaign_schema.go | 3 +- ...rce_genesyscloud_outbound_campaign_test.go | 394 +++++++++--------- 7 files changed, 209 insertions(+), 198 deletions(-) diff --git a/docs/resources/outbound_campaign.md b/docs/resources/outbound_campaign.md index 523b6baf4..880744d19 100644 --- a/docs/resources/outbound_campaign.md +++ b/docs/resources/outbound_campaign.md @@ -63,7 +63,7 @@ resource "genesyscloud_outbound_campaign" "campaign" { - `contact_list_filter_ids` (List of String) Filter to apply to the contact list before dialing. Currently a campaign can only have one filter applied. - `contact_sorts` (Block List) The order in which to sort contacts for dialing, based on up to four columns. (see [below for nested schema](#nestedblock--contact_sorts)) - `division_id` (String) The division this campaign belongs to. -- `dnc_list_ids` (List of String) DncLists for this Campaign to check before placing a call. +- `dnc_list_ids` (Set of String) DncLists for this Campaign to check before placing a call. - `dynamic_contact_queueing_settings` (Block List, Max: 1) Settings for dynamic queueing of contacts. (see [below for nested schema](#nestedblock--dynamic_contact_queueing_settings)) - `dynamic_line_balancing_settings` (Block List, Max: 1) Dynamic line balancing settings. (see [below for nested schema](#nestedblock--dynamic_line_balancing_settings)) - `edge_group_id` (String) The EdgeGroup that will place the calls. Required for all dialing modes except preview. diff --git a/docs/resources/outbound_messagingcampaign.md b/docs/resources/outbound_messagingcampaign.md index 1d29db769..cb8733d30 100644 --- a/docs/resources/outbound_messagingcampaign.md +++ b/docs/resources/outbound_messagingcampaign.md @@ -63,7 +63,7 @@ resource "genesyscloud_outbound_messagingcampaign" "example_outbound_messagingca - `contact_list_filter_ids` (List of String) The contact list filter to check before sending a message for this messaging campaign. - `contact_sorts` (Block List) The order in which to sort contacts for dialing, based on up to four columns. (see [below for nested schema](#nestedblock--contact_sorts)) - `division_id` (String) The division this entity belongs to. -- `dnc_list_ids` (List of String) The dnc lists to check before sending a message for this messaging campaign. +- `dnc_list_ids` (Set of String) The dnc lists to check before sending a message for this messaging campaign. - `dynamic_contact_queueing_settings` (Block List, Max: 1) Indicates (when true) that the campaign supports dynamic queueing of the contact list at the time of a request for contacts. **Warning**: Updating this field will cause the campaign to be destroyed and re-created. (see [below for nested schema](#nestedblock--dynamic_contact_queueing_settings)) - `email_config` (Block List, Max: 1) Configuration for this messaging campaign to send Email messages. (see [below for nested schema](#nestedblock--email_config)) diff --git a/genesyscloud/outbound/genesyscloud_outbound_messagingcampaign_schema.go b/genesyscloud/outbound/genesyscloud_outbound_messagingcampaign_schema.go index 761a9cdd3..cc5834afe 100644 --- a/genesyscloud/outbound/genesyscloud_outbound_messagingcampaign_schema.go +++ b/genesyscloud/outbound/genesyscloud_outbound_messagingcampaign_schema.go @@ -175,7 +175,7 @@ func ResourceOutboundMessagingCampaign() *schema.Resource { `dnc_list_ids`: { Description: `The dnc lists to check before sending a message for this messaging campaign.`, Optional: true, - Type: schema.TypeList, + Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, }, `campaign_status`: { diff --git a/genesyscloud/outbound/resource_genesyscloud_outbound_messagingcampaign.go b/genesyscloud/outbound/resource_genesyscloud_outbound_messagingcampaign.go index f516767e2..f1f936a17 100644 --- a/genesyscloud/outbound/resource_genesyscloud_outbound_messagingcampaign.go +++ b/genesyscloud/outbound/resource_genesyscloud_outbound_messagingcampaign.go @@ -231,7 +231,7 @@ func readOutboundMessagingcampaign(ctx context.Context, d *schema.ResourceData, } if sdkMessagingCampaign.DncLists != nil { - _ = d.Set("dnc_list_ids", util.SdkDomainEntityRefArrToList(*sdkMessagingCampaign.DncLists)) + _ = d.Set("dnc_list_ids", util.SdkDomainEntityRefArrToSet(*sdkMessagingCampaign.DncLists)) } log.Printf("Read Outbound Messaging Campaign %s", d.Id()) diff --git a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign.go b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign.go index 448be41ad..4b1243d2e 100644 --- a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign.go +++ b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign.go @@ -126,7 +126,7 @@ func readOutboundCampaign(ctx context.Context, d *schema.ResourceData, meta inte resourcedata.SetNillableValue(d, "abandon_rate", campaign.AbandonRate) resourcedata.SetNillableValue(d, "max_calls_per_agent", campaign.MaxCallsPerAgent) if campaign.DncLists != nil { - _ = d.Set("dnc_list_ids", util.SdkDomainEntityRefArrToList(*campaign.DncLists)) + _ = d.Set("dnc_list_ids", util.SdkDomainEntityRefArrToSet(*campaign.DncLists)) } resourcedata.SetNillableReference(d, "callable_time_set_id", campaign.CallableTimeSet) resourcedata.SetNillableReference(d, "call_analysis_response_set_id", campaign.CallAnalysisResponseSet) diff --git a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_schema.go b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_schema.go index 3fc1dbf9a..9162ad44b 100644 --- a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_schema.go +++ b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_schema.go @@ -18,6 +18,7 @@ resource_genesycloud_outbound_campaign_schema.go holds four functions within it: 3. The datasource schema definitions for the outbound_campaign datasource. 4. The resource exporter configuration for the outbound_campaign exporter. */ + const ResourceType = "genesyscloud_outbound_campaign" // SetRegistrar registers all of the resources, datasources and exporters in the package @@ -117,7 +118,7 @@ func ResourceOutboundCampaign() *schema.Resource { `dnc_list_ids`: { Description: `DncLists for this Campaign to check before placing a call.`, Optional: true, - Type: schema.TypeList, + Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, }, `callable_time_set_id`: { diff --git a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_test.go b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_test.go index 0f2d4d612..f26fff04b 100644 --- a/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_test.go +++ b/genesyscloud/outbound_campaign/resource_genesyscloud_outbound_campaign_test.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" "terraform-provider-genesyscloud/genesyscloud/architect_flow" - location "terraform-provider-genesyscloud/genesyscloud/location" + "terraform-provider-genesyscloud/genesyscloud/location" "terraform-provider-genesyscloud/genesyscloud/outbound" obDnclist "terraform-provider-genesyscloud/genesyscloud/outbound_dnclist" "terraform-provider-genesyscloud/genesyscloud/provider" @@ -67,6 +67,8 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { callerAddressUpdated = "+353371112111" divResourceLabel = "test-division" divName = "terraform-" + uuid.NewString() + + resourcePath = ResourceType + "." + resourceLabel ) emergencyNumber := "+13178793428" @@ -220,8 +222,8 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { []string{"genesyscloud_outbound_dnclist." + dncListResourceLabel + ".id"}, []string{"genesyscloud_outbound_ruleset." + ruleSetResourceLabel + ".id"}, []string{"genesyscloud_outbound_contactlistfilter." + clfResourceLabel + ".id"}, - []string{""}, - strconv.Quote("false"), + nil, + util.FalseValue, // auto_answer generatePhoneColumnNoTypeBlock("Cell"), outbound.GenerateOutboundMessagingCampaignContactSort( contactSortFieldName, @@ -231,37 +233,37 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { generateDynamicContactQueueingSettingsBlock(util.TrueValue), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "outbound_line_count", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", "off"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "abandon_rate", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "preview_time_out_seconds", "0"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "always_running", util.FalseValue), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "no_answer_timeout", "40"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "priority", "4"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.field_name", contactSortFieldName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.direction", contactSortDirection), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.numeric", contactSortNumeric), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dynamic_contact_queueing_settings.0.sort", util.TrueValue), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "outbound_line_count", "1"), + resource.TestCheckResourceAttr(resourcePath, "campaign_status", "off"), + resource.TestCheckResourceAttr(resourcePath, "abandon_rate", "1"), + resource.TestCheckResourceAttr(resourcePath, "preview_time_out_seconds", "0"), + resource.TestCheckResourceAttr(resourcePath, "always_running", util.FalseValue), + resource.TestCheckResourceAttr(resourcePath, "no_answer_timeout", "40"), + resource.TestCheckResourceAttr(resourcePath, "priority", "4"), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.field_name", contactSortFieldName), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.direction", contactSortDirection), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.numeric", contactSortNumeric), + resource.TestCheckResourceAttr(resourcePath, "dynamic_contact_queueing_settings.0.sort", util.TrueValue), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "callable_time_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "callable_time_set_id", "genesyscloud_outbound_callabletimeset."+callableTimeSetId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_filter_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_filter_ids.0", "genesyscloud_outbound_contactlistfilter."+clfResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "dnc_list_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "dnc_list_ids.0", "genesyscloud_outbound_dnclist."+dncListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "rule_set_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "rule_set_ids.0", "genesyscloud_outbound_ruleset."+ruleSetResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - provider.TestDefaultHomeDivision("genesyscloud_outbound_campaign."+resourceLabel), + provider.TestDefaultHomeDivision(resourcePath), ), }, { @@ -291,8 +293,8 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { []string{"genesyscloud_outbound_dnclist." + dncListResourceLabel + ".id"}, []string{"genesyscloud_outbound_ruleset." + ruleSetResourceLabel + ".id"}, []string{"genesyscloud_outbound_contactlistfilter." + clfResourceLabel + ".id"}, - []string{"en-us"}, - strconv.Quote("false"), + []string{strconv.Quote("en-us")}, + util.FalseValue, // auto_answer generatePhoneColumnNoTypeBlock("Cell"), outbound.GenerateOutboundMessagingCampaignContactSort( contactSortFieldName, @@ -302,37 +304,37 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { generateDynamicContactQueueingSettingsBlock(util.FalseValue), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "outbound_line_count", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", "off"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "abandon_rate", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "preview_time_out_seconds", "0"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "always_running", util.FalseValue), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "no_answer_timeout", "40"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "priority", "4"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.field_name", contactSortFieldName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.direction", contactSortDirection), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.numeric", contactSortNumeric), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dynamic_contact_queueing_settings.0.sort", util.FalseValue), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "outbound_line_count", "1"), + resource.TestCheckResourceAttr(resourcePath, "campaign_status", "off"), + resource.TestCheckResourceAttr(resourcePath, "abandon_rate", "1"), + resource.TestCheckResourceAttr(resourcePath, "preview_time_out_seconds", "0"), + resource.TestCheckResourceAttr(resourcePath, "always_running", util.FalseValue), + resource.TestCheckResourceAttr(resourcePath, "no_answer_timeout", "40"), + resource.TestCheckResourceAttr(resourcePath, "priority", "4"), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.field_name", contactSortFieldName), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.direction", contactSortDirection), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.numeric", contactSortNumeric), + resource.TestCheckResourceAttr(resourcePath, "dynamic_contact_queueing_settings.0.sort", util.FalseValue), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "callable_time_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "callable_time_set_id", "genesyscloud_outbound_callabletimeset."+callableTimeSetId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_filter_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_filter_ids.0", "genesyscloud_outbound_contactlistfilter."+clfResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "dnc_list_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "dnc_list_ids.0", "genesyscloud_outbound_dnclist."+dncListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "rule_set_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "rule_set_ids.0", "genesyscloud_outbound_ruleset."+ruleSetResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - provider.TestDefaultHomeDivision("genesyscloud_outbound_campaign."+resourceLabel), + provider.TestDefaultHomeDivision(resourcePath), ), }, { @@ -362,8 +364,8 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { []string{"genesyscloud_outbound_dnclist." + dncListResourceLabel + ".id"}, []string{"genesyscloud_outbound_ruleset." + ruleSetResourceLabel + ".id"}, []string{"genesyscloud_outbound_contactlistfilter." + clfResourceLabel + ".id"}, - []string{}, - strconv.Quote("false"), + nil, + util.FalseValue, // auto_answer generatePhoneColumnNoTypeBlock("Cell"), outbound.GenerateOutboundMessagingCampaignContactSort( contactSortFieldName, @@ -373,41 +375,41 @@ func TestAccResourceOutboundCampaignBasic(t *testing.T) { generateDynamicContactQueueingSettingsBlock(util.FalseValue), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", nameUpdated), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerNameUpdated), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddressUpdated), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "outbound_line_count", "2"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "abandon_rate", "2"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "preview_time_out_seconds", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "always_running", util.TrueValue), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "no_answer_timeout", "30"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "priority", "3"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.field_name", contactSortFieldName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.direction", contactSortDirection), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.numeric", contactSortNumeric), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dynamic_contact_queueing_settings.0.sort", "false"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", nameUpdated), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerNameUpdated), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddressUpdated), + resource.TestCheckResourceAttr(resourcePath, "outbound_line_count", "2"), + resource.TestCheckResourceAttr(resourcePath, "abandon_rate", "2"), + resource.TestCheckResourceAttr(resourcePath, "preview_time_out_seconds", "1"), + resource.TestCheckResourceAttr(resourcePath, "always_running", util.TrueValue), + resource.TestCheckResourceAttr(resourcePath, "no_answer_timeout", "30"), + resource.TestCheckResourceAttr(resourcePath, "priority", "3"), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.field_name", contactSortFieldName), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.direction", contactSortDirection), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.numeric", contactSortNumeric), + resource.TestCheckResourceAttr(resourcePath, "dynamic_contact_queueing_settings.0.sort", "false"), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "callable_time_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "callable_time_set_id", "genesyscloud_outbound_callabletimeset."+callableTimeSetId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_filter_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_filter_ids.0", "genesyscloud_outbound_contactlistfilter."+clfResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "dnc_list_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "dnc_list_ids.0", "genesyscloud_outbound_dnclist."+dncListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "rule_set_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "rule_set_ids.0", "genesyscloud_outbound_ruleset."+ruleSetResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - provider.TestDefaultHomeDivision("genesyscloud_outbound_campaign."+resourceLabel), + provider.TestDefaultHomeDivision(resourcePath), ), }, { // Import/Read - ResourceName: "genesyscloud_outbound_campaign." + resourceLabel, + ResourceName: resourcePath, ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"queue_id"}, @@ -433,6 +435,8 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { locationResourceLabel = "location" divResourceLabel = "test-division" divName = "terraform-" + uuid.NewString() + + resourcePath = ResourceType + "." + resourceLabel ) emergencyNumber := "+13178793429" @@ -522,7 +526,7 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { Steps: []resource.TestStep{ { Config: referencedResources + fmt.Sprintf(` - resource "genesyscloud_outbound_campaign" "%s" { + resource "%s" "%s" { name = "%s" dialing_mode = "agentless" caller_name = "Test Name" @@ -536,15 +540,15 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { column_name = "Cell" } } - `, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), + `, ResourceType, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", "off"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "campaign_status", "off"), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), // Add contacts to the contact list (because we have access to the state and can pull out the contactlist ID to pass to the API) addContactsToContactList, @@ -552,7 +556,7 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { }, { Config: referencedResources + fmt.Sprintf(` - resource "genesyscloud_outbound_campaign" "%s" { + resource "%s" "%s" { name = "%s" dialing_mode = "agentless" caller_name = "Test Name" @@ -566,21 +570,21 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { column_name = "Cell" } } - `, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), + `, ResourceType, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - util.VerifyAttributeInArrayOfPotentialValues("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", []string{"on", "complete"}), + util.VerifyAttributeInArrayOfPotentialValues(resourcePath, "campaign_status", []string{"on", "complete"}), ), }, { Config: referencedResources + fmt.Sprintf(` - resource "genesyscloud_outbound_campaign" "%s" { + resource "%s" "%s" { name = "%s" dialing_mode = "agentless" caller_name = "Test Name" @@ -594,21 +598,21 @@ func TestAccResourceOutboundCampaignCampaignStatus(t *testing.T) { column_name = "Cell" } } - `, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), + `, ResourceType, resourceLabel, name, contactListResourceLabel, siteId, carResourceLabel), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - util.VerifyAttributeInArrayOfPotentialValues("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", []string{"off", "complete"}), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + util.VerifyAttributeInArrayOfPotentialValues(resourcePath, "campaign_status", []string{"off", "complete"}), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), ), }, { // Import/Read - ResourceName: "genesyscloud_outbound_campaign." + resourceLabel, + ResourceName: resourcePath, ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"campaign_status"}, @@ -633,6 +637,8 @@ func TestAccResourceOutboundCampaignStatusOn(t *testing.T) { locationResourceLabel = "location" divResourceLabel = "test-outbound-campaign-division" divName = "terraform-" + uuid.NewString() + + resourcePath = ResourceType + "." + resourceLabel ) emergencyNumber := "+13178793430" @@ -692,14 +698,14 @@ func TestAccResourceOutboundCampaignStatusOn(t *testing.T) { divResourceLabel, ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "site_id", + resource.TestCheckResourceAttrPair(resourcePath, "site_id", "genesyscloud_telephony_providers_edges_site."+siteId, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - util.VerifyAttributeInArrayOfPotentialValues("genesyscloud_outbound_campaign."+resourceLabel, "campaign_status", []string{"on", "complete"}), + util.VerifyAttributeInArrayOfPotentialValues(resourcePath, "campaign_status", []string{"on", "complete"}), func(s *terraform.State) error { time.Sleep(300 * time.Second) // Takes approx. 300 seconds for campaign to be completed / stopped return nil @@ -708,7 +714,7 @@ func TestAccResourceOutboundCampaignStatusOn(t *testing.T) { }, { // Import/Read - ResourceName: "genesyscloud_outbound_campaign." + resourceLabel, + ResourceName: resourcePath, ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"campaign_status"}, @@ -737,6 +743,8 @@ func TestAccResourceOutboundCampaignWithScriptId(t *testing.T) { contactSortFieldName = "zipcode" contactSortDirection = "ASC" contactSortNumeric = util.FalseValue + + resourcePath = ResourceType + "." + resourceLabel ) scriptId, err := getPublishedScriptId() @@ -814,19 +822,19 @@ func TestAccResourceOutboundCampaignWithScriptId(t *testing.T) { []string{}, []string{}, []string{}, - strconv.Quote("false"), + util.FalseValue, generatePhoneColumnNoTypeBlock("Cell"), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "script_id", scriptId), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "script_id", scriptId), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "queue_id", + resource.TestCheckResourceAttrPair(resourcePath, "queue_id", "genesyscloud_routing_queue."+queueResourceLabel, "id"), ), }, @@ -859,7 +867,7 @@ func TestAccResourceOutboundCampaignWithScriptId(t *testing.T) { []string{"genesyscloud_outbound_ruleset." + ruleSetResourceLabel + ".id"}, []string{"genesyscloud_outbound_contactlistfilter." + clfResourceLabel + ".id"}, []string{strconv.Quote("language")}, - strconv.Quote("false"), + util.FalseValue, // auto_answer generatePhoneColumnNoTypeBlock("Cell"), outbound.GenerateOutboundMessagingCampaignContactSort( contactSortFieldName, @@ -868,44 +876,44 @@ func TestAccResourceOutboundCampaignWithScriptId(t *testing.T) { ), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "abandon_rate", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "outbound_line_count", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "skip_preview_disabled", util.FalseValue), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "preview_time_out_seconds", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "always_running", util.FalseValue), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.field_name", contactSortFieldName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.direction", contactSortDirection), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "contact_sorts.0.numeric", contactSortNumeric), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "no_answer_timeout", "3"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "priority", "2"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "script_id", scriptId), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "skill_columns.0", "language"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "auto_answer", "false"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_filter_ids.0", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "abandon_rate", "1"), + resource.TestCheckResourceAttr(resourcePath, "outbound_line_count", "1"), + resource.TestCheckResourceAttr(resourcePath, "skip_preview_disabled", util.FalseValue), + resource.TestCheckResourceAttr(resourcePath, "preview_time_out_seconds", "1"), + resource.TestCheckResourceAttr(resourcePath, "always_running", util.FalseValue), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.field_name", contactSortFieldName), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.direction", contactSortDirection), + resource.TestCheckResourceAttr(resourcePath, "contact_sorts.0.numeric", contactSortNumeric), + resource.TestCheckResourceAttr(resourcePath, "no_answer_timeout", "3"), + resource.TestCheckResourceAttr(resourcePath, "priority", "2"), + resource.TestCheckResourceAttr(resourcePath, "script_id", scriptId), + resource.TestCheckResourceAttr(resourcePath, "skill_columns.0", "language"), + resource.TestCheckResourceAttr(resourcePath, "auto_answer", "false"), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_filter_ids.0", "genesyscloud_outbound_contactlistfilter."+clfResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "dnc_list_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "dnc_list_ids.0", "genesyscloud_outbound_dnclist."+dncListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "queue_id", + resource.TestCheckResourceAttrPair(resourcePath, "queue_id", "genesyscloud_routing_queue."+queueResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "call_analysis_response_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "call_analysis_response_set_id", "genesyscloud_outbound_callanalysisresponseset."+carResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "rule_set_ids.0", + resource.TestCheckResourceAttrPair(resourcePath, "rule_set_ids.0", "genesyscloud_outbound_ruleset."+ruleSetResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "callable_time_set_id", + resource.TestCheckResourceAttrPair(resourcePath, "callable_time_set_id", "genesyscloud_outbound_callabletimeset."+callableTimeSetResourceLabel, "id"), - provider.TestDefaultHomeDivision("genesyscloud_outbound_campaign."+resourceLabel), + provider.TestDefaultHomeDivision(resourcePath), ), }, { // Import/Read - ResourceName: "genesyscloud_outbound_campaign." + resourceLabel, + ResourceName: resourcePath, ImportState: true, ImportStateVerify: true, }, @@ -927,6 +935,8 @@ func TestAccResourceOutboundCampaignPower(t *testing.T) { locationResourceLabel = "location" siteId = "site" carResourceLabel = "car" + + resourcePath = ResourceType + "." + resourceLabel ) emergencyNumber := "+13178793431" @@ -995,20 +1005,20 @@ func TestAccResourceOutboundCampaignPower(t *testing.T) { generateDynamicLineBalancingSettingsBlock(util.FalseValue, "0"), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "max_calls_per_agent", "1"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "outbound_line_count", "1"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "max_calls_per_agent", "1"), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttr(resourcePath, "outbound_line_count", "1"), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "queue_id", + resource.TestCheckResourceAttrPair(resourcePath, "queue_id", "genesyscloud_routing_queue."+queueResourceLabel, "id"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, + resource.TestCheckResourceAttr(resourcePath, "dynamic_line_balancing_settings.0.enabled", "false"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, + resource.TestCheckResourceAttr(resourcePath, "dynamic_line_balancing_settings.0.relative_weight", "0"), ), }, @@ -1046,27 +1056,27 @@ func TestAccResourceOutboundCampaignPower(t *testing.T) { generateDynamicLineBalancingSettingsBlock(util.TrueValue, "15"), ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "name", name), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "dialing_mode", dialingMode), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_name", callerName), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "caller_address", callerAddress), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "max_calls_per_agent", "2"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, "phone_columns.0.column_name", "Cell"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "contact_list_id", + resource.TestCheckResourceAttr(resourcePath, "name", name), + resource.TestCheckResourceAttr(resourcePath, "dialing_mode", dialingMode), + resource.TestCheckResourceAttr(resourcePath, "caller_name", callerName), + resource.TestCheckResourceAttr(resourcePath, "caller_address", callerAddress), + resource.TestCheckResourceAttr(resourcePath, "max_calls_per_agent", "2"), + resource.TestCheckResourceAttr(resourcePath, "phone_columns.0.column_name", "Cell"), + resource.TestCheckResourceAttrPair(resourcePath, "contact_list_id", "genesyscloud_outbound_contact_list."+contactListResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "queue_id", + resource.TestCheckResourceAttrPair(resourcePath, "queue_id", "genesyscloud_routing_queue."+queueResourceLabel, "id"), - resource.TestCheckResourceAttrPair("genesyscloud_outbound_campaign."+resourceLabel, "queue_id", + resource.TestCheckResourceAttrPair(resourcePath, "queue_id", "genesyscloud_routing_queue."+queueResourceLabel, "id"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, + resource.TestCheckResourceAttr(resourcePath, "dynamic_line_balancing_settings.0.enabled", "true"), - resource.TestCheckResourceAttr("genesyscloud_outbound_campaign."+resourceLabel, + resource.TestCheckResourceAttr(resourcePath, "dynamic_line_balancing_settings.0.relative_weight", "15"), ), }, { // Import/Read - ResourceName: "genesyscloud_outbound_campaign." + resourceLabel, + ResourceName: resourcePath, ImportState: true, ImportStateVerify: true, }, @@ -1132,30 +1142,30 @@ func addContactsToContactList(state *terraform.State) error { } func generateOutboundCampaign( - resourceLabel string, - name string, - dialingMode string, // required - callerName string, // required - callerAddress string, // required - contactListId string, // required - campaignStatus string, - divisionId string, - scriptId string, - queueId string, - siteId string, - abandonRate string, - maxCallsPerAgent string, - callableTimeSetId string, - callAnalysisResponseSetId string, - outboundLineCount string, - skipPreviewDisabled string, - previewTimeOutSeconds string, - alwaysRunning string, - noAnswerTimeout string, + resourceLabel, + name, + dialingMode, // required + callerName, // required + callerAddress, // required + contactListId, // required + campaignStatus, + divisionId, + scriptId, + queueId, + siteId, + abandonRate, + maxCallsPerAgent, + callableTimeSetId, + callAnalysisResponseSetId, + outboundLineCount, + skipPreviewDisabled, + previewTimeOutSeconds, + alwaysRunning, + noAnswerTimeout, priority string, - dncListIds []string, - ruleSetIds []string, - contactListFilterIds []string, + dncListIds, + ruleSetIds, + contactListFilterIds, skillColumns []string, autoAnswer string, nestedBlocks ...string, @@ -1203,7 +1213,7 @@ func generateDynamicContactQueueingSettingsBlock(sort string) string { `, sort) } -func generateDynamicLineBalancingSettingsBlock(enabled string, weight string) string { +func generateDynamicLineBalancingSettingsBlock(enabled, weight string) string { return fmt.Sprintf(` dynamic_line_balancing_settings { enabled = %s @@ -1226,7 +1236,7 @@ func getPublishedScriptId() (string, error) { func testVerifyOutboundCampaignDestroyed(state *terraform.State) error { outboundAPI := platformclientv2.NewOutboundApi() for _, rs := range state.RootModule().Resources { - if rs.Type != "genesyscloud_outbound_campaign" { + if rs.Type != ResourceType { continue } campaign, resp, err := outboundAPI.GetOutboundCampaign(rs.Primary.ID)