diff --git a/genesyscloud/data_source_genesyscloud_routing_language.go b/genesyscloud/data_source_genesyscloud_routing_language.go deleted file mode 100644 index 729080fc8..000000000 --- a/genesyscloud/data_source_genesyscloud_routing_language.go +++ /dev/null @@ -1,59 +0,0 @@ -package genesyscloud - -import ( - "context" - "fmt" - "terraform-provider-genesyscloud/genesyscloud/provider" - "terraform-provider-genesyscloud/genesyscloud/util" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/mypurecloud/platform-client-sdk-go/v133/platformclientv2" -) - -func dataSourceRoutingLanguage() *schema.Resource { - return &schema.Resource{ - Description: "Data source for Genesys Cloud Routing Languages. Select a language by name.", - ReadContext: provider.ReadWithPooledClient(dataSourceRoutingLanguageRead), - Schema: map[string]*schema.Schema{ - "name": { - Description: "Language name.", - Type: schema.TypeString, - Required: true, - }, - }, - } -} - -func dataSourceRoutingLanguageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - sdkConfig := m.(*provider.ProviderMeta).ClientConfig - routingAPI := platformclientv2.NewRoutingApiWithConfig(sdkConfig) - - name := d.Get("name").(string) - - // Find first non-deleted language by name. Retry in case new language is not yet indexed by search - return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { - for pageNum := 1; ; pageNum++ { - const pageSize = 50 - languages, resp, getErr := routingAPI.GetRoutingLanguages(pageSize, pageNum, "", name, nil) - if getErr != nil { - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Error requesting language %s | error: %s", name, getErr), resp)) - } - - if languages.Entities == nil || len(*languages.Entities) == 0 { - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("No routing languages found with name %s", name), resp)) - } - - for _, language := range *languages.Entities { - if language.Name != nil && *language.Name == name && - language.State != nil && *language.State != "deleted" { - d.SetId(*language.Id) - return nil - } - } - } - }) -} diff --git a/genesyscloud/recording_media_retention_policy/data_source_genesyscloud_recording_media_retention_policy_test.go b/genesyscloud/recording_media_retention_policy/data_source_genesyscloud_recording_media_retention_policy_test.go index 99caa46b7..ab04c8d80 100644 --- a/genesyscloud/recording_media_retention_policy/data_source_genesyscloud_recording_media_retention_policy_test.go +++ b/genesyscloud/recording_media_retention_policy/data_source_genesyscloud_recording_media_retention_policy_test.go @@ -8,6 +8,7 @@ import ( "terraform-provider-genesyscloud/genesyscloud/architect_flow" authRole "terraform-provider-genesyscloud/genesyscloud/auth_role" "terraform-provider-genesyscloud/genesyscloud/provider" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" userRoles "terraform-provider-genesyscloud/genesyscloud/user_roles" "terraform-provider-genesyscloud/genesyscloud/util" @@ -169,7 +170,7 @@ func TestAccDataSourceRecordingMediaRetentionPolicy(t *testing.T) { gcloud.GenerateEvaluationFormResource(evaluationFormResource1, &evaluationFormResourceBody) + gcloud.GenerateSurveyFormResource(surveyFormResource1, &surveyFormResourceBody) + integration.GenerateIntegrationResource(integrationResource1, strconv.Quote(integrationIntendedState), strconv.Quote(integrationType), "") + - gcloud.GenerateRoutingLanguageResource(languageResource1, languageName) + + routingLanguage.GenerateRoutingLanguageResource(languageResource1, languageName) + gcloud.GenerateRoutingWrapupcodeResource(wrapupCodeResource1, wrapupCodeName) + architect_flow.GenerateFlowResource( flowResource1, diff --git a/genesyscloud/recording_media_retention_policy/genesyscloud_recording_media_retention_policy_init_test.go b/genesyscloud/recording_media_retention_policy/genesyscloud_recording_media_retention_policy_init_test.go index 21bafbcb0..30e3830e7 100644 --- a/genesyscloud/recording_media_retention_policy/genesyscloud_recording_media_retention_policy_init_test.go +++ b/genesyscloud/recording_media_retention_policy/genesyscloud_recording_media_retention_policy_init_test.go @@ -9,6 +9,7 @@ import ( integration "terraform-provider-genesyscloud/genesyscloud/integration" "terraform-provider-genesyscloud/genesyscloud/provider" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" userRoles "terraform-provider-genesyscloud/genesyscloud/user_roles" "testing" @@ -52,7 +53,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_quality_forms_evaluation"] = gcloud.ResourceEvaluationForm() providerResources["genesyscloud_quality_forms_survey"] = gcloud.ResourceSurveyForm() providerResources["genesyscloud_integration"] = integration.ResourceIntegration() - providerResources["genesyscloud_routing_language"] = gcloud.ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_wrapupcode"] = gcloud.ResourceRoutingWrapupCode() providerResources["genesyscloud_flow"] = flow.ResourceArchitectFlow() } diff --git a/genesyscloud/recording_media_retention_policy/resource_genesyscloud_recording_media_retention_policy_test.go b/genesyscloud/recording_media_retention_policy/resource_genesyscloud_recording_media_retention_policy_test.go index 9b7bcc10a..b86fdcf87 100644 --- a/genesyscloud/recording_media_retention_policy/resource_genesyscloud_recording_media_retention_policy_test.go +++ b/genesyscloud/recording_media_retention_policy/resource_genesyscloud_recording_media_retention_policy_test.go @@ -10,6 +10,7 @@ import ( "terraform-provider-genesyscloud/genesyscloud/architect_flow" authRole "terraform-provider-genesyscloud/genesyscloud/auth_role" "terraform-provider-genesyscloud/genesyscloud/provider" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" userRoles "terraform-provider-genesyscloud/genesyscloud/user_roles" "terraform-provider-genesyscloud/genesyscloud/util" @@ -955,7 +956,7 @@ func TestAccResourceMediaRetentionPolicyBasic(t *testing.T) { gcloud.GenerateEvaluationFormResource(evaluationFormResource1, &evaluationFormResourceBody) + gcloud.GenerateSurveyFormResource(surveyFormResource1, &surveyFormResourceBody) + integration.GenerateIntegrationResource(integrationResource1, strconv.Quote(integrationIntendedState), strconv.Quote(integrationType), "") + - gcloud.GenerateRoutingLanguageResource(languageResource1, languageName) + + routingLanguage.GenerateRoutingLanguageResource(languageResource1, languageName) + gcloud.GenerateRoutingWrapupcodeResource(wrapupCodeResource1, wrapupCodeName) + architect_flow.GenerateFlowResource( flowResource1, @@ -1062,7 +1063,7 @@ func TestAccResourceMediaRetentionPolicyBasic(t *testing.T) { gcloud.GenerateEvaluationFormResource(evaluationFormResource1, &evaluationFormResourceBody) + gcloud.GenerateSurveyFormResource(surveyFormResource1, &surveyFormResourceBody) + integration.GenerateIntegrationResource(integrationResource1, strconv.Quote(integrationIntendedState), strconv.Quote(integrationType), "") + - gcloud.GenerateRoutingLanguageResource(languageResource1, languageName) + + routingLanguage.GenerateRoutingLanguageResource(languageResource1, languageName) + gcloud.GenerateRoutingWrapupcodeResource(wrapupCodeResource1, wrapupCodeName) + architect_flow.GenerateFlowResource( flowResource1, @@ -1169,7 +1170,7 @@ func TestAccResourceMediaRetentionPolicyBasic(t *testing.T) { gcloud.GenerateEvaluationFormResource(evaluationFormResource1, &evaluationFormResourceBody) + gcloud.GenerateSurveyFormResource(surveyFormResource1, &surveyFormResourceBody) + integration.GenerateIntegrationResource(integrationResource1, strconv.Quote(integrationIntendedState), strconv.Quote(integrationType), "") + - gcloud.GenerateRoutingLanguageResource(languageResource1, languageName) + + routingLanguage.GenerateRoutingLanguageResource(languageResource1, languageName) + gcloud.GenerateRoutingWrapupcodeResource(wrapupCodeResource1, wrapupCodeName) + architect_flow.GenerateFlowResource( flowResource1, @@ -1276,7 +1277,7 @@ func TestAccResourceMediaRetentionPolicyBasic(t *testing.T) { gcloud.GenerateEvaluationFormResource(evaluationFormResource1, &evaluationFormResourceBody) + gcloud.GenerateSurveyFormResource(surveyFormResource1, &surveyFormResourceBody) + integration.GenerateIntegrationResource(integrationResource1, strconv.Quote(integrationIntendedState), strconv.Quote(integrationType), "") + - gcloud.GenerateRoutingLanguageResource(languageResource1, languageName) + + routingLanguage.GenerateRoutingLanguageResource(languageResource1, languageName) + gcloud.GenerateRoutingWrapupcodeResource(wrapupCodeResource1, wrapupCodeName) + architect_flow.GenerateFlowResource( flowResource1, diff --git a/genesyscloud/resource_genesyscloud_init.go b/genesyscloud/resource_genesyscloud_init.go index 747e3a5a2..7a3b47b9f 100644 --- a/genesyscloud/resource_genesyscloud_init.go +++ b/genesyscloud/resource_genesyscloud_init.go @@ -29,7 +29,6 @@ func registerDataSources(l registrar.Registrar) { l.RegisterDataSource("genesyscloud_organizations_me", DataSourceOrganizationsMe()) l.RegisterDataSource("genesyscloud_quality_forms_evaluation", DataSourceQualityFormsEvaluations()) l.RegisterDataSource("genesyscloud_quality_forms_survey", dataSourceQualityFormsSurvey()) - l.RegisterDataSource("genesyscloud_routing_language", dataSourceRoutingLanguage()) l.RegisterDataSource("genesyscloud_routing_skill", dataSourceRoutingSkill()) l.RegisterDataSource("genesyscloud_routing_skill_group", dataSourceRoutingSkillGroup()) l.RegisterDataSource("genesyscloud_routing_email_domain", DataSourceRoutingEmailDomain()) @@ -58,7 +57,6 @@ func registerResources(l registrar.Registrar) { l.RegisterResource("genesyscloud_quality_forms_evaluation", ResourceEvaluationForm()) l.RegisterResource("genesyscloud_quality_forms_survey", ResourceSurveyForm()) l.RegisterResource("genesyscloud_routing_email_domain", ResourceRoutingEmailDomain()) - l.RegisterResource("genesyscloud_routing_language", ResourceRoutingLanguage()) l.RegisterResource("genesyscloud_routing_skill", ResourceRoutingSkill()) l.RegisterResource("genesyscloud_routing_skill_group", ResourceRoutingSkillGroup()) l.RegisterResource("genesyscloud_routing_wrapupcode", ResourceRoutingWrapupCode()) @@ -81,7 +79,6 @@ func registerExporters(l registrar.Registrar) { l.RegisterExporter("genesyscloud_quality_forms_evaluation", EvaluationFormExporter()) l.RegisterExporter("genesyscloud_quality_forms_survey", SurveyFormExporter()) l.RegisterExporter("genesyscloud_routing_email_domain", RoutingEmailDomainExporter()) - l.RegisterExporter("genesyscloud_routing_language", RoutingLanguageExporter()) l.RegisterExporter("genesyscloud_routing_skill", RoutingSkillExporter()) l.RegisterExporter("genesyscloud_routing_skill_group", ResourceSkillGroupExporter()) l.RegisterExporter("genesyscloud_routing_wrapupcode", RoutingWrapupCodeExporter()) diff --git a/genesyscloud/resource_genesyscloud_init_test.go b/genesyscloud/resource_genesyscloud_init_test.go index ae2ed4dae..eb31b6123 100644 --- a/genesyscloud/resource_genesyscloud_init_test.go +++ b/genesyscloud/resource_genesyscloud_init_test.go @@ -8,6 +8,7 @@ import ( architectSchedules "terraform-provider-genesyscloud/genesyscloud/architect_schedules" "terraform-provider-genesyscloud/genesyscloud/group" "terraform-provider-genesyscloud/genesyscloud/provider" + routinglanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" routingSettings "terraform-provider-genesyscloud/genesyscloud/routing_settings" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" @@ -55,7 +56,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_quality_forms_evaluation"] = ResourceEvaluationForm() providerResources["genesyscloud_quality_forms_survey"] = ResourceSurveyForm() providerResources["genesyscloud_routing_email_domain"] = ResourceRoutingEmailDomain() - providerResources["genesyscloud_routing_language"] = ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routinglanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_skill"] = ResourceRoutingSkill() providerResources["genesyscloud_routing_skill_group"] = ResourceRoutingSkillGroup() providerResources["genesyscloud_routing_settings"] = routingSettings.ResourceRoutingSettings() @@ -93,7 +94,7 @@ func (r *registerTestInstance) registerTestDataSources() { providerDataSources["genesyscloud_organizations_me"] = DataSourceOrganizationsMe() providerDataSources["genesyscloud_quality_forms_evaluation"] = DataSourceQualityFormsEvaluations() providerDataSources["genesyscloud_quality_forms_survey"] = dataSourceQualityFormsSurvey() - providerDataSources["genesyscloud_routing_language"] = dataSourceRoutingLanguage() + providerDataSources["genesyscloud_routing_language"] = routinglanguage.DataSourceRoutingLanguage() providerDataSources["genesyscloud_routing_skill"] = dataSourceRoutingSkill() providerDataSources["genesyscloud_routing_skill_group"] = dataSourceRoutingSkillGroup() providerDataSources["genesyscloud_routing_email_domain"] = DataSourceRoutingEmailDomain() diff --git a/genesyscloud/resource_genesyscloud_routing_language.go b/genesyscloud/resource_genesyscloud_routing_language.go deleted file mode 100644 index 9340ff2b7..000000000 --- a/genesyscloud/resource_genesyscloud_routing_language.go +++ /dev/null @@ -1,164 +0,0 @@ -package genesyscloud - -import ( - "context" - "fmt" - "log" - "terraform-provider-genesyscloud/genesyscloud/provider" - "terraform-provider-genesyscloud/genesyscloud/util" - "terraform-provider-genesyscloud/genesyscloud/util/constants" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - - "terraform-provider-genesyscloud/genesyscloud/consistency_checker" - - resourceExporter "terraform-provider-genesyscloud/genesyscloud/resource_exporter" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/mypurecloud/platform-client-sdk-go/v133/platformclientv2" -) - -func getAllRoutingLanguages(_ context.Context, clientConfig *platformclientv2.Configuration) (resourceExporter.ResourceIDMetaMap, diag.Diagnostics) { - resources := make(resourceExporter.ResourceIDMetaMap) - routingAPI := platformclientv2.NewRoutingApiWithConfig(clientConfig) - - for pageNum := 1; ; pageNum++ { - const pageSize = 100 - languages, resp, getErr := routingAPI.GetRoutingLanguages(pageSize, pageNum, "", "", nil) - if getErr != nil { - return nil, util.BuildAPIDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Failed to get page of languages: %v", getErr), resp) - } - - if languages.Entities == nil || len(*languages.Entities) == 0 { - break - } - - for _, language := range *languages.Entities { - if language.State != nil && *language.State != "deleted" { - resources[*language.Id] = &resourceExporter.ResourceMeta{Name: *language.Name} - } - } - } - - return resources, nil -} - -func RoutingLanguageExporter() *resourceExporter.ResourceExporter { - return &resourceExporter.ResourceExporter{ - GetResourcesFunc: provider.GetAllWithPooledClient(getAllRoutingLanguages), - RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references - } -} - -func ResourceRoutingLanguage() *schema.Resource { - return &schema.Resource{ - Description: "Genesys Cloud Routing Language", - - CreateContext: provider.CreateWithPooledClient(createRoutingLanguage), - ReadContext: provider.ReadWithPooledClient(readRoutingLanguage), - DeleteContext: provider.DeleteWithPooledClient(deleteRoutingLanguage), - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - SchemaVersion: 1, - Schema: map[string]*schema.Schema{ - "name": { - Description: "Language name. Changing the language_name attribute will cause the language object to be dropped and recreated with a new ID.", - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - } -} - -func createRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - name := d.Get("name").(string) - - sdkConfig := meta.(*provider.ProviderMeta).ClientConfig - routingAPI := platformclientv2.NewRoutingApiWithConfig(sdkConfig) - - log.Printf("Creating language %s", name) - language, resp, err := routingAPI.PostRoutingLanguages(platformclientv2.Language{ - Name: &name, - }) - if err != nil { - return util.BuildAPIDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Failed to create language %s error: %s", name, err), resp) - } - - d.SetId(*language.Id) - - log.Printf("Created language %s %s", name, *language.Id) - return readRoutingLanguage(ctx, d, meta) -} - -func readRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - sdkConfig := meta.(*provider.ProviderMeta).ClientConfig - routingApi := platformclientv2.NewRoutingApiWithConfig(sdkConfig) - cc := consistency_checker.NewConsistencyCheck(ctx, d, meta, ResourceRoutingLanguage(), constants.DefaultConsistencyChecks, "genesyscloud_routing_language") - - log.Printf("Reading language %s", d.Id()) - return util.WithRetriesForRead(ctx, d, func() *retry.RetryError { - language, resp, getErr := routingApi.GetRoutingLanguage(d.Id()) - if getErr != nil { - if util.IsStatus404(resp) { - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Failed to read language %s | error: %s", d.Id(), getErr), resp)) - } - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Failed to read language %s | error: %s", d.Id(), getErr), resp)) - } - - if language.State != nil && *language.State == "deleted" { - d.SetId("") - return nil - } - - d.Set("name", *language.Name) - log.Printf("Read language %s %s", d.Id(), *language.Name) - return cc.CheckState(d) - }) -} - -func deleteRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - name := d.Get("name").(string) - - sdkConfig := meta.(*provider.ProviderMeta).ClientConfig - routingApi := platformclientv2.NewRoutingApiWithConfig(sdkConfig) - - log.Printf("Deleting language %s", name) - resp, err := routingApi.DeleteRoutingLanguage(d.Id()) - - if err != nil { - return util.BuildAPIDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Failed to delete language %s error: %s", name, err), resp) - } - - return util.WithRetries(ctx, 30*time.Second, func() *retry.RetryError { - routingLanguage, resp, err := routingApi.GetRoutingLanguage(d.Id()) - if err != nil { - if util.IsStatus404(resp) { - // Routing language deleted - log.Printf("Deleted Routing language %s", d.Id()) - return nil - } - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Error deleting Routing language %s | error: %s", d.Id(), err), resp)) - } - - if routingLanguage.State != nil && *routingLanguage.State == "deleted" { - // Routing language deleted - log.Printf("Deleted Routing language %s", d.Id()) - return nil - } - - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_language", fmt.Sprintf("Routing language %s still exists", d.Id()), resp)) - }) -} - -func GenerateRoutingLanguageResource( - resourceID string, - name string) string { - return fmt.Sprintf(`resource "genesyscloud_routing_language" "%s" { - name = "%s" - } - `, resourceID, name) -} diff --git a/genesyscloud/resource_genesyscloud_user_test.go b/genesyscloud/resource_genesyscloud_user_test.go index e3f37ddb9..52fda8c8e 100644 --- a/genesyscloud/resource_genesyscloud_user_test.go +++ b/genesyscloud/resource_genesyscloud_user_test.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "terraform-provider-genesyscloud/genesyscloud/provider" + routinglanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" "terraform-provider-genesyscloud/genesyscloud/util" @@ -486,7 +487,7 @@ func TestAccResourceUserLanguages(t *testing.T) { email1, userName1, generateUserRoutingLang("genesyscloud_routing_language."+langResource1+".id", proficiency1), - ) + GenerateRoutingLanguageResource(langResource1, langName1), + ) + routinglanguage.GenerateRoutingLanguageResource(langResource1, langName1), Check: resource.ComposeTestCheckFunc( validateUserLanguage("genesyscloud_user."+userResource1, "genesyscloud_routing_language."+langResource1, proficiency1), ), @@ -499,10 +500,10 @@ func TestAccResourceUserLanguages(t *testing.T) { userName1, generateUserRoutingLang("genesyscloud_routing_language."+langResource1+".id", proficiency1), generateUserRoutingLang("genesyscloud_routing_language."+langResource2+".id", proficiency2), - ) + GenerateRoutingLanguageResource( + ) + routinglanguage.GenerateRoutingLanguageResource( langResource1, langName1, - ) + GenerateRoutingLanguageResource( + ) + routinglanguage.GenerateRoutingLanguageResource( langResource2, langName2, ), @@ -518,7 +519,7 @@ func TestAccResourceUserLanguages(t *testing.T) { email1, userName1, generateUserRoutingLang("genesyscloud_routing_language."+langResource2+".id", proficiency1), - ) + GenerateRoutingLanguageResource( + ) + routinglanguage.GenerateRoutingLanguageResource( langResource2, langName2, ), diff --git a/genesyscloud/routing_email_route/genesyscloud_routing_email_route_init_test.go b/genesyscloud/routing_email_route/genesyscloud_routing_email_route_init_test.go index 9037521ac..2bccf1649 100644 --- a/genesyscloud/routing_email_route/genesyscloud_routing_email_route_init_test.go +++ b/genesyscloud/routing_email_route/genesyscloud_routing_email_route_init_test.go @@ -6,6 +6,7 @@ import ( architectFlow "terraform-provider-genesyscloud/genesyscloud/architect_flow" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -35,7 +36,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources[resourceName] = ResourceRoutingEmailRoute() providerResources["genesyscloud_routing_email_domain"] = genesyscloud.ResourceRoutingEmailDomain() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() - providerResources["genesyscloud_routing_language"] = genesyscloud.ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_skill"] = genesyscloud.ResourceRoutingSkill() providerResources["genesyscloud_flow"] = architectFlow.ResourceArchitectFlow() providerResources["genesyscloud_routing_skill_group"] = genesyscloud.ResourceRoutingSkillGroup() diff --git a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_test.go b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_test.go index 075bd7b7c..cf9d610ca 100644 --- a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_test.go +++ b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_test.go @@ -9,6 +9,7 @@ import ( "terraform-provider-genesyscloud/genesyscloud/architect_flow" "terraform-provider-genesyscloud/genesyscloud/provider" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" "terraform-provider-genesyscloud/genesyscloud/util" "testing" "time" @@ -124,7 +125,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingQueue.GenerateRoutingQueueResourceBasic( queueResource, queueName, - ) + gcloud.GenerateRoutingLanguageResource( + ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, ) + gcloud.GenerateRoutingSkillResource( @@ -196,7 +197,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { queueResource, queueName, - ) + gcloud.GenerateRoutingLanguageResource( + ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, ) + gcloud.GenerateRoutingSkillResource( @@ -253,7 +254,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingQueue.GenerateRoutingQueueResourceBasic( queueResource, queueName, - ) + gcloud.GenerateRoutingLanguageResource( + ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, ) + gcloud.GenerateRoutingSkillResource( @@ -315,7 +316,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingQueue.GenerateRoutingQueueResourceBasic( queueResource, queueName, - ) + gcloud.GenerateRoutingLanguageResource( + ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, ) + gcloud.GenerateRoutingSkillResource( diff --git a/genesyscloud/routing_language/data_source_genesyscloud_routing_language.go b/genesyscloud/routing_language/data_source_genesyscloud_routing_language.go new file mode 100644 index 000000000..fb231d336 --- /dev/null +++ b/genesyscloud/routing_language/data_source_genesyscloud_routing_language.go @@ -0,0 +1,34 @@ +package routing_language + +import ( + "context" + "fmt" + "terraform-provider-genesyscloud/genesyscloud/provider" + "terraform-provider-genesyscloud/genesyscloud/util" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceRoutingLanguageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + sdkConfig := m.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingLanguageProxy(sdkConfig) + name := d.Get("name").(string) + + // Find first non-deleted language by name. Retry in case new language is not yet indexed by search + return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { + languageId, resp, retryable, err := proxy.getRoutingLanguageIdByName(ctx, name) + if err != nil && !retryable { + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error requesting language %s | error: %s", name, err), resp)) + } + if retryable { + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error requesting language %s | error: %s", name, err), resp)) + } + + d.SetId(languageId) + return nil + }) +} diff --git a/genesyscloud/data_source_genesyscloud_routing_language_test.go b/genesyscloud/routing_language/data_source_genesyscloud_routing_language_test.go similarity index 98% rename from genesyscloud/data_source_genesyscloud_routing_language_test.go rename to genesyscloud/routing_language/data_source_genesyscloud_routing_language_test.go index 018c1d2e9..5b3a724f2 100644 --- a/genesyscloud/data_source_genesyscloud_routing_language_test.go +++ b/genesyscloud/routing_language/data_source_genesyscloud_routing_language_test.go @@ -1,4 +1,4 @@ -package genesyscloud +package routing_language import ( "fmt" diff --git a/genesyscloud/routing_language/genesyscloud_routing_language_init_test.go b/genesyscloud/routing_language/genesyscloud_routing_language_init_test.go new file mode 100644 index 000000000..5642770cb --- /dev/null +++ b/genesyscloud/routing_language/genesyscloud_routing_language_init_test.go @@ -0,0 +1,60 @@ +package routing_language + +import ( + "sync" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +/* +The genesyscloud_routing_language_init_test.go file is used to initialize the data sources and resources +used in testing the routing_language resource. +*/ + +// providerDataSources holds a map of all registered datasources +var providerDataSources map[string]*schema.Resource + +// providerResources holds a map of all registered resources +var providerResources map[string]*schema.Resource + +type registerTestInstance struct { + resourceMapMutex sync.RWMutex + dataSourceMapMutex sync.RWMutex +} + +// registerTestResources registers all resources used in the tests +func (r *registerTestInstance) registerTestResources() { + r.resourceMapMutex.Lock() + defer r.resourceMapMutex.Unlock() + + providerResources[resourceName] = ResourceRoutingLanguage() +} + +// registerTestDataSources registers all data sources used in the tests. +func (r *registerTestInstance) registerTestDataSources() { + r.dataSourceMapMutex.Lock() + defer r.dataSourceMapMutex.Unlock() + + providerDataSources[resourceName] = DataSourceRoutingLanguage() +} + +// initTestResources initializes all test resources and data sources. +func initTestResources() { + providerDataSources = make(map[string]*schema.Resource) + providerResources = make(map[string]*schema.Resource) + + regInstance := ®isterTestInstance{} + + regInstance.registerTestResources() + regInstance.registerTestDataSources() +} + +// TestMain is a "setup" function called by the testing framework when run the test +func TestMain(m *testing.M) { + // Run setup function before starting the test suite for routing_language package + initTestResources() + + // Run the test suite for the routing_language package + m.Run() +} diff --git a/genesyscloud/routing_language/genesyscloud_routing_language_proxy.go b/genesyscloud/routing_language/genesyscloud_routing_language_proxy.go new file mode 100644 index 000000000..4e989950f --- /dev/null +++ b/genesyscloud/routing_language/genesyscloud_routing_language_proxy.go @@ -0,0 +1,154 @@ +package routing_language + +import ( + "context" + "fmt" + "log" + rc "terraform-provider-genesyscloud/genesyscloud/resource_cache" + + "github.com/mypurecloud/platform-client-sdk-go/v133/platformclientv2" +) + +var internalProxy *routingLanguageProxy + +type getAllRoutingLanguagesFunc func(ctx context.Context, p *routingLanguageProxy, name string) (*[]platformclientv2.Language, *platformclientv2.APIResponse, error) +type createRoutingLanguageFunc func(ctx context.Context, p *routingLanguageProxy, language *platformclientv2.Language) (*platformclientv2.Language, *platformclientv2.APIResponse, error) +type getRoutingLanguageByIdFunc func(ctx context.Context, p *routingLanguageProxy, id string) (*platformclientv2.Language, *platformclientv2.APIResponse, error) +type getRoutingLanguageIdByNameFunc func(ctx context.Context, p *routingLanguageProxy, name string) (string, *platformclientv2.APIResponse, bool, error) +type deleteRoutingLanguageFunc func(ctx context.Context, p *routingLanguageProxy, id string) (*platformclientv2.APIResponse, error) + +// routingLanguageProxy contains all of the methods that call genesys cloud APIs. +type routingLanguageProxy struct { + clientConfig *platformclientv2.Configuration + routingApi *platformclientv2.RoutingApi + createRoutingLanguageAttr createRoutingLanguageFunc + getAllRoutingLanguagesAttr getAllRoutingLanguagesFunc + getRoutingLanguageIdByNameAttr getRoutingLanguageIdByNameFunc + getRoutingLanguageByIdAttr getRoutingLanguageByIdFunc + deleteRoutingLanguageAttr deleteRoutingLanguageFunc + routingLanguageCache rc.CacheInterface[platformclientv2.Language] +} + +// newRoutingLanguageProxy initializes the routing language proxy with all of the data needed to communicate with Genesys Cloud +func newRoutingLanguageProxy(clientConfig *platformclientv2.Configuration) *routingLanguageProxy { + api := platformclientv2.NewRoutingApiWithConfig(clientConfig) + routingLanguageCache := rc.NewResourceCache[platformclientv2.Language]() + return &routingLanguageProxy{ + clientConfig: clientConfig, + routingApi: api, + createRoutingLanguageAttr: createRoutingLanguageFn, + getAllRoutingLanguagesAttr: getAllRoutingLanguagesFn, + getRoutingLanguageIdByNameAttr: getRoutingLanguageIdByNameFn, + getRoutingLanguageByIdAttr: getRoutingLanguageByIdFn, + deleteRoutingLanguageAttr: deleteRoutingLanguageFn, + routingLanguageCache: routingLanguageCache, + } +} + +func getRoutingLanguageProxy(clientConfig *platformclientv2.Configuration) *routingLanguageProxy { + if internalProxy == nil { + internalProxy = newRoutingLanguageProxy(clientConfig) + } + return internalProxy +} + +// getRoutingLanguage retrieves all Genesys Cloud routing language +func (p *routingLanguageProxy) getAllRoutingLanguages(ctx context.Context, name string) (*[]platformclientv2.Language, *platformclientv2.APIResponse, error) { + return p.getAllRoutingLanguagesAttr(ctx, p, name) +} + +// createRoutingLanguage creates a Genesys Cloud routing language +func (p *routingLanguageProxy) createRoutingLanguage(ctx context.Context, routingLanguage *platformclientv2.Language) (*platformclientv2.Language, *platformclientv2.APIResponse, error) { + return p.createRoutingLanguageAttr(ctx, p, routingLanguage) +} + +// getRoutingLanguageById returns a single Genesys Cloud routing language by Id +func (p *routingLanguageProxy) getRoutingLanguageById(ctx context.Context, id string) (*platformclientv2.Language, *platformclientv2.APIResponse, error) { + return p.getRoutingLanguageByIdAttr(ctx, p, id) +} + +// getRoutingLanguageIdByName returns a single Genesys Cloud routing language by a name +func (p *routingLanguageProxy) getRoutingLanguageIdByName(ctx context.Context, name string) (string, *platformclientv2.APIResponse, bool, error) { + return p.getRoutingLanguageIdByNameAttr(ctx, p, name) +} + +// deleteRoutingLanguage deletes a Genesys Cloud routing language by Id +func (p *routingLanguageProxy) deleteRoutingLanguage(ctx context.Context, id string) (*platformclientv2.APIResponse, error) { + return p.deleteRoutingLanguageAttr(ctx, p, id) +} + +// getAllRoutingLanguageFn is the implementation for retrieving all routing language in Genesys Cloud +func getAllRoutingLanguagesFn(ctx context.Context, p *routingLanguageProxy, name string) (*[]platformclientv2.Language, *platformclientv2.APIResponse, error) { + var ( + allLanguages []platformclientv2.Language + response *platformclientv2.APIResponse + pageSize = 100 + ) + + languages, resp, err := p.routingApi.GetRoutingLanguages(pageSize, 1, "", name, []string{}) + if err != nil { + return nil, resp, fmt.Errorf("failed to get language: %v", err) + } + + if languages.Entities == nil || len(*languages.Entities) == 0 { + return &allLanguages, resp, nil + } + allLanguages = append(allLanguages, *languages.Entities...) + + for pageNum := 2; pageNum <= *languages.PageCount; pageNum++ { + languages, resp, err := p.routingApi.GetRoutingLanguages(pageSize, pageNum, "", name, []string{}) + if err != nil { + return nil, resp, fmt.Errorf("failed to get language: %v", err) + } + + response = resp + if languages.Entities == nil || len(*languages.Entities) == 0 { + break + } + allLanguages = append(allLanguages, *languages.Entities...) + } + + for _, language := range allLanguages { + rc.SetCache(p.routingLanguageCache, *language.Id, language) + } + + return &allLanguages, response, nil +} + +// createRoutingLanguageFn is an implementation function for creating a Genesys Cloud routing language +func createRoutingLanguageFn(ctx context.Context, p *routingLanguageProxy, routingLanguage *platformclientv2.Language) (*platformclientv2.Language, *platformclientv2.APIResponse, error) { + return p.routingApi.PostRoutingLanguages(*routingLanguage) +} + +// getRoutingLanguageByIdFn is an implementation of the function to get a Genesys Cloud routing language by Id +func getRoutingLanguageByIdFn(ctx context.Context, p *routingLanguageProxy, id string) (*platformclientv2.Language, *platformclientv2.APIResponse, error) { + if language := rc.GetCacheItem(p.routingLanguageCache, id); language != nil { + return language, nil, nil + } + return p.routingApi.GetRoutingLanguage(id) +} + +// getRoutingLanguageIdByNameFn is an implementation of the function to get a Genesys Cloud routing language by name +func getRoutingLanguageIdByNameFn(ctx context.Context, p *routingLanguageProxy, name string) (string, *platformclientv2.APIResponse, bool, error) { + languages, resp, err := getAllRoutingLanguagesFn(ctx, p, name) + if err != nil { + return "", resp, false, err + } + + if languages == nil || len(*languages) == 0 { + return "", resp, true, fmt.Errorf("no routing language found with name %s", name) + } + + for _, language := range *languages { + if *language.Name == name { + log.Printf("Retrieved the routing language id %s by name %s", *language.Id, name) + return *language.Id, resp, false, nil + } + } + return "", resp, true, fmt.Errorf("unable to find routing language with name %s", name) +} + +// deleteRoutingLanguageFn is an implementation function for deleting a Genesys Cloud routing language +func deleteRoutingLanguageFn(ctx context.Context, p *routingLanguageProxy, id string) (*platformclientv2.APIResponse, error) { + return p.routingApi.DeleteRoutingLanguage(id) +} diff --git a/genesyscloud/routing_language/resource_genesyscloud_routing_language.go b/genesyscloud/routing_language/resource_genesyscloud_routing_language.go new file mode 100644 index 000000000..3ffee932a --- /dev/null +++ b/genesyscloud/routing_language/resource_genesyscloud_routing_language.go @@ -0,0 +1,119 @@ +package routing_language + +import ( + "context" + "fmt" + "log" + "terraform-provider-genesyscloud/genesyscloud/provider" + "terraform-provider-genesyscloud/genesyscloud/util" + "terraform-provider-genesyscloud/genesyscloud/util/constants" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + + "terraform-provider-genesyscloud/genesyscloud/consistency_checker" + + resourceExporter "terraform-provider-genesyscloud/genesyscloud/resource_exporter" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mypurecloud/platform-client-sdk-go/v133/platformclientv2" +) + +func getAllRoutingLanguages(ctx context.Context, clientConfig *platformclientv2.Configuration) (resourceExporter.ResourceIDMetaMap, diag.Diagnostics) { + resources := make(resourceExporter.ResourceIDMetaMap) + proxy := getRoutingLanguageProxy(clientConfig) + + languages, resp, getErr := proxy.getAllRoutingLanguages(ctx, "") + if getErr != nil { + return nil, util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to get page of languages: %v", getErr), resp) + } + + if languages == nil || len(*languages) == 0 { + return resources, nil + } + + for _, language := range *languages { + if language.State != nil && *language.State != "deleted" { + resources[*language.Id] = &resourceExporter.ResourceMeta{Name: *language.Name} + } + } + return resources, nil +} + +func createRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingLanguageProxy(sdkConfig) + name := d.Get("name").(string) + + log.Printf("Creating language %s", name) + + language, resp, err := proxy.createRoutingLanguage(ctx, &platformclientv2.Language{ + Name: &name, + }) + if err != nil { + return util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to create language %s error: %s", name, err), resp) + } + + d.SetId(*language.Id) + + log.Printf("Created language %s %s", name, *language.Id) + return readRoutingLanguage(ctx, d, meta) +} + +func readRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingLanguageProxy(sdkConfig) + cc := consistency_checker.NewConsistencyCheck(ctx, d, meta, ResourceRoutingLanguage(), constants.DefaultConsistencyChecks, resourceName) + + log.Printf("Reading routing language %s", d.Id()) + return util.WithRetriesForRead(ctx, d, func() *retry.RetryError { + language, resp, getErr := proxy.getRoutingLanguageById(ctx, d.Id()) + if getErr != nil { + if util.IsStatus404(resp) { + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Failed to read language %s | error: %s", d.Id(), getErr), resp)) + } + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Failed to read language %s | error: %s", d.Id(), getErr), resp)) + } + + if language.State != nil && *language.State == "deleted" { + d.SetId("") + return nil + } + + _ = d.Set("name", *language.Name) + log.Printf("Read routing language %s %s", d.Id(), *language.Name) + return cc.CheckState(d) + }) +} + +func deleteRoutingLanguage(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingLanguageProxy(sdkConfig) + name := d.Get("name").(string) + + log.Printf("Deleting language %s", name) + resp, err := proxy.deleteRoutingLanguage(ctx, d.Id()) + if err != nil { + return util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to delete language %s error: %s", name, err), resp) + } + + return util.WithRetries(ctx, 30*time.Second, func() *retry.RetryError { + routingLanguage, resp, err := proxy.getRoutingLanguageById(ctx, d.Id()) + if err != nil { + if util.IsStatus404(resp) { + // Routing language deleted + log.Printf("Deleted Routing language %s", d.Id()) + return nil + } + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error deleting Routing language %s | error: %s", d.Id(), err), resp)) + } + + if routingLanguage.State != nil && *routingLanguage.State == "deleted" { + // Routing language deleted + log.Printf("Deleted Routing language %s", d.Id()) + return nil + } + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Routing language %s still exists", d.Id()), resp)) + }) +} diff --git a/genesyscloud/routing_language/resource_genesyscloud_routing_language_schema.go b/genesyscloud/routing_language/resource_genesyscloud_routing_language_schema.go new file mode 100644 index 000000000..6ae346a4e --- /dev/null +++ b/genesyscloud/routing_language/resource_genesyscloud_routing_language_schema.go @@ -0,0 +1,70 @@ +package routing_language + +import ( + "fmt" + "terraform-provider-genesyscloud/genesyscloud/provider" + resourceExporter "terraform-provider-genesyscloud/genesyscloud/resource_exporter" + registrar "terraform-provider-genesyscloud/genesyscloud/resource_register" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +const resourceName = "genesyscloud_routing_language" + +// SetRegistrar registers all of the resources, datasources and exporters in the package +func SetRegistrar(regInstance registrar.Registrar) { + regInstance.RegisterResource(resourceName, ResourceRoutingLanguage()) + regInstance.RegisterExporter(resourceName, RoutingLanguageExporter()) + regInstance.RegisterDataSource(resourceName, DataSourceRoutingLanguage()) +} + +func ResourceRoutingLanguage() *schema.Resource { + return &schema.Resource{ + Description: "Genesys Cloud Routing Language", + + CreateContext: provider.CreateWithPooledClient(createRoutingLanguage), + ReadContext: provider.ReadWithPooledClient(readRoutingLanguage), + DeleteContext: provider.DeleteWithPooledClient(deleteRoutingLanguage), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + SchemaVersion: 1, + Schema: map[string]*schema.Schema{ + "name": { + Description: "Language name. Changing the language_name attribute will cause the language object to be dropped and recreated with a new ID.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + } +} + +func DataSourceRoutingLanguage() *schema.Resource { + return &schema.Resource{ + Description: "Data source for Genesys Cloud Routing Languages. Select a language by name.", + ReadContext: provider.ReadWithPooledClient(dataSourceRoutingLanguageRead), + Schema: map[string]*schema.Schema{ + "name": { + Description: "Language name.", + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func RoutingLanguageExporter() *resourceExporter.ResourceExporter { + return &resourceExporter.ResourceExporter{ + GetResourcesFunc: provider.GetAllWithPooledClient(getAllRoutingLanguages), + } +} + +func GenerateRoutingLanguageResource( + resourceID string, + name string) string { + return fmt.Sprintf(`resource "genesyscloud_routing_language" "%s" { + name = "%s" + } + `, resourceID, name) +} diff --git a/genesyscloud/resource_genesyscloud_routing_language_test.go b/genesyscloud/routing_language/resource_genesyscloud_routing_language_test.go similarity index 98% rename from genesyscloud/resource_genesyscloud_routing_language_test.go rename to genesyscloud/routing_language/resource_genesyscloud_routing_language_test.go index 5d0349c8a..b2dfbe573 100644 --- a/genesyscloud/resource_genesyscloud_routing_language_test.go +++ b/genesyscloud/routing_language/resource_genesyscloud_routing_language_test.go @@ -1,4 +1,4 @@ -package genesyscloud +package routing_language import ( "fmt" diff --git a/genesyscloud/task_management_workitem/genesyscloud_task_management_workitem_init_test.go b/genesyscloud/task_management_workitem/genesyscloud_task_management_workitem_init_test.go index d2b760c69..cad4d1e46 100644 --- a/genesyscloud/task_management_workitem/genesyscloud_task_management_workitem_init_test.go +++ b/genesyscloud/task_management_workitem/genesyscloud_task_management_workitem_init_test.go @@ -3,6 +3,7 @@ package task_management_workitem import ( "sync" authRole "terraform-provider-genesyscloud/genesyscloud/auth_role" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" "terraform-provider-genesyscloud/genesyscloud/user_roles" "testing" @@ -41,7 +42,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_task_management_workitem_schema"] = workitemSchema.ResourceTaskManagementWorkitemSchema() providerResources["genesyscloud_task_management_workbin"] = workbin.ResourceTaskManagementWorkbin() providerResources["genesyscloud_task_management_worktype"] = worktype.ResourceTaskManagementWorktype() - providerResources["genesyscloud_routing_language"] = gcloud.ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() providerResources["genesyscloud_user"] = gcloud.ResourceUser() providerResources["genesyscloud_externalcontacts_contact"] = externalContacts.ResourceExternalContact() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() diff --git a/genesyscloud/task_management_workitem/resource_genesyscloud_task_management_workitem_test.go b/genesyscloud/task_management_workitem/resource_genesyscloud_task_management_workitem_test.go index ae67f2425..697a3bcbf 100644 --- a/genesyscloud/task_management_workitem/resource_genesyscloud_task_management_workitem_test.go +++ b/genesyscloud/task_management_workitem/resource_genesyscloud_task_management_workitem_test.go @@ -6,6 +6,7 @@ import ( "strings" authRole "terraform-provider-genesyscloud/genesyscloud/auth_role" "terraform-provider-genesyscloud/genesyscloud/provider" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" "terraform-provider-genesyscloud/genesyscloud/user_roles" "terraform-provider-genesyscloud/genesyscloud/util" @@ -194,7 +195,7 @@ func TestAccResourceTaskManagementWorkitem(t *testing.T) { { Config: taskMgmtConfig + gcloud.GenerateAuthDivisionHomeDataSource(homeDivRes) + - gcloud.GenerateRoutingLanguageResource(resLang, lang) + + routingLanguage.GenerateRoutingLanguageResource(resLang, lang) + routingQueue.GenerateRoutingQueueResourceBasic(resQueue, queueName) + gcloud.GenerateRoutingSkillResource(skillResId1, skillResName1) + gcloud.GenerateBasicUserResource(userResId1, userEmail1, userName1) + diff --git a/genesyscloud/task_management_worktype/genesyscloud_task_management_worktype_init_test.go b/genesyscloud/task_management_worktype/genesyscloud_task_management_worktype_init_test.go index 897b3b335..bdb8160ee 100644 --- a/genesyscloud/task_management_worktype/genesyscloud_task_management_worktype_init_test.go +++ b/genesyscloud/task_management_worktype/genesyscloud_task_management_worktype_init_test.go @@ -6,6 +6,7 @@ import ( "testing" gcloud "terraform-provider-genesyscloud/genesyscloud" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" workbin "terraform-provider-genesyscloud/genesyscloud/task_management_workbin" workitemSchema "terraform-provider-genesyscloud/genesyscloud/task_management_workitem_schema" @@ -36,7 +37,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources[resourceName] = ResourceTaskManagementWorktype() providerResources["genesyscloud_task_management_workbin"] = workbin.ResourceTaskManagementWorkbin() providerResources["genesyscloud_task_management_workitem_schema"] = workitemSchema.ResourceTaskManagementWorkitemSchema() - providerResources["genesyscloud_routing_language"] = gcloud.ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() providerResources["genesyscloud_routing_skill"] = gcloud.ResourceRoutingSkill() } diff --git a/genesyscloud/task_management_worktype/resource_genesyscloud_task_management_worktype_test.go b/genesyscloud/task_management_worktype/resource_genesyscloud_task_management_worktype_test.go index 90bf04a63..12a109adb 100644 --- a/genesyscloud/task_management_worktype/resource_genesyscloud_task_management_worktype_test.go +++ b/genesyscloud/task_management_worktype/resource_genesyscloud_task_management_worktype_test.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "terraform-provider-genesyscloud/genesyscloud/provider" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" "terraform-provider-genesyscloud/genesyscloud/util" "testing" @@ -109,7 +110,7 @@ func TestAccResourceTaskManagementWorktype(t *testing.T) { Config: workbin.GenerateWorkbinResource(wbResourceId, wbName, wbDescription, util.NullValue) + workitemSchema.GenerateWorkitemSchemaResourceBasic(wsResourceId, wsName, wsDescription) + routingQueue.GenerateRoutingQueueResourceBasic(queueResId, queueName) + - gcloud.GenerateRoutingLanguageResource(langResId, langName) + + routingLanguage.GenerateRoutingLanguageResource(langResId, langName) + gcloud.GenerateRoutingSkillResource(skillResId1, skillResName1) + gcloud.GenerateRoutingSkillResource(skillResId2, skillResName2) + generateWorktypeResource(wtRes) + diff --git a/genesyscloud/tfexporter/tf_exporter_resource_test.go b/genesyscloud/tfexporter/tf_exporter_resource_test.go index 5f3873c2e..ed4942b40 100644 --- a/genesyscloud/tfexporter/tf_exporter_resource_test.go +++ b/genesyscloud/tfexporter/tf_exporter_resource_test.go @@ -52,6 +52,7 @@ import ( responsemanagementResponse "terraform-provider-genesyscloud/genesyscloud/responsemanagement_response" respManagementRespAsset "terraform-provider-genesyscloud/genesyscloud/responsemanagement_responseasset" routingEmailRoute "terraform-provider-genesyscloud/genesyscloud/routing_email_route" + routinglanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" routingQueueConditionalGroupRouting "terraform-provider-genesyscloud/genesyscloud/routing_queue_conditional_group_routing" routingQueueOutboundEmailAddress "terraform-provider-genesyscloud/genesyscloud/routing_queue_outbound_email_address" @@ -73,7 +74,6 @@ import ( userRoles "terraform-provider-genesyscloud/genesyscloud/user_roles" webdeployConfig "terraform-provider-genesyscloud/genesyscloud/webdeployments_configuration" webdeployDeploy "terraform-provider-genesyscloud/genesyscloud/webdeployments_deployment" - "testing" edgePhone "terraform-provider-genesyscloud/genesyscloud/telephony_providers_edges_phone" @@ -152,7 +152,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_responsemanagement_responseasset"] = respManagementRespAsset.ResourceResponseManagementResponseAsset() providerResources["genesyscloud_routing_email_domain"] = gcloud.ResourceRoutingEmailDomain() providerResources["genesyscloud_routing_email_route"] = routingEmailRoute.ResourceRoutingEmailRoute() - providerResources["genesyscloud_routing_language"] = gcloud.ResourceRoutingLanguage() + providerResources["genesyscloud_routing_language"] = routinglanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() providerResources["genesyscloud_routing_queue_conditional_group_routing"] = routingQueueConditionalGroupRouting.ResourceRoutingQueueConditionalGroupRouting() providerResources["genesyscloud_routing_queue_outbound_email_address"] = routingQueueOutboundEmailAddress.ResourceRoutingQueueOutboundEmailAddress() @@ -264,7 +264,7 @@ func (r *registerTestInstance) registerTestExporters() { RegisterExporter("genesyscloud_responsemanagement_responseasset", respManagementRespAsset.ExporterResponseManagementResponseAsset()) RegisterExporter("genesyscloud_routing_email_domain", gcloud.RoutingEmailDomainExporter()) RegisterExporter("genesyscloud_routing_email_route", routingEmailRoute.RoutingEmailRouteExporter()) - RegisterExporter("genesyscloud_routing_language", gcloud.RoutingLanguageExporter()) + RegisterExporter("genesyscloud_routing_language", routinglanguage.RoutingLanguageExporter()) RegisterExporter("genesyscloud_routing_queue", routingQueue.RoutingQueueExporter()) RegisterExporter("genesyscloud_routing_queue_conditional_group_routing", routingQueueConditionalGroupRouting.RoutingQueueConditionalGroupRoutingExporter()) RegisterExporter("genesyscloud_routing_queue_outbound_email_address", routingQueueOutboundEmailAddress.OutboundRoutingQueueOutboundEmailAddressExporter()) diff --git a/main.go b/main.go index 9c07f19fc..18055ff09 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,7 @@ import ( responsemanagementResponse "terraform-provider-genesyscloud/genesyscloud/responsemanagement_response" responsemanagementResponseasset "terraform-provider-genesyscloud/genesyscloud/responsemanagement_responseasset" routingEmailRoute "terraform-provider-genesyscloud/genesyscloud/routing_email_route" + routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" @@ -237,7 +238,7 @@ func registerResources() { routingUtilization.SetRegistrar(regInstance) // Registering routing utilization routingUtilizationLabel.SetRegistrar(regInstance) // Registering routing utilization label journeyViews.SetRegistrar(regInstance) //Registering journey views - + routingLanguage.SetRegistrar(regInstance) //Registering Routing Language // setting resources for Use cases like TF export where provider is used in resource classes. tfexp.SetRegistrar(regInstance) //Registering tf exporter registrar.SetResources(providerResources, providerDataSources)