Skip to content

Commit

Permalink
refactor/Devtooling-186: routing queue (#1238)
Browse files Browse the repository at this point in the history
* Moved Build and Flatten Functions to util file

* Good Bit Done

* vet fixes

* 778 - required attributes to optional

* Fixing test

* generate

* Made requested changes

* Changes Made

* Added unit test

* updated docs

* go mod tidy

* undid breaking change

* docs

* resolved conflict

* fmt

* fixed conflicts

* Fixed Tests

* outbound email address failing test
  • Loading branch information
BrianMoyles authored Sep 23, 2024
1 parent a670a23 commit 2e4fc52
Show file tree
Hide file tree
Showing 14 changed files with 1,884 additions and 1,062 deletions.
55 changes: 22 additions & 33 deletions docs/resources/routing_queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ resource "genesyscloud_routing_queue" "example_queue" {
- `message_in_queue_flow_id` (String) The in-queue flow ID to use for message conversations waiting in queue.
- `on_hold_prompt_id` (String) The audio to be played when calls on this queue are on hold. If not configured, the default on-hold music will play.
- `outbound_email_address` (Block List, Max: 1, Deprecated) The outbound email address settings for this queue. (see [below for nested schema](#nestedblock--outbound_email_address))
- `outbound_messaging_open_messaging_recipient_id` (String) The unique ID of the outbound messaging open messaging recipient for the queue.
- `outbound_messaging_sms_address_id` (String) The unique ID of the outbound messaging SMS address for the queue.
- `outbound_messaging_whatsapp_recipient_id` (String) The unique ID of the outbound messaging whatsapp recipient for the queue.
- `peer_id` (String) The ID of an associated external queue
- `queue_flow_id` (String) The in-queue flow ID to use for call conversations waiting in queue.
- `routing_rules` (Block List, Max: 6) The routing rules for the queue, used for routing to known or preferred agents. (see [below for nested schema](#nestedblock--routing_rules))
- `scoring_method` (String) The Scoring Method for the queue. Defaults to TimestampAndPriority. Defaults to `TimestampAndPriority`.
- `skill_evaluation_method` (String) The skill evaluation method to use when routing conversations (NONE | BEST | ALL). Defaults to `ALL`.
- `skill_groups` (Set of String) List of skill group ids assigned to the queue.
- `source_queue_id` (String) The id of an existing queue to copy the settings (does not include GPR settings) from when creating a new queue.
- `suppress_in_queue_call_recording` (Boolean) Indicates whether recording in-queue calls is suppressed for this queue. Defaults to `true`.
- `teams` (Set of String) List of ids assigned to the queue
- `whisper_prompt_id` (String) The prompt ID used for whisper on the queue, if configured.
Expand All @@ -127,7 +131,7 @@ resource "genesyscloud_routing_queue" "example_queue" {
<a id="nestedblock--agent_owned_routing"></a>
### Nested Schema for `agent_owned_routing`

Required:
Optional:

- `enable_agent_owned_callbacks` (Boolean) Enable Agent Owned Callbacks
- `max_owned_callback_delay_hours` (Number) Max Owned Call Back Delay Hours >= 7
Expand Down Expand Up @@ -161,13 +165,13 @@ Required:

Required:

- `condition_value` (Number) The limit value, beyond which a rule evaluates as true.
- `groups` (Block List, Min: 1) The group(s) to activate if the rule evaluates as true. (see [below for nested schema](#nestedblock--conditional_group_routing_rules--groups))
- `operator` (String) The operator that compares the actual value against the condition value. Valid values: GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo.

Optional:

- `condition_value` (Number) The limit value, beyond which a rule evaluates as true.
- `metric` (String) The queue metric being evaluated. Valid values: EstimatedWaitTime, ServiceLevel Defaults to `EstimatedWaitTime`.
- `operator` (String) The operator that compares the actual value against the condition value. Valid values: GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo.
- `queue_id` (String) The ID of the queue being evaluated for this rule. For rule 1, this is always be the current queue, so no queue id should be specified for the first rule.
- `wait_seconds` (Number) The number of seconds to wait in this rule, if it evaluates as true, before evaluating the next rule. For the final rule, this is ignored, so need not be specified. Defaults to `2`.

Expand Down Expand Up @@ -197,86 +201,71 @@ Optional:
<a id="nestedblock--media_settings_call"></a>
### Nested Schema for `media_settings_call`

Required:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.

Optional:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `auto_dial_delay_seconds` (Number) Auto Dial Delay Seconds.
- `auto_end_delay_seconds` (Number) Auto End Delay Seconds.
- `enable_auto_answer` (Boolean) Auto-Answer for digital channels(Email, Message) Defaults to `false`.
- `enable_auto_dial_and_end` (Boolean) Auto Dail and End Defaults to `false`.
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.


<a id="nestedblock--media_settings_callback"></a>
### Nested Schema for `media_settings_callback`

Required:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.

Optional:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `auto_dial_delay_seconds` (Number) Auto Dial Delay Seconds.
- `auto_end_delay_seconds` (Number) Auto End Delay Seconds.
- `enable_auto_answer` (Boolean) Auto-Answer for digital channels(Email, Message) Defaults to `false`.
- `enable_auto_dial_and_end` (Boolean) Auto Dail and End Defaults to `false`.
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.


<a id="nestedblock--media_settings_chat"></a>
### Nested Schema for `media_settings_chat`

Required:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.

Optional:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `auto_dial_delay_seconds` (Number) Auto Dial Delay Seconds.
- `auto_end_delay_seconds` (Number) Auto End Delay Seconds.
- `enable_auto_answer` (Boolean) Auto-Answer for digital channels(Email, Message) Defaults to `false`.
- `enable_auto_dial_and_end` (Boolean) Auto Dail and End Defaults to `false`.
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.


<a id="nestedblock--media_settings_email"></a>
### Nested Schema for `media_settings_email`

Required:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.

Optional:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `auto_dial_delay_seconds` (Number) Auto Dial Delay Seconds.
- `auto_end_delay_seconds` (Number) Auto End Delay Seconds.
- `enable_auto_answer` (Boolean) Auto-Answer for digital channels(Email, Message) Defaults to `false`.
- `enable_auto_dial_and_end` (Boolean) Auto Dail and End Defaults to `false`.
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.


<a id="nestedblock--media_settings_message"></a>
### Nested Schema for `media_settings_message`

Required:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.

Optional:

- `alerting_timeout_sec` (Number) Alerting timeout in seconds. Must be >= 7
- `auto_dial_delay_seconds` (Number) Auto Dial Delay Seconds.
- `auto_end_delay_seconds` (Number) Auto End Delay Seconds.
- `enable_auto_answer` (Boolean) Auto-Answer for digital channels(Email, Message) Defaults to `false`.
- `enable_auto_dial_and_end` (Boolean) Auto Dail and End Defaults to `false`.
- `service_level_duration_ms` (Number) Service Level target in milliseconds. Must be >= 1000
- `service_level_percentage` (Number) The desired Service Level. A float value between 0 and 1.


<a id="nestedatt--members"></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
inboundCall:
name: Terraform Flow Test-a8bf377f-3900-42a2-aa43-cec584f14366
name: Terraform Flow Test-b066d719-c330-41c3-8c0f-9f880f6cdfb5
defaultLanguage: en-us
startUpRef: ./menus/menu[mainMenu]
initialGreeting:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
inboundEmail:
name: Terraform Flow Test-c93ae359-ace8-4e15-932b-18f242a33b09
name: Terraform Flow Test-88aecd38-8ab8-45cf-bf74-7f9fa01da2ac
division: New Home
startUpRef: "/inboundEmail/states/state[Initial State_10]"
defaultLanguage: en-us
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
inboundCall:
name: Terraform Flow Test-7fbe9a86-3aca-4bdc-a88f-ab89b891793e
name: Terraform Flow Test-bbe3c4a2-faa9-48c7-a54d-6117ae2eabc1
defaultLanguage: en-us
startUpRef: ./menus/menu[mainMenu]
initialGreeting:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func dataSourceRoutingQueueRead(ctx context.Context, d *schema.ResourceData, m i
}

queueId, err := rc.RetrieveId(dataSourceRoutingQueueCache, resourceName, key, ctx)

if err != nil {
return err
}
Expand All @@ -48,19 +47,23 @@ func normalizeQueueName(queueName string) string {

// hydrateRoutingQueueCacheFn for hydrating the cache with Genesys Cloud routing queues using the SDK
func hydrateRoutingQueueCacheFn(c *rc.DataSourceCache, ctx context.Context) error {
log.Printf("hydrating cache for data source genesyscloud_routing_queues")
proxy := GetRoutingQueueProxy(c.ClientConfig)

log.Printf("hydrating cache for data source genesyscloud_routing_queues")

// Newly created resources often aren't returned unless there's a delay
time.Sleep(5 * time.Second)

queues, _, err := proxy.GetAllRoutingQueues(ctx, "")
allQueues, resp, err := proxy.GetAllRoutingQueues(ctx, "")
if err != nil {
return err
return fmt.Errorf("failed to get routing queues %s %s", err, resp)
}

// Add ids to cache
for _, queue := range *queues {
if allQueues == nil || len(*allQueues) == 0 {
return nil
}

for _, queue := range *allQueues {
c.Cache[normalizeQueueName(*queue.Name)] = *queue.Id
}

Expand All @@ -75,16 +78,16 @@ func getQueueByNameFn(c *rc.DataSourceCache, name string, ctx context.Context) (
queueId := ""

diag := util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError {
queue, resp, retryable, getErr := proxy.getRoutingQueueByName(ctx, name)

queueID, resp, retryable, getErr := proxy.getRoutingQueueByName(ctx, name)
if getErr != nil && !retryable {
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("error requesting queue %s | error %s", name, getErr), resp))
}

if retryable {
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("no routing queue found with name %s", name), resp))
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("error requesting queue %s | error %s", name, getErr), resp))
}

queueId = queue
queueId = queueID
return nil
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func TestAccDataSourceRoutingQueueBasic(t *testing.T) {
util.NullValue, //suppressCall_record_false
util.NullValue, // enable_transcription false
strconv.Quote("TimestampAndPriority"),
util.NullValue,
util.NullValue,
) + generateRoutingQueueDataSource(
queueDataSource,
"genesyscloud_routing_queue."+queueResource+".name",
Expand Down
Loading

0 comments on commit 2e4fc52

Please sign in to comment.