From 8b2f0bd0992e204ff1c25f6266a9d16838178636 Mon Sep 17 00:00:00 2001 From: Charlie Conneely <87772562+charliecon@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:54:39 +0100 Subject: [PATCH 1/2] No jira: unit tests workflow (#1181) * Adding unit tests workflow * inconsequential change to trigger new workflow * minor change * Removed comment * changing workflow trigger * Fixing syntax error in yml file * Fixed unit test * Fixing other unit tests --- .github/workflows/unit-tests.yml | 27 +++++++++++++++++++ ...esyscloud_architect_ivr_proxy_unit_test.go | 4 +-- ...eue_conditional_group_routing_unit_test.go | 9 +++++++ ..._queue_outbound_email_address_unit_test.go | 9 +++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..7f3282bd6 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,27 @@ +name: Unit Tests +on: + push: + paths-ignore: + - 'README.md' +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.20' + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Run Unit Tests + env: + TF_UNIT: '*' + ENABLE_STANDALONE_CGR: 'true' + ENABLE_STANDALONE_EMAIL_ADDRESS: 'true' + run: | + go test ./genesyscloud/... -v -run TestUnit \ No newline at end of file diff --git a/genesyscloud/architect_ivr/genesyscloud_architect_ivr_proxy_unit_test.go b/genesyscloud/architect_ivr/genesyscloud_architect_ivr_proxy_unit_test.go index a49095e59..f2cce00a6 100644 --- a/genesyscloud/architect_ivr/genesyscloud_architect_ivr_proxy_unit_test.go +++ b/genesyscloud/architect_ivr/genesyscloud_architect_ivr_proxy_unit_test.go @@ -87,8 +87,8 @@ func TestUnitUploadIvrDnisChunksError(t *testing.T) { mockGetError = fmt.Errorf("error on proxy.GetArchitectIvr") mockPostError = fmt.Errorf("error on proxy.PostArchitectIvr") mockPutError = fmt.Errorf("error on proxy.PutArchitectIvr") - dnis = []string{"123", "abc", "iii", "zzz"} maxDnisPerRequest = 2 + dnis = []string{"123", "abc", "iii", "zzz"} ) ivr := platformclientv2.Ivr{ @@ -98,7 +98,7 @@ func TestUnitUploadIvrDnisChunksError(t *testing.T) { architectProxy := newArchitectIvrProxy(nil) architectProxy.maxDnisPerRequest = maxDnisPerRequest - // will be called on create after a chunk update fails because the ivr will need to be manually taken down, in that case + // Will be called on create after a chunk update fails because the ivr will need to be manually taken down, in that case architectProxy.deleteArchitectIvrAttr = createMockDeleteIvrFunc(nil) testCases := []architectIvrUploadErrorTestData{ diff --git a/genesyscloud/routing_queue_conditional_group_routing/resource_genesyscloud_routing_queue_conditional_group_routing_unit_test.go b/genesyscloud/routing_queue_conditional_group_routing/resource_genesyscloud_routing_queue_conditional_group_routing_unit_test.go index fc4f84f7f..0d23ea6a7 100644 --- a/genesyscloud/routing_queue_conditional_group_routing/resource_genesyscloud_routing_queue_conditional_group_routing_unit_test.go +++ b/genesyscloud/routing_queue_conditional_group_routing/resource_genesyscloud_routing_queue_conditional_group_routing_unit_test.go @@ -4,6 +4,7 @@ import ( "context" "net/http" "terraform-provider-genesyscloud/genesyscloud/provider" + featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles" "testing" "github.com/google/go-cmp/cmp" @@ -18,6 +19,10 @@ func TestUnitResourceRoutingQueueConditionalGroupRoutingUpdate(t *testing.T) { tRules := generateRuleData() tId := tQueueId + "/rules" + if !featureToggles.CSGToggleExists() { + t.Skipf("Skipping because %s env variable is not set", featureToggles.CSGToggleName()) + } + groupRoutingProxy := &routingQueueConditionalGroupRoutingProxy{} groupRoutingProxy.updateRoutingQueueConditionRoutingAttr = func(ctx context.Context, p *routingQueueConditionalGroupRoutingProxy, queueId string, rules *[]platformclientv2.Conditionalgrouproutingrule) (*[]platformclientv2.Conditionalgrouproutingrule, *platformclientv2.APIResponse, error) { equal := cmp.Equal(tRules, *rules) @@ -57,6 +62,10 @@ func TestUnitResourceRoutingQueueConditionalGroupRoutingRead(t *testing.T) { tRules := generateRuleData() tId := tQueueId + "/rules" + if !featureToggles.CSGToggleExists() { + t.Skipf("Skipping because %s env variable is not set", featureToggles.CSGToggleName()) + } + groupRoutingProxy := &routingQueueConditionalGroupRoutingProxy{} groupRoutingProxy.getRoutingQueueConditionRoutingAttr = func(ctx context.Context, p *routingQueueConditionalGroupRoutingProxy, queueId string) (*[]platformclientv2.Conditionalgrouproutingrule, *platformclientv2.APIResponse, error) { diff --git a/genesyscloud/routing_queue_outbound_email_address/resource_genesyscloud_routing_queue_outbound_email_address_unit_test.go b/genesyscloud/routing_queue_outbound_email_address/resource_genesyscloud_routing_queue_outbound_email_address_unit_test.go index 00f239f42..7ac363a35 100644 --- a/genesyscloud/routing_queue_outbound_email_address/resource_genesyscloud_routing_queue_outbound_email_address_unit_test.go +++ b/genesyscloud/routing_queue_outbound_email_address/resource_genesyscloud_routing_queue_outbound_email_address_unit_test.go @@ -4,6 +4,7 @@ import ( "context" "net/http" "terraform-provider-genesyscloud/genesyscloud/provider" + featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles" "testing" "github.com/google/uuid" @@ -19,6 +20,10 @@ func TestUnitResourceRoutingQueueOutboundEmailAddressUpdate(t *testing.T) { tId := tQueueId + if !featureToggles.OEAToggleExists() { + t.Skipf("Skipping because env variable %s is not set", featureToggles.OEAToggleName()) + } + groupRoutingProxy := &routingQueueOutboundEmailAddressProxy{} groupRoutingProxy.updateRoutingQueueOutboundEmailAddressAttr = func(ctx context.Context, p *routingQueueOutboundEmailAddressProxy, queueId string, address *platformclientv2.Queueemailaddress) (*platformclientv2.Queueemailaddress, *platformclientv2.APIResponse, error) { assert.Equal(t, tDomainId, *address.Domain.Id) @@ -71,6 +76,10 @@ func TestUnitResourceRoutingQueueOutboundEmailAddressRead(t *testing.T) { tRouteId := uuid.NewString() tId := tQueueId + if !featureToggles.OEAToggleExists() { + t.Skipf("Skipping because env variable %s is not set", featureToggles.OEAToggleName()) + } + groupRoutingProxy := &routingQueueOutboundEmailAddressProxy{} groupRoutingProxy.getRoutingQueueOutboundEmailAddressAttr = func(ctx context.Context, p *routingQueueOutboundEmailAddressProxy, queueId string) (*platformclientv2.Queueemailaddress, *platformclientv2.APIResponse, error) { From 925ae74dc47103808864c0537a9047561bc3fc51 Mon Sep 17 00:00:00 2001 From: Brian Moyles <157126600+BrianMoyles@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:13:27 +0100 Subject: [PATCH 2/2] Refactor/devtooling-188: Routing Skill (#1183) * Added Routing Skill Package * refactored routing skill * Fixing merge conflicts --- .../data_source_genesyscloud_routing_skill.go | 129 -------------- .../resource_genesyscloud_outbound_ruleset.go | 4 +- genesyscloud/resource_genesyscloud_init.go | 3 - .../resource_genesyscloud_init_test.go | 5 +- .../resource_genesyscloud_routing_skill.go | 163 ------------------ .../resource_genesyscloud_user_test.go | 10 +- ...esyscloud_routing_email_route_init_test.go | 5 +- ...e_genesyscloud_routing_email_route_test.go | 10 +- .../genesyscloud_routing_queue_init_test.go | 3 +- ...esource_genesyscloud_routing_queue_test.go | 5 +- .../data_source_genesyscloud_routing_skill.go | 78 +++++++++ ..._source_genesyscloud_routing_skill_test.go | 5 +- .../genesyscloud_routing_skill_init_test.go | 52 ++++++ .../genesyscloud_routing_skill_proxy.go | 145 ++++++++++++++++ .../resource_genesyscloud_routing_skill.go | 122 +++++++++++++ ...ource_genesyscloud_routing_skill_schema.go | 62 +++++++ ...esource_genesyscloud_routing_skill_test.go | 2 +- ...esyscloud_routing_skill_group_init_test.go | 3 +- ...e_genesyscloud_routing_skill_group_test.go | 3 +- ...loud_task_management_workitem_init_test.go | 4 +- ...esyscloud_task_management_workitem_test.go | 4 +- ...loud_task_management_worktype_init_test.go | 3 +- ...esyscloud_task_management_worktype_test.go | 7 +- .../tfexporter/tf_exporter_resource_test.go | 5 +- main.go | 3 +- 25 files changed, 508 insertions(+), 327 deletions(-) delete mode 100644 genesyscloud/data_source_genesyscloud_routing_skill.go delete mode 100644 genesyscloud/resource_genesyscloud_routing_skill.go create mode 100644 genesyscloud/routing_skill/data_source_genesyscloud_routing_skill.go rename genesyscloud/{ => routing_skill}/data_source_genesyscloud_routing_skill_test.go (98%) create mode 100644 genesyscloud/routing_skill/genesyscloud_routing_skill_init_test.go create mode 100644 genesyscloud/routing_skill/genesyscloud_routing_skill_proxy.go create mode 100644 genesyscloud/routing_skill/resource_genesyscloud_routing_skill.go create mode 100644 genesyscloud/routing_skill/resource_genesyscloud_routing_skill_schema.go rename genesyscloud/{ => routing_skill}/resource_genesyscloud_routing_skill_test.go (98%) diff --git a/genesyscloud/data_source_genesyscloud_routing_skill.go b/genesyscloud/data_source_genesyscloud_routing_skill.go deleted file mode 100644 index bf82e832d..000000000 --- a/genesyscloud/data_source_genesyscloud_routing_skill.go +++ /dev/null @@ -1,129 +0,0 @@ -package genesyscloud - -import ( - "context" - "fmt" - "log" - "terraform-provider-genesyscloud/genesyscloud/provider" - rc "terraform-provider-genesyscloud/genesyscloud/resource_cache" - "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" -) - -// The context is now added without Timeout , -// since the warming up of cache will take place for the first Datasource registered during a Terraform Apply. -func dataSourceRoutingSkill() *schema.Resource { - return &schema.Resource{ - Description: "Data source for Genesys Cloud Routing Skills. Select a skill by name.", - ReadWithoutTimeout: provider.ReadWithPooledClient(dataSourceRoutingSkillRead), - Schema: map[string]*schema.Schema{ - "name": { - Description: "Skill name.", - Type: schema.TypeString, - Required: true, - }, - }, - } -} - -var ( - dataSourceRoutingSkillCache *rc.DataSourceCache -) - -func dataSourceRoutingSkillRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - sdkConfig := m.(*provider.ProviderMeta).ClientConfig - - key := d.Get("name").(string) - - if dataSourceRoutingSkillCache == nil { - dataSourceRoutingSkillCache = rc.NewDataSourceCache(sdkConfig, hydrateRoutingSkillCacheFn, getSkillByNameFn) - } - - queueId, err := rc.RetrieveId(dataSourceRoutingSkillCache, "genesyscloud_routing_skill", key, ctx) - - if err != nil { - return err - } - - d.SetId(queueId) - return nil -} - -func hydrateRoutingSkillCacheFn(c *rc.DataSourceCache) error { - log.Printf("hydrating cache for data source genesyscloud_routing_skill") - - routingApi := platformclientv2.NewRoutingApiWithConfig(c.ClientConfig) - const pageSize = 100 - skills, _, getErr := routingApi.GetRoutingSkills(pageSize, 1, "", nil) - - if getErr != nil { - return fmt.Errorf("failed to get page of skills: %v", getErr) - } - - if skills.Entities == nil || len(*skills.Entities) == 0 { - return nil - } - - for _, skill := range *skills.Entities { - c.Cache[*skill.Name] = *skill.Id - } - - for pageNum := 2; pageNum <= *skills.PageCount; pageNum++ { - - log.Printf("calling cache for data source genesyscloud_routing_skill") - - skills, _, getErr := routingApi.GetRoutingSkills(pageSize, pageNum, "", nil) - log.Printf("calling cache for data source genesyscloud_routing_skill %v", pageNum) - if getErr != nil { - return fmt.Errorf("failed to get page of skills: %v", getErr) - } - - if skills.Entities == nil || len(*skills.Entities) == 0 { - break - } - - // Add ids to cache - for _, skill := range *skills.Entities { - c.Cache[*skill.Name] = *skill.Id - } - } - - log.Printf("cache hydration completed for data source genesyscloud_routing_skill") - - return nil -} - -func getSkillByNameFn(c *rc.DataSourceCache, name string, ctx context.Context) (string, diag.Diagnostics) { - const pageSize = 100 - skillId := "" - routingAPI := platformclientv2.NewRoutingApiWithConfig(c.ClientConfig) - - // Find first non-deleted skill by name. Retry in case new skill is not yet indexed by search - diag := util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { - for pageNum := 1; ; pageNum++ { - skills, resp, getErr := routingAPI.GetRoutingSkills(pageSize, pageNum, name, nil) - if getErr != nil { - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("error requesting skill %s | error: %s", name, getErr), resp)) - } - - if skills.Entities == nil || len(*skills.Entities) == 0 { - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("no routing skills found with name %s", name), resp)) - } - - for _, skill := range *skills.Entities { - if skill.Name != nil && *skill.Name == name && - skill.State != nil && *skill.State != "deleted" { - skillId = *skill.Id - return nil - } - } - } - }) - return skillId, diag -} diff --git a/genesyscloud/outbound_ruleset/resource_genesyscloud_outbound_ruleset.go b/genesyscloud/outbound_ruleset/resource_genesyscloud_outbound_ruleset.go index 932a5cda7..abab08551 100644 --- a/genesyscloud/outbound_ruleset/resource_genesyscloud_outbound_ruleset.go +++ b/genesyscloud/outbound_ruleset/resource_genesyscloud_outbound_ruleset.go @@ -13,7 +13,7 @@ import ( "terraform-provider-genesyscloud/genesyscloud/consistency_checker" - gcloud "terraform-provider-genesyscloud/genesyscloud" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" resourceExporter "terraform-provider-genesyscloud/genesyscloud/resource_exporter" "terraform-provider-genesyscloud/genesyscloud/util/resourcedata" @@ -38,7 +38,7 @@ func getAllAuthOutboundRuleset(ctx context.Context, clientConfig *platformclient } // DEVTOOLING-319: filters rule sets by removing the ones that reference skills that no longer exist in GC - skillExporter := gcloud.RoutingSkillExporter() + skillExporter := routingSkill.RoutingSkillExporter() skillMap, skillErr := skillExporter.GetResourcesFunc(ctx) if skillErr != nil { return nil, util.BuildDiagnosticError(resourceName, fmt.Sprintf("Failed to get skill resources"), fmt.Errorf("%v", skillErr)) diff --git a/genesyscloud/resource_genesyscloud_init.go b/genesyscloud/resource_genesyscloud_init.go index 59ebc8b61..ca549551f 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_skill", dataSourceRoutingSkill()) l.RegisterDataSource("genesyscloud_routing_wrapupcode", DataSourceRoutingWrapupcode()) l.RegisterDataSource("genesyscloud_user", DataSourceUser()) l.RegisterDataSource("genesyscloud_widget_deployment", dataSourceWidgetDeployments()) @@ -53,7 +52,6 @@ func registerResources(l registrar.Registrar) { l.RegisterResource("genesyscloud_location", ResourceLocation()) l.RegisterResource("genesyscloud_quality_forms_evaluation", ResourceEvaluationForm()) l.RegisterResource("genesyscloud_quality_forms_survey", ResourceSurveyForm()) - l.RegisterResource("genesyscloud_routing_skill", ResourceRoutingSkill()) l.RegisterResource("genesyscloud_routing_wrapupcode", ResourceRoutingWrapupCode()) l.RegisterResource("genesyscloud_user", ResourceUser()) l.RegisterResource("genesyscloud_widget_deployment", ResourceWidgetDeployment()) @@ -72,7 +70,6 @@ func registerExporters(l registrar.Registrar) { l.RegisterExporter("genesyscloud_location", LocationExporter()) l.RegisterExporter("genesyscloud_quality_forms_evaluation", EvaluationFormExporter()) l.RegisterExporter("genesyscloud_quality_forms_survey", SurveyFormExporter()) - l.RegisterExporter("genesyscloud_routing_skill", RoutingSkillExporter()) l.RegisterExporter("genesyscloud_routing_wrapupcode", RoutingWrapupCodeExporter()) l.RegisterExporter("genesyscloud_user", UserExporter()) l.RegisterExporter("genesyscloud_widget_deployment", WidgetDeploymentExporter()) diff --git a/genesyscloud/resource_genesyscloud_init_test.go b/genesyscloud/resource_genesyscloud_init_test.go index 08137254f..23c9a3aa1 100644 --- a/genesyscloud/resource_genesyscloud_init_test.go +++ b/genesyscloud/resource_genesyscloud_init_test.go @@ -15,6 +15,7 @@ import ( routingSettings "terraform-provider-genesyscloud/genesyscloud/routing_settings" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" extensionPool "terraform-provider-genesyscloud/genesyscloud/telephony_providers_edges_extension_pool" routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" "testing" @@ -60,8 +61,8 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_quality_forms_survey"] = ResourceSurveyForm() providerResources["genesyscloud_routing_language"] = routinglanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_email_domain"] = routingEmailDomain.ResourceRoutingEmailDomain() - providerResources["genesyscloud_routing_skill"] = ResourceRoutingSkill() providerResources["genesyscloud_routing_skill_group"] = routingSkillGroup.ResourceRoutingSkillGroup() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() providerResources["genesyscloud_routing_settings"] = routingSettings.ResourceRoutingSettings() providerResources["genesyscloud_routing_utilization"] = routingUtilization.ResourceRoutingUtilization() providerResources["genesyscloud_routing_wrapupcode"] = ResourceRoutingWrapupCode() @@ -99,7 +100,7 @@ func (r *registerTestInstance) registerTestDataSources() { providerDataSources["genesyscloud_quality_forms_evaluation"] = DataSourceQualityFormsEvaluations() providerDataSources["genesyscloud_quality_forms_survey"] = dataSourceQualityFormsSurvey() providerDataSources["genesyscloud_routing_language"] = routinglanguage.DataSourceRoutingLanguage() - providerDataSources["genesyscloud_routing_skill"] = dataSourceRoutingSkill() + providerDataSources["genesyscloud_routing_skill"] = routingSkill.DataSourceRoutingSkill() providerDataSources["genesyscloud_routing_email_domain"] = routingEmailDomain.DataSourceRoutingEmailDomain() providerDataSources["genesyscloud_routing_skill_group"] = routingSkillGroup.DataSourceRoutingSkillGroup() providerDataSources["genesyscloud_routing_wrapupcode"] = DataSourceRoutingWrapupcode() diff --git a/genesyscloud/resource_genesyscloud_routing_skill.go b/genesyscloud/resource_genesyscloud_routing_skill.go deleted file mode 100644 index 33093ab37..000000000 --- a/genesyscloud/resource_genesyscloud_routing_skill.go +++ /dev/null @@ -1,163 +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 getAllRoutingSkills(_ context.Context, clientConfig *platformclientv2.Configuration) (resourceExporter.ResourceIDMetaMap, diag.Diagnostics) { - resources := make(resourceExporter.ResourceIDMetaMap) - routingAPI := platformclientv2.NewRoutingApiWithConfig(clientConfig) - - for pageNum := 1; ; pageNum++ { - const pageSize = 100 - skills, resp, getErr := routingAPI.GetRoutingSkills(pageSize, pageNum, "", nil) - if getErr != nil { - return nil, util.BuildAPIDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Failed to get skills error: %s", getErr), resp) - } - - if skills.Entities == nil || len(*skills.Entities) == 0 { - break - } - - for _, skill := range *skills.Entities { - if skill.State != nil && *skill.State != "deleted" { - resources[*skill.Id] = &resourceExporter.ResourceMeta{Name: *skill.Name} - } - } - } - - return resources, nil -} - -func RoutingSkillExporter() *resourceExporter.ResourceExporter { - return &resourceExporter.ResourceExporter{ - GetResourcesFunc: provider.GetAllWithPooledClient(getAllRoutingSkills), - RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references - } -} - -func ResourceRoutingSkill() *schema.Resource { - return &schema.Resource{ - Description: "Genesys Cloud Routing Skill", - - CreateContext: provider.CreateWithPooledClient(createRoutingSkill), - ReadContext: provider.ReadWithPooledClient(readRoutingSkill), - DeleteContext: provider.DeleteWithPooledClient(deleteRoutingSkill), - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - SchemaVersion: 1, - Schema: map[string]*schema.Schema{ - "name": { - Description: "Skill name. Changing the name attribute will cause the skill object object to dropped and recreated with a new ID.", - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - } -} - -func createRoutingSkill(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 skill %s", name) - skill, resp, err := routingAPI.PostRoutingSkills(platformclientv2.Routingskill{ - Name: &name, - }) - if err != nil { - return util.BuildAPIDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Failed to create skill %s error: %s", name, err), resp) - } - - d.SetId(*skill.Id) - - log.Printf("Created skill %s %s", name, *skill.Id) - return readRoutingSkill(ctx, d, meta) -} - -func readRoutingSkill(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, ResourceRoutingSkill(), constants.DefaultConsistencyChecks, "genesyscloud_routing_skill") - - log.Printf("Reading skill %s", d.Id()) - return util.WithRetriesForRead(ctx, d, func() *retry.RetryError { - skill, resp, getErr := routingAPI.GetRoutingSkill(d.Id()) - if getErr != nil { - if util.IsStatus404(resp) { - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Failed to read skill %s | error: %s", d.Id(), getErr), resp)) - } - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Failed to read skill %s | error: %s", d.Id(), getErr), resp)) - } - - if skill.State != nil && *skill.State == "deleted" { - d.SetId("") - return nil - } - - d.Set("name", *skill.Name) - log.Printf("Read skill %s %s", d.Id(), *skill.Name) - return cc.CheckState(d) - }) -} - -func deleteRoutingSkill(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 skill %s", name) - resp, err := routingAPI.DeleteRoutingSkill(d.Id()) - if err != nil { - return util.BuildAPIDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Failed to delete skill %s error: %s", name, err), resp) - } - - return util.WithRetries(ctx, 30*time.Second, func() *retry.RetryError { - routingSkill, resp, err := routingAPI.GetRoutingSkill(d.Id()) - if err != nil { - if util.IsStatus404(resp) { - // Routing skill deleted - log.Printf("Deleted Routing skill %s", d.Id()) - return nil - } - return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Error deleting Routing skill %s | error: %s", d.Id(), err), resp)) - } - - if routingSkill.State != nil && *routingSkill.State == "deleted" { - // Routing skill deleted - log.Printf("Deleted Routing skill %s", d.Id()) - return nil - } - - return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError("genesyscloud_routing_skill", fmt.Sprintf("Routing skill %s still exists", d.Id()), resp)) - }) -} - -func GenerateRoutingSkillResource( - resourceID string, - name string) string { - return fmt.Sprintf(`resource "genesyscloud_routing_skill" "%s" { - name = "%s" - } - `, resourceID, name) -} diff --git a/genesyscloud/resource_genesyscloud_user_test.go b/genesyscloud/resource_genesyscloud_user_test.go index 9fefdec8d..0f3c3b4fe 100644 --- a/genesyscloud/resource_genesyscloud_user_test.go +++ b/genesyscloud/resource_genesyscloud_user_test.go @@ -10,6 +10,8 @@ import ( routinglanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" + extensionPool "terraform-provider-genesyscloud/genesyscloud/telephony_providers_edges_extension_pool" "terraform-provider-genesyscloud/genesyscloud/util" "testing" @@ -466,7 +468,7 @@ func TestAccResourceUserSkills(t *testing.T) { email1, userName1, generateUserRoutingSkill("genesyscloud_routing_skill."+skillResource1+".id", proficiency1), - ) + GenerateRoutingSkillResource(skillResource1, skillName1), + ) + routingSkill.GenerateRoutingSkillResource(skillResource1, skillName1), Check: resource.ComposeTestCheckFunc( validateUserSkill("genesyscloud_user."+userResource1, "genesyscloud_routing_skill."+skillResource1, proficiency1), ), @@ -479,10 +481,10 @@ func TestAccResourceUserSkills(t *testing.T) { userName1, generateUserRoutingSkill("genesyscloud_routing_skill."+skillResource1+".id", proficiency1), generateUserRoutingSkill("genesyscloud_routing_skill."+skillResource2+".id", proficiency2), - ) + GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource1, skillName1, - ) + GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource2, skillName2, ), @@ -498,7 +500,7 @@ func TestAccResourceUserSkills(t *testing.T) { email1, userName1, generateUserRoutingSkill("genesyscloud_routing_skill."+skillResource2+".id", proficiency1), - ) + GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource2, skillName2, ), 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 d4f4392b3..b34fcae5b 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 @@ -2,13 +2,14 @@ package routing_email_route import ( "sync" - "terraform-provider-genesyscloud/genesyscloud" routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" architectFlow "terraform-provider-genesyscloud/genesyscloud/architect_flow" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingEmailDomain "terraform-provider-genesyscloud/genesyscloud/routing_email_domain" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" + "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -39,7 +40,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_routing_email_domain"] = routingEmailDomain.ResourceRoutingEmailDomain() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() - providerResources["genesyscloud_routing_skill"] = genesyscloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() providerResources["genesyscloud_flow"] = architectFlow.ResourceArchitectFlow() providerResources["genesyscloud_routing_skill_group"] = routingSkillGroup.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 e8ebb5b46..700aaa04a 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 @@ -5,12 +5,12 @@ import ( "log" "regexp" "strings" - gcloud "terraform-provider-genesyscloud/genesyscloud" "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" routingEmailDomain "terraform-provider-genesyscloud/genesyscloud/routing_email_domain" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" "terraform-provider-genesyscloud/genesyscloud/util" "testing" @@ -130,7 +130,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, - ) + gcloud.GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource, skillName, ) + architect_flow.GenerateFlowResource( @@ -202,7 +202,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, - ) + gcloud.GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource, skillName, ) + GenerateRoutingEmailRouteResource( @@ -259,7 +259,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, - ) + gcloud.GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource, skillName, ) + GenerateRoutingEmailRouteResource( @@ -321,7 +321,7 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { ) + routingLanguage.GenerateRoutingLanguageResource( langResource, langName, - ) + gcloud.GenerateRoutingSkillResource( + ) + routingSkill.GenerateRoutingSkillResource( skillResource, skillName, ) + GenerateRoutingEmailRouteResource( diff --git a/genesyscloud/routing_queue/genesyscloud_routing_queue_init_test.go b/genesyscloud/routing_queue/genesyscloud_routing_queue_init_test.go index 09caba543..953cf461c 100644 --- a/genesyscloud/routing_queue/genesyscloud_routing_queue_init_test.go +++ b/genesyscloud/routing_queue/genesyscloud_routing_queue_init_test.go @@ -8,6 +8,7 @@ import ( "terraform-provider-genesyscloud/genesyscloud/group" routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" "testing" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +36,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources[resourceName] = ResourceRoutingQueue() providerResources["genesyscloud_user"] = gcloud.ResourceUser() - providerResources["genesyscloud_routing_skill"] = gcloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() providerResources["genesyscloud_group"] = group.ResourceGroup() providerResources["genesyscloud_routing_wrapupcode"] = gcloud.ResourceRoutingWrapupCode() providerResources["genesyscloud_flow"] = architectFlow.ResourceArchitectFlow() diff --git a/genesyscloud/routing_queue/resource_genesyscloud_routing_queue_test.go b/genesyscloud/routing_queue/resource_genesyscloud_routing_queue_test.go index 9ada4f718..fe1a4e13f 100644 --- a/genesyscloud/routing_queue/resource_genesyscloud_routing_queue_test.go +++ b/genesyscloud/routing_queue/resource_genesyscloud_routing_queue_test.go @@ -14,6 +14,7 @@ import ( routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" "terraform-provider-genesyscloud/genesyscloud/util" featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" "terraform-provider-genesyscloud/genesyscloud/util/testrunner" "testing" "time" @@ -69,7 +70,7 @@ func TestAccResourceRoutingQueueBasic(t *testing.T) { Steps: []resource.TestStep{ { // Create - Config: generateUserWithCustomAttrs(testUserResource, testUserEmail, testUserName) + genesyscloud.GenerateRoutingSkillResource(queueSkillResource, queueSkillName) + + Config: generateUserWithCustomAttrs(testUserResource, testUserEmail, testUserName) + routingSkill.GenerateRoutingSkillResource(queueSkillResource, queueSkillName) + group.GenerateGroupResource( bullseyeMemberGroupName, "MySeries6Groupv20", @@ -829,7 +830,7 @@ func TestAccResourceRoutingQueueSkillgroupMembers(t *testing.T) { ProviderFactories: provider.GetProviderFactories(providerResources, providerDataSources), Steps: []resource.TestStep{ { - Config: genesyscloud.GenerateRoutingSkillResource( + Config: routingSkill.GenerateRoutingSkillResource( skillResourceId, skillName, ) + skillGroupConfig + user2Config + diff --git a/genesyscloud/routing_skill/data_source_genesyscloud_routing_skill.go b/genesyscloud/routing_skill/data_source_genesyscloud_routing_skill.go new file mode 100644 index 000000000..4b89dac5b --- /dev/null +++ b/genesyscloud/routing_skill/data_source_genesyscloud_routing_skill.go @@ -0,0 +1,78 @@ +package routing_skill + +import ( + "context" + "fmt" + "log" + "terraform-provider-genesyscloud/genesyscloud/provider" + rc "terraform-provider-genesyscloud/genesyscloud/resource_cache" + "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" +) + +var dataSourceRoutingSkillCache *rc.DataSourceCache + +func dataSourceRoutingSkillRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + sdkConfig := m.(*provider.ProviderMeta).ClientConfig + key := d.Get("name").(string) + + if dataSourceRoutingSkillCache == nil { + dataSourceRoutingSkillCache = rc.NewDataSourceCache(sdkConfig, hydrateRoutingSkillCacheFn, getSkillByNameFn) + } + + queueId, err := rc.RetrieveId(dataSourceRoutingSkillCache, resourceName, key, ctx) + if err != nil { + return err + } + + d.SetId(queueId) + return nil +} + +func hydrateRoutingSkillCacheFn(c *rc.DataSourceCache) error { + log.Printf("hydrating cache for data source genesyscloud_routing_skill") + proxy := getRoutingSkillProxy(c.ClientConfig) + + skills, resp, getErr := proxy.getAllRoutingSkills(context.TODO(), "") + if getErr != nil { + return fmt.Errorf("failed to get page of skills: %v %v", getErr, resp) + } + + if skills == nil || len(*skills) == 0 { + return nil + } + + for _, skill := range *skills { + c.Cache[*skill.Name] = *skill.Id + } + + log.Printf("cache hydration completed for data source genesyscloud_routing_skill") + + return nil +} + +func getSkillByNameFn(c *rc.DataSourceCache, name string, ctx context.Context) (string, diag.Diagnostics) { + skillId := "" + proxy := getRoutingSkillProxy(c.ClientConfig) + + // Find first non-deleted skill by name. Retry in case new skill is not yet indexed by search + diag := util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { + skill, resp, retryable, getErr := proxy.getRoutingSkillIdByName(ctx, name) + if getErr != nil && !retryable { + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("error requesting skill %s | error: %s", name, getErr), resp)) + } + + if retryable { + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("no routing skills found with name %s", name), resp)) + } + + skillId = skill + return nil + }) + return skillId, diag +} diff --git a/genesyscloud/data_source_genesyscloud_routing_skill_test.go b/genesyscloud/routing_skill/data_source_genesyscloud_routing_skill_test.go similarity index 98% rename from genesyscloud/data_source_genesyscloud_routing_skill_test.go rename to genesyscloud/routing_skill/data_source_genesyscloud_routing_skill_test.go index 424fdc8d2..cd565b3f3 100644 --- a/genesyscloud/data_source_genesyscloud_routing_skill_test.go +++ b/genesyscloud/routing_skill/data_source_genesyscloud_routing_skill_test.go @@ -1,14 +1,15 @@ -package genesyscloud +package routing_skill import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "log" "terraform-provider-genesyscloud/genesyscloud/provider" "terraform-provider-genesyscloud/genesyscloud/util" "testing" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) diff --git a/genesyscloud/routing_skill/genesyscloud_routing_skill_init_test.go b/genesyscloud/routing_skill/genesyscloud_routing_skill_init_test.go new file mode 100644 index 000000000..618bf2ce9 --- /dev/null +++ b/genesyscloud/routing_skill/genesyscloud_routing_skill_init_test.go @@ -0,0 +1,52 @@ +package routing_skill + +import ( + "sync" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var providerDataSources map[string]*schema.Resource +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] = ResourceRoutingSkill() +} + +// registerTestDataSources registers all data sources used in the tests. +func (r *registerTestInstance) registerTestDataSources() { + r.datasourceMapMutex.Lock() + defer r.datasourceMapMutex.Unlock() + + providerDataSources[resourceName] = DataSourceRoutingSkill() +} + +// 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.registerTestDataSources() + regInstance.registerTestResources() +} + +// 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_skill package + initTestResources() + + // Run the test suite for the routing_skill package + m.Run() +} diff --git a/genesyscloud/routing_skill/genesyscloud_routing_skill_proxy.go b/genesyscloud/routing_skill/genesyscloud_routing_skill_proxy.go new file mode 100644 index 000000000..12ade10ec --- /dev/null +++ b/genesyscloud/routing_skill/genesyscloud_routing_skill_proxy.go @@ -0,0 +1,145 @@ +package routing_skill + +import ( + "context" + "fmt" + "log" + rc "terraform-provider-genesyscloud/genesyscloud/resource_cache" + + "github.com/mypurecloud/platform-client-sdk-go/v133/platformclientv2" +) + +var internalProxy *routingSkillProxy + +type getAllRoutingSkillsFunc func(ctx context.Context, p *routingSkillProxy, name string) (*[]platformclientv2.Routingskill, *platformclientv2.APIResponse, error) +type createRoutingSkillFunc func(ctx context.Context, p *routingSkillProxy, routingSkill *platformclientv2.Routingskill) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) +type getRoutingSkillByIdFunc func(ctx context.Context, p *routingSkillProxy, id string) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) +type getRoutingSkillIdByNameFunc func(ctx context.Context, p *routingSkillProxy, name string) (string, *platformclientv2.APIResponse, bool, error) +type deleteRoutingSkillFunc func(ctx context.Context, p *routingSkillProxy, id string) (*platformclientv2.APIResponse, error) + +// routingSkillProxy contains all of the methods that call genesys cloud APIs. +type routingSkillProxy struct { + clientConfig *platformclientv2.Configuration + routingApi *platformclientv2.RoutingApi + createRoutingSkillAttr createRoutingSkillFunc + getAllRoutingSkillsAttr getAllRoutingSkillsFunc + getRoutingSkillIdByNameAttr getRoutingSkillIdByNameFunc + getRoutingSkillByIdAttr getRoutingSkillByIdFunc + deleteRoutingSkillAttr deleteRoutingSkillFunc + routingCache rc.CacheInterface[platformclientv2.Routingskill] +} + +// newRoutingSkillProxy initializes the routing skill proxy with all of the data needed to communicate with Genesys Cloud +func newRoutingSkillProxy(clientConfig *platformclientv2.Configuration) *routingSkillProxy { + api := platformclientv2.NewRoutingApiWithConfig(clientConfig) + routingCache := rc.NewResourceCache[platformclientv2.Routingskill]() + return &routingSkillProxy{ + clientConfig: clientConfig, + routingApi: api, + createRoutingSkillAttr: createRoutingSkillFn, + getAllRoutingSkillsAttr: getAllRoutingSkillsFn, + getRoutingSkillIdByNameAttr: getRoutingSkillIdByNameFn, + getRoutingSkillByIdAttr: getRoutingSkillByIdFn, + deleteRoutingSkillAttr: deleteRoutingSkillFn, + routingCache: routingCache, + } +} + +func getRoutingSkillProxy(clientConfig *platformclientv2.Configuration) *routingSkillProxy { + if internalProxy == nil { + internalProxy = newRoutingSkillProxy(clientConfig) + } + + return internalProxy +} + +func (p *routingSkillProxy) getAllRoutingSkills(ctx context.Context, name string) (*[]platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + return p.getAllRoutingSkillsAttr(ctx, p, name) +} + +func (p *routingSkillProxy) createRoutingSkill(ctx context.Context, routingSkill *platformclientv2.Routingskill) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + return p.createRoutingSkillAttr(ctx, p, routingSkill) +} + +func (p *routingSkillProxy) getRoutingSkillById(ctx context.Context, id string) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + return p.getRoutingSkillByIdAttr(ctx, p, id) +} + +func (p *routingSkillProxy) getRoutingSkillIdByName(ctx context.Context, name string) (string, *platformclientv2.APIResponse, bool, error) { + return p.getRoutingSkillIdByNameAttr(ctx, p, name) +} + +func (p *routingSkillProxy) deleteRoutingSkill(ctx context.Context, id string) (*platformclientv2.APIResponse, error) { + return p.deleteRoutingSkillAttr(ctx, p, id) +} + +func getAllRoutingSkillsFn(ctx context.Context, p *routingSkillProxy, name string) (*[]platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + var allRoutingSkills []platformclientv2.Routingskill + const pageSize = 100 + + routingSkills, resp, err := p.routingApi.GetRoutingSkills(pageSize, 1, name, nil) + if err != nil { + return nil, resp, err + } + + if routingSkills.Entities == nil || len(*routingSkills.Entities) == 0 { + return &allRoutingSkills, resp, nil + } + + allRoutingSkills = append(allRoutingSkills, *routingSkills.Entities...) + + for pageNum := 2; pageNum <= *routingSkills.PageCount; pageNum++ { + routingSkills, _, err := p.routingApi.GetRoutingSkills(pageSize, pageNum, name, nil) + if err != nil { + return nil, resp, err + } + + if routingSkills.Entities == nil || len(*routingSkills.Entities) == 0 { + break + } + + allRoutingSkills = append(allRoutingSkills, *routingSkills.Entities...) + + } + + for _, skill := range allRoutingSkills { + rc.SetCache(p.routingCache, *skill.Id, skill) + } + + return &allRoutingSkills, resp, nil +} + +func createRoutingSkillFn(ctx context.Context, p *routingSkillProxy, routingSkill *platformclientv2.Routingskill) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + return p.routingApi.PostRoutingSkills(*routingSkill) +} + +func getRoutingSkillByIdFn(ctx context.Context, p *routingSkillProxy, id string) (*platformclientv2.Routingskill, *platformclientv2.APIResponse, error) { + if skill := rc.GetCacheItem(p.routingCache, id); skill != nil { + return skill, nil, nil + } + return p.routingApi.GetRoutingSkill(id) +} + +func getRoutingSkillIdByNameFn(ctx context.Context, p *routingSkillProxy, name string) (string, *platformclientv2.APIResponse, bool, error) { + routingSkills, resp, err := getAllRoutingSkillsFn(ctx, p, name) + if err != nil { + return "", resp, false, err + } + + if routingSkills == nil || len(*routingSkills) == 0 { + return "", resp, true, err + } + + for _, routingSkill := range *routingSkills { + if *routingSkill.Name == name { + log.Printf("Retrieved the routing skill id %s by name %s", *routingSkill.Id, name) + return *routingSkill.Id, resp, false, nil + } + } + + return "", resp, true, fmt.Errorf("unable to find routing skill with name %s", name) +} + +func deleteRoutingSkillFn(ctx context.Context, p *routingSkillProxy, id string) (*platformclientv2.APIResponse, error) { + return p.routingApi.DeleteRoutingSkill(id) +} diff --git a/genesyscloud/routing_skill/resource_genesyscloud_routing_skill.go b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill.go new file mode 100644 index 000000000..7c8693c96 --- /dev/null +++ b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill.go @@ -0,0 +1,122 @@ +package routing_skill + +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 getAllRoutingSkills(ctx context.Context, clientConfig *platformclientv2.Configuration) (resourceExporter.ResourceIDMetaMap, diag.Diagnostics) { + resources := make(resourceExporter.ResourceIDMetaMap) + proxy := getRoutingSkillProxy(clientConfig) + + skills, resp, getErr := proxy.getAllRoutingSkills(ctx, "") + if getErr != nil { + return nil, util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to get all routing skills | error: %s", getErr), resp) + } + + for _, skill := range *skills { + if skill.State != nil && *skill.State != "deleted" { + resources[*skill.Id] = &resourceExporter.ResourceMeta{Name: *skill.Name} + } + } + + return resources, nil +} + +func createRoutingSkill(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingSkillProxy(sdkConfig) + name := d.Get("name").(string) + + log.Printf("Creating skill %s", name) + skill, resp, err := proxy.createRoutingSkill(ctx, &platformclientv2.Routingskill{ + Name: &name, + }) + if err != nil { + return util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to create skill %s error: %s", name, err), resp) + } + + d.SetId(*skill.Id) + log.Printf("Created skill %s %s", name, *skill.Id) + return readRoutingSkill(ctx, d, meta) +} + +func readRoutingSkill(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingSkillProxy(sdkConfig) + cc := consistency_checker.NewConsistencyCheck(ctx, d, meta, ResourceRoutingSkill(), constants.DefaultConsistencyChecks, resourceName) + + log.Printf("Reading skill %s", d.Id()) + return util.WithRetriesForRead(ctx, d, func() *retry.RetryError { + skill, resp, getErr := proxy.getRoutingSkillById(ctx, d.Id()) + if getErr != nil { + if util.IsStatus404(resp) { + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Failed to read skill %s | error: %s", d.Id(), getErr), resp)) + } + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Failed to read skill %s | error: %s", d.Id(), getErr), resp)) + } + + if skill.State != nil && *skill.State == "deleted" { + d.SetId("") + return nil + } + + _ = d.Set("name", *skill.Name) + log.Printf("Read skill %s %s", d.Id(), *skill.Name) + return cc.CheckState(d) + }) +} + +func deleteRoutingSkill(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sdkConfig := meta.(*provider.ProviderMeta).ClientConfig + proxy := getRoutingSkillProxy(sdkConfig) + name := d.Get("name").(string) + + log.Printf("Deleting Routing skill %s", name) + resp, err := proxy.deleteRoutingSkill(ctx, d.Id()) + if err != nil { + return util.BuildAPIDiagnosticError(resourceName, fmt.Sprintf("Failed to delete skill %s error: %s", name, err), resp) + } + + return util.WithRetries(ctx, 30*time.Second, func() *retry.RetryError { + routingSkill, resp, err := proxy.getRoutingSkillById(ctx, d.Id()) + if err != nil { + if util.IsStatus404(resp) { + log.Printf("Deleted Routing skill %s", d.Id()) + return nil + } + return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error deleting Routing skill %s | error: %s", d.Id(), err), resp)) + } + + if routingSkill.State != nil && *routingSkill.State == "deleted" { + log.Printf("Deleted Routing skill %s", d.Id()) + return nil + } + + return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Routing skill %s still exists", d.Id()), resp)) + }) +} + +func GenerateRoutingSkillResource( + resourceID string, + name string) string { + return fmt.Sprintf(`resource "genesyscloud_routing_skill" "%s" { + name = "%s" + } + `, resourceID, name) +} diff --git a/genesyscloud/routing_skill/resource_genesyscloud_routing_skill_schema.go b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill_schema.go new file mode 100644 index 000000000..d6720c668 --- /dev/null +++ b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill_schema.go @@ -0,0 +1,62 @@ +package routing_skill + +import ( + "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_skill" + +func SetRegistrar(regInstance registrar.Registrar) { + regInstance.RegisterResource(resourceName, ResourceRoutingSkill()) + regInstance.RegisterExporter(resourceName, RoutingSkillExporter()) + regInstance.RegisterDataSource(resourceName, DataSourceRoutingSkill()) +} + +// The context is now added without Timeout , +// since the warming up of cache will take place for the first Datasource registered during a Terraform Apply. +func DataSourceRoutingSkill() *schema.Resource { + return &schema.Resource{ + Description: "Data source for Genesys Cloud Routing Skills. Select a skill by name.", + ReadWithoutTimeout: provider.ReadWithPooledClient(dataSourceRoutingSkillRead), + Schema: map[string]*schema.Schema{ + "name": { + Description: "Skill name.", + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func ResourceRoutingSkill() *schema.Resource { + return &schema.Resource{ + Description: "Genesys Cloud Routing Skill", + + CreateContext: provider.CreateWithPooledClient(createRoutingSkill), + ReadContext: provider.ReadWithPooledClient(readRoutingSkill), + DeleteContext: provider.DeleteWithPooledClient(deleteRoutingSkill), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + SchemaVersion: 1, + Schema: map[string]*schema.Schema{ + "name": { + Description: "Skill name. Changing the name attribute will cause the skill object object to dropped and recreated with a new ID.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + } +} + +func RoutingSkillExporter() *resourceExporter.ResourceExporter { + return &resourceExporter.ResourceExporter{ + GetResourcesFunc: provider.GetAllWithPooledClient(getAllRoutingSkills), + RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references + } +} diff --git a/genesyscloud/resource_genesyscloud_routing_skill_test.go b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill_test.go similarity index 98% rename from genesyscloud/resource_genesyscloud_routing_skill_test.go rename to genesyscloud/routing_skill/resource_genesyscloud_routing_skill_test.go index e847a18ff..c715e6b82 100644 --- a/genesyscloud/resource_genesyscloud_routing_skill_test.go +++ b/genesyscloud/routing_skill/resource_genesyscloud_routing_skill_test.go @@ -1,4 +1,4 @@ -package genesyscloud +package routing_skill import ( "fmt" diff --git a/genesyscloud/routing_skill_group/genesyscloud_routing_skill_group_init_test.go b/genesyscloud/routing_skill_group/genesyscloud_routing_skill_group_init_test.go index 2af5ebc88..a6cb02fe6 100644 --- a/genesyscloud/routing_skill_group/genesyscloud_routing_skill_group_init_test.go +++ b/genesyscloud/routing_skill_group/genesyscloud_routing_skill_group_init_test.go @@ -4,6 +4,7 @@ import ( "sync" "terraform-provider-genesyscloud/genesyscloud" "testing" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -24,7 +25,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources[resourceName] = ResourceRoutingSkillGroup() providerResources["genesyscloud_auth_division"] = genesyscloud.ResourceAuthDivision() providerResources["genesyscloud_user"] = genesyscloud.ResourceUser() - providerResources["genesyscloud_routing_skill"] = genesyscloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() } // registerTestDataSources registers all data sources used in the tests. diff --git a/genesyscloud/routing_skill_group/resource_genesyscloud_routing_skill_group_test.go b/genesyscloud/routing_skill_group/resource_genesyscloud_routing_skill_group_test.go index 74f706207..88a8cee9f 100644 --- a/genesyscloud/routing_skill_group/resource_genesyscloud_routing_skill_group_test.go +++ b/genesyscloud/routing_skill_group/resource_genesyscloud_routing_skill_group_test.go @@ -13,6 +13,7 @@ import ( "time" lists "terraform-provider-genesyscloud/genesyscloud/util/lists" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -424,7 +425,7 @@ func TestAccResourceRoutingSkillGroupMemberDivisionsUsersAssigned(t *testing.T) } ) - routingSkillResource := gcloud.GenerateRoutingSkillResource(routingSkillResourceId, routingSkillName) + routingSkillResource := routingSkill.GenerateRoutingSkillResource(routingSkillResourceId, routingSkillName) division1Resource := gcloud.GenerateAuthDivisionBasic(division1ResourceId, division1Name) division2Resource := gcloud.GenerateAuthDivisionBasic(division2ResourceId, division2Name) 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 cad4d1e46..ccf75c3e8 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 @@ -5,6 +5,8 @@ import ( authRole "terraform-provider-genesyscloud/genesyscloud/auth_role" routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" + "terraform-provider-genesyscloud/genesyscloud/user_roles" "testing" @@ -46,7 +48,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_user"] = gcloud.ResourceUser() providerResources["genesyscloud_externalcontacts_contact"] = externalContacts.ResourceExternalContact() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() - providerResources["genesyscloud_routing_skill"] = gcloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() providerResources["genesyscloud_auth_role"] = authRole.ResourceAuthRole() providerResources["genesyscloud_user_roles"] = user_roles.ResourceUserRoles() } 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 697a3bcbf..bc5178d12 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 @@ -8,6 +8,8 @@ import ( "terraform-provider-genesyscloud/genesyscloud/provider" routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" + "terraform-provider-genesyscloud/genesyscloud/user_roles" "terraform-provider-genesyscloud/genesyscloud/util" "testing" @@ -197,7 +199,7 @@ func TestAccResourceTaskManagementWorkitem(t *testing.T) { gcloud.GenerateAuthDivisionHomeDataSource(homeDivRes) + routingLanguage.GenerateRoutingLanguageResource(resLang, lang) + routingQueue.GenerateRoutingQueueResourceBasic(resQueue, queueName) + - gcloud.GenerateRoutingSkillResource(skillResId1, skillResName1) + + routingSkill.GenerateRoutingSkillResource(skillResId1, skillResName1) + gcloud.GenerateBasicUserResource(userResId1, userEmail1, userName1) + externalContact.GenerateBasicExternalContactResource(externalContactResId1, externalContactTitle1) + authRole.GenerateAuthRoleResource(roleResId1, roleName1, "test role description", 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 bdb8160ee..f33fe57d6 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 @@ -4,6 +4,7 @@ import ( "sync" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" "testing" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" gcloud "terraform-provider-genesyscloud/genesyscloud" routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" @@ -39,7 +40,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_task_management_workitem_schema"] = workitemSchema.ResourceTaskManagementWorkitemSchema() providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage() providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() - providerResources["genesyscloud_routing_skill"] = gcloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() } // registerTestDataSources registers all data sources used in the tests. 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 12a109adb..179e1f6dd 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 @@ -8,13 +8,14 @@ import ( "terraform-provider-genesyscloud/genesyscloud/provider" routingLanguage "terraform-provider-genesyscloud/genesyscloud/routing_language" routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" + "terraform-provider-genesyscloud/genesyscloud/util" "testing" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - gcloud "terraform-provider-genesyscloud/genesyscloud" workbin "terraform-provider-genesyscloud/genesyscloud/task_management_workbin" workitemSchema "terraform-provider-genesyscloud/genesyscloud/task_management_workitem_schema" @@ -111,8 +112,8 @@ func TestAccResourceTaskManagementWorktype(t *testing.T) { workitemSchema.GenerateWorkitemSchemaResourceBasic(wsResourceId, wsName, wsDescription) + routingQueue.GenerateRoutingQueueResourceBasic(queueResId, queueName) + routingLanguage.GenerateRoutingLanguageResource(langResId, langName) + - gcloud.GenerateRoutingSkillResource(skillResId1, skillResName1) + - gcloud.GenerateRoutingSkillResource(skillResId2, skillResName2) + + routingSkill.GenerateRoutingSkillResource(skillResId1, skillResName1) + + routingSkill.GenerateRoutingSkillResource(skillResId2, skillResName2) + generateWorktypeResource(wtRes) + fmt.Sprintf("\n data \"genesyscloud_auth_division_home\" \"%s\" {}\n", divData), Check: resource.ComposeTestCheckFunc( diff --git a/genesyscloud/tfexporter/tf_exporter_resource_test.go b/genesyscloud/tfexporter/tf_exporter_resource_test.go index 406cb44b1..d1060fd0b 100644 --- a/genesyscloud/tfexporter/tf_exporter_resource_test.go +++ b/genesyscloud/tfexporter/tf_exporter_resource_test.go @@ -62,6 +62,7 @@ import ( routingQueueOutboundEmailAddress "terraform-provider-genesyscloud/genesyscloud/routing_queue_outbound_email_address" routingSettings "terraform-provider-genesyscloud/genesyscloud/routing_settings" routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" routingSmsAddress "terraform-provider-genesyscloud/genesyscloud/routing_sms_addresses" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" @@ -161,7 +162,7 @@ func (r *registerTestInstance) registerTestResources() { providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue() providerResources["genesyscloud_routing_queue_conditional_group_routing"] = routingQueueConditionalGroupRouting.ResourceRoutingQueueConditionalGroupRouting() providerResources["genesyscloud_routing_queue_outbound_email_address"] = routingQueueOutboundEmailAddress.ResourceRoutingQueueOutboundEmailAddress() - providerResources["genesyscloud_routing_skill"] = gcloud.ResourceRoutingSkill() + providerResources["genesyscloud_routing_skill"] = routingSkill.ResourceRoutingSkill() providerResources["genesyscloud_routing_settings"] = routingSettings.ResourceRoutingSettings() providerResources["genesyscloud_routing_utilization"] = routingUtilization.ResourceRoutingUtilization() providerResources["genesyscloud_routing_utilization_label"] = routingUtilizationLabel.ResourceRoutingUtilizationLabel() @@ -276,8 +277,8 @@ func (r *registerTestInstance) registerTestExporters() { RegisterExporter("genesyscloud_routing_queue_conditional_group_routing", routingQueueConditionalGroupRouting.RoutingQueueConditionalGroupRoutingExporter()) RegisterExporter("genesyscloud_routing_queue_outbound_email_address", routingQueueOutboundEmailAddress.OutboundRoutingQueueOutboundEmailAddressExporter()) RegisterExporter("genesyscloud_routing_settings", routingSettings.RoutingSettingsExporter()) - RegisterExporter("genesyscloud_routing_skill", gcloud.RoutingSkillExporter()) RegisterExporter("genesyscloud_routing_skill_group", routingSkillGroup.ResourceSkillGroupExporter()) + RegisterExporter("genesyscloud_routing_skill", routingSkill.RoutingSkillExporter()) RegisterExporter("genesyscloud_routing_sms_address", routingSmsAddress.RoutingSmsAddressExporter()) RegisterExporter("genesyscloud_routing_utilization", routingUtilization.RoutingUtilizationExporter()) RegisterExporter("genesyscloud_routing_utilization_label", routingUtilizationLabel.RoutingUtilizationLabelExporter()) diff --git a/main.go b/main.go index 665a71fcb..d597aa222 100644 --- a/main.go +++ b/main.go @@ -70,11 +70,11 @@ import ( routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group" routingUtilization "terraform-provider-genesyscloud/genesyscloud/routing_utilization" routingUtilizationLabel "terraform-provider-genesyscloud/genesyscloud/routing_utilization_label" - cMessageSettings "terraform-provider-genesyscloud/genesyscloud/conversations_messaging_settings" routingQueueConditionalGroupRouting "terraform-provider-genesyscloud/genesyscloud/routing_queue_conditional_group_routing" routingQueueOutboundEmailAddress "terraform-provider-genesyscloud/genesyscloud/routing_queue_outbound_email_address" routingSettings "terraform-provider-genesyscloud/genesyscloud/routing_settings" + routingSkill "terraform-provider-genesyscloud/genesyscloud/routing_skill" smsAddresses "terraform-provider-genesyscloud/genesyscloud/routing_sms_addresses" "terraform-provider-genesyscloud/genesyscloud/scripts" "terraform-provider-genesyscloud/genesyscloud/station" @@ -247,6 +247,7 @@ func registerResources() { journeyViews.SetRegistrar(regInstance) //Registering journey views routingLanguage.SetRegistrar(regInstance) //Registering Routing Language routingEmailDomain.SetRegistrar(regInstance) //Registering Routing Email Domain + routingSkill.SetRegistrar(regInstance) //Registering Routing Skill cMessageSettings.SetRegistrar(regInstance) // Registering conversations messaging settings routingSkillGroup.SetRegistrar(regInstance) //Registering routing skill group // setting resources for Use cases like TF export where provider is used in resource classes.