Skip to content

Commit

Permalink
PR
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMoyles committed Jul 19, 2024
1 parent e579510 commit 78788c3
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 309 deletions.
2 changes: 1 addition & 1 deletion docs/resources/routing_skill_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource "genesyscloud_routing_skill_group" "skillgroup" {

- `description` (String) Description of the skill group
- `division_id` (String) The division to which this entity belongs
- `member_division_ids` (List of String) The IDs of member divisions to add or remove for this skill group. An empty array means all divisions will be removed, "*" means all divisions will be added.
- `member_divisions` (List of String) Member divisions for this skill group.
- `skill_conditions` (String) JSON encoded array of rules that will be used to determine group membership.

### Read-Only
Expand Down
41 changes: 24 additions & 17 deletions examples/resources/genesyscloud_flow/inboundcall_flow_example2.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
inboundCall:
name: Terraform Flow Test-0f374aca-4d2e-4959-b1bb-9b4fa37e6c73
description: test description 2
defaultLanguage: en-us
startUpRef: ./menus/menu[mainMenu]
initialGreeting:
tts: Archy says hi!!!!!
menus:
- menu:
name: Main Menu
audio:
tts: You are at the Main Menu, press 9 to disconnect.
refId: mainMenu
choices:
- menuDisconnect:
name: Disconnect
dtmf: digit_9
inboundEmail:
name: Terraform Flow Test-d0c40522-88e4-4b66-aa48-f237afb819e0
division: New Home
startUpRef: "/inboundEmail/states/state[Initial State_10]"
defaultLanguage: en-us
supportedLanguages:
en-us:
defaultLanguageSkill:
noValue: true
settingsInboundEmailHandling:
emailHandling:
disconnect:
none: true
settingsErrorHandling:
errorHandling:
disconnect:
none: true
states:
- state:
name: Initial State
refId: Initial State_10
actions:
- disconnect:
name: Disconnect
40 changes: 16 additions & 24 deletions examples/resources/genesyscloud_flow/inboundcall_flow_example3.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
inboundEmail:
name: Terraform Flow Test-0f374aca-4d2e-4959-b1bb-9b4fa37e6c73
description: test description 1
startUpRef: "/inboundEmail/states/state[Initial State_10]"
defaultLanguage: en-us
supportedLanguages:
en-us:
defaultLanguageSkill:
noValue: true
settingsInboundEmailHandling:
emailHandling:
disconnect:
none: true
settingsErrorHandling:
errorHandling:
disconnect:
none: true
states:
- state:
name: Initial State
refId: Initial State_10
actions:
- disconnect:
name: Disconnect
inboundCall:
name: Terraform Flow Test-e602c7ba-318e-4373-99bb-bdf69dcc7600
defaultLanguage: en-us
startUpRef: ./menus/menu[mainMenu]
initialGreeting:
tts: Archy says hi!!!!!
menus:
- menu:
name: Main Menu
audio:
tts: You are at the Main Menu, press 9 to disconnect.
refId: mainMenu
choices:
- menuDisconnect:
name: Disconnect
dtmf: digit_9
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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"
Expand Down Expand Up @@ -40,7 +41,7 @@ func (r *registerTestInstance) registerTestResources() {
providerResources["genesyscloud_routing_language"] = routingLanguage.ResourceRoutingLanguage()
providerResources["genesyscloud_routing_skill"] = genesyscloud.ResourceRoutingSkill()
providerResources["genesyscloud_flow"] = architectFlow.ResourceArchitectFlow()
providerResources["genesyscloud_routing_skill_group"] = genesyscloud.ResourceRoutingSkillGroup()
providerResources["genesyscloud_routing_skill_group"] = routingSkillGroup.ResourceRoutingSkillGroup()
}

// registerTestDataSources registers all data sources used in the tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
architectFlow "terraform-provider-genesyscloud/genesyscloud/architect_flow"
"terraform-provider-genesyscloud/genesyscloud/architect_user_prompt"
"terraform-provider-genesyscloud/genesyscloud/group"
routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -38,7 +39,7 @@ func (r *registerTestInstance) registerTestResources() {
providerResources["genesyscloud_group"] = group.ResourceGroup()
providerResources["genesyscloud_routing_wrapupcode"] = gcloud.ResourceRoutingWrapupCode()
providerResources["genesyscloud_flow"] = architectFlow.ResourceArchitectFlow()
providerResources["genesyscloud_routing_skill_group"] = gcloud.ResourceRoutingSkillGroup()
providerResources["genesyscloud_routing_skill_group"] = routingSkillGroup.ResourceRoutingSkillGroup()
providerResources["genesyscloud_architect_user_prompt"] = architect_user_prompt.ResourceArchitectUserPrompt()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"terraform-provider-genesyscloud/genesyscloud/architect_user_prompt"
"terraform-provider-genesyscloud/genesyscloud/group"
"terraform-provider-genesyscloud/genesyscloud/provider"
routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group"
"terraform-provider-genesyscloud/genesyscloud/util"
featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles"
"terraform-provider-genesyscloud/genesyscloud/util/testrunner"
Expand Down Expand Up @@ -249,7 +250,7 @@ func TestAccResourceRoutingQueueConditionalRouting(t *testing.T) {
time.Sleep(30 * time.Second)
},
// Create
Config: genesyscloud.GenerateRoutingSkillGroupResourceBasic(
Config: routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand Down Expand Up @@ -346,7 +347,7 @@ func TestAccResourceRoutingQueueConditionalRouting(t *testing.T) {
queueResource2,
queueName2,
) +
genesyscloud.GenerateRoutingSkillGroupResourceBasic(
routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand Down Expand Up @@ -520,7 +521,7 @@ func TestAccResourceRoutingQueueParToCGR(t *testing.T) {
ProviderFactories: provider.GetProviderFactories(providerResources, providerDataSources),
Steps: []resource.TestStep{
{
Config: genesyscloud.GenerateRoutingSkillGroupResourceBasic(
Config: routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand Down Expand Up @@ -1600,7 +1601,7 @@ func TestAccResourceRoutingQueueSkillGroups(t *testing.T) {
Steps: []resource.TestStep{
{
// Create
Config: generateUserWithCustomAttrs(testUserResource, testUserEmail, testUserName) + genesyscloud.GenerateRoutingSkillGroupResourceBasic(skillGroupResource, skillGroupName, skillGroupDescription) +
Config: generateUserWithCustomAttrs(testUserResource, testUserEmail, testUserName) + routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(skillGroupResource, skillGroupName, skillGroupDescription) +
group.GenerateBasicGroupResource(groupResource, groupName,
group.GenerateGroupOwners("genesyscloud_user."+testUserResource+".id"),
) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
gcloud "terraform-provider-genesyscloud/genesyscloud"
"terraform-provider-genesyscloud/genesyscloud/group"
routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue"
routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group"
"testing"
)

Expand All @@ -28,7 +29,7 @@ func (r *registerTestInstance) registerTestResources() {

providerResources[resourceName] = ResourceRoutingQueueConditionalGroupRouting()
providerResources["genesyscloud_routing_queue"] = routingQueue.ResourceRoutingQueue()
providerResources["genesyscloud_routing_skill_group"] = gcloud.ResourceRoutingSkillGroup()
providerResources["genesyscloud_routing_skill_group"] = routingSkillGroup.ResourceRoutingSkillGroup()
providerResources["genesyscloud_user"] = gcloud.ResourceUser()
providerResources["genesyscloud_group"] = group.ResourceGroup()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"os"
"strings"
"sync"
gcloud "terraform-provider-genesyscloud/genesyscloud"
"terraform-provider-genesyscloud/genesyscloud/group"
"terraform-provider-genesyscloud/genesyscloud/provider"
routingQueue "terraform-provider-genesyscloud/genesyscloud/routing_queue"
routingSkillGroup "terraform-provider-genesyscloud/genesyscloud/routing_skill_group"
"terraform-provider-genesyscloud/genesyscloud/util"
featureToggles "terraform-provider-genesyscloud/genesyscloud/util/feature_toggles"
"testing"
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestAccResourceRoutingQueueConditionalGroupRouting(t *testing.T) {
{
// Create the queue first so we can save the id to a channel and use it in the later test steps
// The reason we are doing this is that we need to verify the parent queue is never dropped and recreated because of CGR
Config: gcloud.GenerateRoutingSkillGroupResourceBasic(
Config: routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand All @@ -95,7 +95,7 @@ func TestAccResourceRoutingQueueConditionalGroupRouting(t *testing.T) {
},
{
// Create rule
Config: gcloud.GenerateRoutingSkillGroupResourceBasic(
Config: routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestAccResourceRoutingQueueConditionalGroupRouting(t *testing.T) {
groupResourceId,
groupName,
group.GenerateGroupOwners("genesyscloud_user."+testUserResource+".id"),
) + gcloud.GenerateRoutingSkillGroupResourceBasic(
) + routingSkillGroup.GenerateRoutingSkillGroupResourceBasic(
skillGroupResourceId,
skillGroupName,
"description",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func dataSourceRoutingSkillGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
sdkConfig := m.(*provider.ProviderMeta).ClientConfig
proxy := getRoutingSkillGroupProxy(sdkConfig)
proxy := getRoutingSkillGroupsProxy(sdkConfig)
name := d.Get("name").(string)

return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,46 @@ type createRoutingSkillGroupsFunc func(ctx context.Context, p *routingSkillGroup
type getRoutingSkillGroupsByIdFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.Skillgroup, *platformclientv2.APIResponse, error)
type getRoutingSkillGroupsIdByNameFunc func(ctx context.Context, p *routingSkillGroupsProxy, name string) (string, *platformclientv2.APIResponse, bool, error)
type updateRoutingSkillGroupsFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string, skillGroupWithMemberDivisions *platformclientv2.Skillgroup) (*platformclientv2.Skillgroup, *platformclientv2.APIResponse, error)
type deleteRoutingSkillGroupFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.APIResponse, error)

type getRoutingSkillGroupsMembersFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string) (*[]platformclientv2.Skillgroupmemberentitylisting, *platformclientv2.APIResponse, error)
type deleteRoutingSkillGroupsFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.APIResponse, error)
type createRoutingSkillGroupsMemberDivisionFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string, reqBody platformclientv2.Skillgroupmemberdivisions) (*platformclientv2.APIResponse, error)
type getRoutingSkillGroupsMemberDivisonFunc func(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.Skillgroupmemberdivisionlist, *platformclientv2.APIResponse, error)

// routingSkillGroupsProxy contains all of the methods that call genesys cloud APIs.
type routingSkillGroupsProxy struct {
clientConfig *platformclientv2.Configuration
routingApi *platformclientv2.RoutingApi
createRoutingSkillGroupsAttr createRoutingSkillGroupsFunc
getAllRoutingSkillGroupsAttr getAllRoutingSkillGroupsFunc
getRoutingSkillGroupsIdByNameAttr getRoutingSkillGroupsIdByNameFunc
getRoutingSkillGroupsByIdAttr getRoutingSkillGroupsByIdFunc
updateRoutingSkillGroupsAttr updateRoutingSkillGroupsFunc
deleteRoutingSkillGroupAttr deleteRoutingSkillGroupFunc

getRoutingSkillGroupsMembersAttr getRoutingSkillGroupsMembersFunc
clientConfig *platformclientv2.Configuration
routingApi *platformclientv2.RoutingApi
createRoutingSkillGroupsAttr createRoutingSkillGroupsFunc
getAllRoutingSkillGroupsAttr getAllRoutingSkillGroupsFunc
getRoutingSkillGroupsIdByNameAttr getRoutingSkillGroupsIdByNameFunc
getRoutingSkillGroupsByIdAttr getRoutingSkillGroupsByIdFunc
updateRoutingSkillGroupsAttr updateRoutingSkillGroupsFunc
deleteRoutingSkillGroupsAttr deleteRoutingSkillGroupsFunc
createRoutingSkillGroupsMemberDivisionAttr createRoutingSkillGroupsMemberDivisionFunc
getRoutingSkillGroupsMemberDivisonAttr getRoutingSkillGroupsMemberDivisonFunc
}

// newRoutingSkillGroupsProxy initializes the routing skill groups proxy with all of the data needed to communicate with Genesys Cloud
func newRoutingSkillGroupProxy(clientConfig *platformclientv2.Configuration) *routingSkillGroupsProxy {
func newRoutingSkillGroupsProxy(clientConfig *platformclientv2.Configuration) *routingSkillGroupsProxy {
api := platformclientv2.NewRoutingApiWithConfig(clientConfig)
return &routingSkillGroupsProxy{
clientConfig: clientConfig,
routingApi: api,
createRoutingSkillGroupsAttr: createRoutingSkillGroupsFn,
getAllRoutingSkillGroupsAttr: getAllRoutingSkillGroupsFn,
getRoutingSkillGroupsIdByNameAttr: getRoutingSkillGroupsIdByNameFn,
getRoutingSkillGroupsByIdAttr: getRoutingSkillGroupsByIdFn,
updateRoutingSkillGroupsAttr: updateRoutingSkillGroupsFn,
deleteRoutingSkillGroupAttr: deleteRoutingSkillGroupFn,

getRoutingSkillGroupsMembersAttr: getRoutingSkillGroupsMembersFn,
clientConfig: clientConfig,
routingApi: api,
createRoutingSkillGroupsAttr: createRoutingSkillGroupsFn,
getAllRoutingSkillGroupsAttr: getAllRoutingSkillGroupsFn,
getRoutingSkillGroupsIdByNameAttr: getRoutingSkillGroupsIdByNameFn,
getRoutingSkillGroupsByIdAttr: getRoutingSkillGroupsByIdFn,
updateRoutingSkillGroupsAttr: updateRoutingSkillGroupsFn,
deleteRoutingSkillGroupsAttr: deleteRoutingSkillGroupsFn,
createRoutingSkillGroupsMemberDivisionAttr: createRoutingSkillGroupsMemberDivisionFn,
getRoutingSkillGroupsMemberDivisonAttr: getRoutingSkillGroupsMemberDivisonFn,
}
}

// getRoutingSkillGroupsProxy acts as a singleton to for the internalProxy. It also ensures
// that we can still proxy our tests by directly setting internalProxy package variable
func getRoutingSkillGroupProxy(clientConfig *platformclientv2.Configuration) *routingSkillGroupsProxy {
func getRoutingSkillGroupsProxy(clientConfig *platformclientv2.Configuration) *routingSkillGroupsProxy {
if internalProxy == nil {
internalProxy = newRoutingSkillGroupProxy(clientConfig)
internalProxy = newRoutingSkillGroupsProxy(clientConfig)
}
return internalProxy
}
Expand Down Expand Up @@ -92,12 +86,8 @@ func (p *routingSkillGroupsProxy) updateRoutingSkillGroups(ctx context.Context,
}

// deleteRoutingSkillGroups deletes a Genesys Cloud routing skill groups by Id
func (p *routingSkillGroupsProxy) deleteRoutingSkillGroup(ctx context.Context, id string) (*platformclientv2.APIResponse, error) {
return p.deleteRoutingSkillGroupAttr(ctx, p, id)
}

func (p *routingSkillGroupsProxy) getRoutingSkillGroupsMembers(ctx context.Context, id string) (*[]platformclientv2.Skillgroupmemberentitylisting, *platformclientv2.APIResponse, error) {
return p.getRoutingSkillGroupsMembersAttr(ctx, p, id)
func (p *routingSkillGroupsProxy) deleteRoutingSkillGroups(ctx context.Context, id string) (*platformclientv2.APIResponse, error) {
return p.deleteRoutingSkillGroupsAttr(ctx, p, id)
}

func (p *routingSkillGroupsProxy) createRoutingSkillGroupsMemberDivision(ctx context.Context, id string, reqBody platformclientv2.Skillgroupmemberdivisions) (*platformclientv2.APIResponse, error) {
Expand Down Expand Up @@ -174,7 +164,7 @@ func getRoutingSkillGroupsIdByNameFn(ctx context.Context, p *routingSkillGroupsP
}
}

return "", resp, true, fmt.Errorf("Unable to find routing skill groups with name %s", name)
return "", resp, true, fmt.Errorf("unable to find routing skill groups with name %s", name)
}

// updateRoutingSkillGroupsFn is an implementation of the function to update a Genesys Cloud routing skill groups
Expand All @@ -183,47 +173,10 @@ func updateRoutingSkillGroupsFn(ctx context.Context, p *routingSkillGroupsProxy,
}

// deleteRoutingSkillGroupsFn is an implementation function for deleting a Genesys Cloud routing skill groups
func deleteRoutingSkillGroupFn(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.APIResponse, error) {
func deleteRoutingSkillGroupsFn(ctx context.Context, p *routingSkillGroupsProxy, id string) (*platformclientv2.APIResponse, error) {
return p.routingApi.DeleteRoutingSkillgroup(id)
}

func getRoutingSkillGroupsMembersFn(ctx context.Context, p *routingSkillGroupsProxy, id string) (*[]platformclientv2.Skillgroupmemberentitylisting, *platformclientv2.APIResponse, error) {
var (
allSkillGroupMembers []platformclientv2.Skillgroupmemberentitylisting
pageSize = 100
after string
err error
response *platformclientv2.APIResponse
)

for i := 0; ; i++ {
skillGroupMembers, resp, getErr := p.routingApi.GetRoutingSkillgroupMembers(id, pageSize, after, "", "")
response = resp
if getErr != nil {
return nil, resp, fmt.Errorf("unable to get routing skill group members %s", getErr)
}

if skillGroupMembers.Entities == nil || len(*skillGroupMembers.Entities) == 0 {
break
}

//allSkillGroupMembers = append(allSkillGroupMembers, skillGroupMembers.Entities...)

if skillGroupMembers.NextUri == nil || *skillGroupMembers.NextUri == "" {
break
}

after, err = util.GetQueryParamValueFromUri(*skillGroupMembers.NextUri, "after")
if err != nil {
return nil, resp, fmt.Errorf("unable to parse after cursor from skill groups next uri: %v", err)
}
if after == "" {
break
}
}
return &allSkillGroupMembers, response, nil
}

func createRoutingSkillGroupsMemberDivisionFn(ctx context.Context, p *routingSkillGroupsProxy, id string, reqBody platformclientv2.Skillgroupmemberdivisions) (*platformclientv2.APIResponse, error) {
return p.routingApi.PostRoutingSkillgroupMembersDivisions(id, reqBody)
}
Expand Down
Loading

0 comments on commit 78788c3

Please sign in to comment.