-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/devtooling 734 Outbound Digital RuleSet (#1250)
* added files for outbound ruleset * fixes for imports * added test cases * added utility methods * added test functions * changes made for doNoSend Settings * changes in Utils * added test cases * updated docs * code cleanup and error messages updated * error message updated for data source * resolved comments * updated docs
- Loading branch information
1 parent
47ac0ba
commit 0fbd64f
Showing
15 changed files
with
2,827 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "genesyscloud_outbound_digitalruleset Data Source - terraform-provider-genesyscloud" | ||
subcategory: "" | ||
description: |- | ||
Genesys Cloud outbound digitalruleset data source. Select an outbound digitalruleset by name | ||
--- | ||
|
||
# genesyscloud_outbound_digitalruleset (Data Source) | ||
|
||
Genesys Cloud outbound digitalruleset data source. Select an outbound digitalruleset by name | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "genesyscloud_outbound_digitalruleset" "digital-ruleset" { | ||
name = "Digital RuleSet Test" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) outbound digitalruleset name | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
--- | ||
page_title: "genesyscloud_outbound_digitalruleset Resource - terraform-provider-genesyscloud" | ||
subcategory: "" | ||
description: |- | ||
Genesys Cloud outbound digitalruleset | ||
--- | ||
# genesyscloud_outbound_digitalruleset (Resource) | ||
|
||
Genesys Cloud outbound digitalruleset | ||
|
||
## API Usage | ||
The following Genesys Cloud APIs are used by this resource. Ensure your OAuth Client has been granted the necessary scopes and permissions to perform these operations: | ||
|
||
* [POST /api/v2/outbound/digitalrulesets](https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-outbound-digitalrulesets) | ||
* [GET /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [PUT /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#put-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [DELETE /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#delete-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [GET /api/v2/outbound/digitalrulesets](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-outbound-digitalrulesets) | ||
|
||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "genesyscloud_outbound_digitalruleset" "test_ruleset_sample" { | ||
name = "Test Digital RuleSet - 13" | ||
version = 1 | ||
contact_list_id = "c2406f62-63e3-4826-a6f9-ae635bd731e0" | ||
rules { | ||
name = "Rule-1" | ||
order = 0 | ||
category = "PreContact" | ||
conditions { | ||
inverted = true | ||
contact_column_condition_settings { | ||
column_name = "Work" | ||
operator = "Equals" | ||
value = "\"XYZ\"" | ||
value_type = "String" | ||
} | ||
} | ||
actions { | ||
do_not_send_action_settings = jsonencode({}) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `rules` (Block List, Min: 1) The list of rules. (see [below for nested schema](#nestedblock--rules)) | ||
|
||
### Optional | ||
|
||
- `contact_list_id` (String) A ContactList to provide suggestions for contact columns on relevant conditions and actions. | ||
- `name` (String) The name of the digital rule set | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--rules"></a> | ||
### Nested Schema for `rules` | ||
|
||
Required: | ||
|
||
- `actions` (Block List, Min: 1) The list of actions to be taken if all conditions are true. (see [below for nested schema](#nestedblock--rules--actions)) | ||
- `category` (String) The category of the rule. | ||
- `conditions` (Block List, Min: 1) A list of conditions to evaluate. All of the Conditions must evaluate to true to trigger the actions. (see [below for nested schema](#nestedblock--rules--conditions)) | ||
- `name` (String) The name of the rule. | ||
- `order` (Number) The ranked order of the rule. Rules are processed from lowest number to highest. | ||
|
||
<a id="nestedblock--rules--actions"></a> | ||
### Nested Schema for `rules.actions` | ||
|
||
Optional: | ||
|
||
- `append_to_dnc_action_settings` (Block Set, Max: 1) The settings for an 'Append to DNC' action. (see [below for nested schema](#nestedblock--rules--actions--append_to_dnc_action_settings)) | ||
- `do_not_send_action_settings` (String) The settings for a 'do not send' action. | ||
- `mark_contact_address_uncontactable_action_settings` (String) The settings for an 'mark contact address uncontactable' action. | ||
- `mark_contact_uncontactable_action_settings` (Block Set, Max: 1) The settings for a 'mark contact uncontactable' action. (see [below for nested schema](#nestedblock--rules--actions--mark_contact_uncontactable_action_settings)) | ||
- `set_content_template_action_settings` (Block Set, Max: 1) The settings for a 'Set content template' action. (see [below for nested schema](#nestedblock--rules--actions--set_content_template_action_settings)) | ||
- `set_sms_phone_number_action_settings` (Block Set, Max: 1) The settings for a 'set sms phone number' action. (see [below for nested schema](#nestedblock--rules--actions--set_sms_phone_number_action_settings)) | ||
- `update_contact_column_action_settings` (Block Set, Max: 1) The settings for an 'update contact column' action. (see [below for nested schema](#nestedblock--rules--actions--update_contact_column_action_settings)) | ||
|
||
<a id="nestedblock--rules--actions--append_to_dnc_action_settings"></a> | ||
### Nested Schema for `rules.actions.append_to_dnc_action_settings` | ||
|
||
Required: | ||
|
||
- `expire` (Boolean) Whether to expire the record appended to the DNC list. | ||
|
||
Optional: | ||
|
||
- `expiration_duration` (String) If 'expire' is set to true, how long to keep the record. | ||
- `list_type` (String) The Dnc List Type to append entries to | ||
|
||
|
||
<a id="nestedblock--rules--actions--mark_contact_uncontactable_action_settings"></a> | ||
### Nested Schema for `rules.actions.mark_contact_uncontactable_action_settings` | ||
|
||
Required: | ||
|
||
- `media_types` (List of String) A list of media types to evaluate. | ||
|
||
|
||
<a id="nestedblock--rules--actions--set_content_template_action_settings"></a> | ||
### Nested Schema for `rules.actions.set_content_template_action_settings` | ||
|
||
Required: | ||
|
||
- `email_content_template_id` (String) A string of email contentTemplateId. | ||
- `sms_content_template_id` (String) A string of sms contentTemplateId. | ||
|
||
|
||
<a id="nestedblock--rules--actions--set_sms_phone_number_action_settings"></a> | ||
### Nested Schema for `rules.actions.set_sms_phone_number_action_settings` | ||
|
||
Required: | ||
|
||
- `sender_sms_phone_number` (String) The string address for the sms phone number. | ||
|
||
|
||
<a id="nestedblock--rules--actions--update_contact_column_action_settings"></a> | ||
### Nested Schema for `rules.actions.update_contact_column_action_settings` | ||
|
||
Required: | ||
|
||
- `update_option` (String) The type of update to make to the specified contact column(s). | ||
|
||
Optional: | ||
|
||
- `properties` (String) A map of key-value pairs pertinent to the DialerAction. Different types of DialerActions require different properties. MODIFY_CONTACT_ATTRIBUTE with an updateOption of SET takes a contact column as the key and accepts any value. SCHEDULE_CALLBACK takes a key 'callbackOffset' that specifies how far in the future the callback should be scheduled, in minutes. SET_CALLER_ID takes two keys: 'callerAddress', which should be the caller id phone number, and 'callerName'. For either key, you can also specify a column on the contact to get the value from. To do this, specify 'contact.Column', where 'Column' is the name of the contact column from which to get the value. SET_SKILLS takes a key 'skills' with an array of skill ids wrapped into a string (Example: {'skills': '['skillIdHere']'} ). | ||
|
||
|
||
|
||
<a id="nestedblock--rules--conditions"></a> | ||
### Nested Schema for `rules.conditions` | ||
|
||
Optional: | ||
|
||
- `contact_address_condition_settings` (Block Set, Max: 1) The settings for a 'contact address' condition. (see [below for nested schema](#nestedblock--rules--conditions--contact_address_condition_settings)) | ||
- `contact_address_type_condition_settings` (Block Set, Max: 1) The settings for a 'contact address type' condition. (see [below for nested schema](#nestedblock--rules--conditions--contact_address_type_condition_settings)) | ||
- `contact_column_condition_settings` (Block Set, Max: 1) The settings for a 'contact list column' condition. (see [below for nested schema](#nestedblock--rules--conditions--contact_column_condition_settings)) | ||
- `data_action_condition_settings` (Block Set, Max: 1) The settings for a 'data action' condition. (see [below for nested schema](#nestedblock--rules--conditions--data_action_condition_settings)) | ||
- `inverted` (Boolean) If true, inverts the result of evaluating this condition. Default is false. | ||
- `last_attempt_by_column_condition_settings` (Block Set, Max: 1) The settings for a 'last attempt by column' condition. (see [below for nested schema](#nestedblock--rules--conditions--last_attempt_by_column_condition_settings)) | ||
- `last_attempt_overall_condition_settings` (Block Set, Max: 1) The settings for a 'last attempt overall' condition. (see [below for nested schema](#nestedblock--rules--conditions--last_attempt_overall_condition_settings)) | ||
- `last_result_by_column_condition_settings` (Block Set, Max: 1) The settings for a 'last result by column' condition. (see [below for nested schema](#nestedblock--rules--conditions--last_result_by_column_condition_settings)) | ||
- `last_result_overall_condition_settings` (Block Set, Max: 1) The settings for a 'last result overall' condition. (see [below for nested schema](#nestedblock--rules--conditions--last_result_overall_condition_settings)) | ||
|
||
<a id="nestedblock--rules--conditions--contact_address_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.contact_address_condition_settings` | ||
|
||
Required: | ||
|
||
- `operator` (String) The operator to use when comparing address values. | ||
- `value` (String) The value to compare against the contact's address. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--contact_address_type_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.contact_address_type_condition_settings` | ||
|
||
Required: | ||
|
||
- `operator` (String) The operator to use when comparing the address types. | ||
- `value` (String) The type value to compare against the contact column type. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--contact_column_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.contact_column_condition_settings` | ||
|
||
Required: | ||
|
||
- `column_name` (String) The name of the contact list column to evaluate. | ||
- `operator` (String) The operator to use when comparing values. | ||
- `value` (String) The value to compare against the contact's data. | ||
- `value_type` (String) The data type the value should be treated as. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--data_action_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.data_action_condition_settings` | ||
|
||
Required: | ||
|
||
- `data_action_id` (String) The Data Action Id to use for this condition. | ||
- `data_not_found_resolution` (Boolean) The result of this condition if the data action returns a result indicating there was no data. | ||
|
||
Optional: | ||
|
||
- `contact_column_to_data_action_field_mappings` (Block List) A list of mappings defining which contact data fields will be passed to which data action input fields. (see [below for nested schema](#nestedblock--rules--conditions--data_action_condition_settings--contact_column_to_data_action_field_mappings)) | ||
- `contact_id_field` (String) The input field from the data action that the contactId will be passed into. | ||
- `predicates` (Block List) A list of predicates defining the comparisons to use for this condition. (see [below for nested schema](#nestedblock--rules--conditions--data_action_condition_settings--predicates)) | ||
|
||
<a id="nestedblock--rules--conditions--data_action_condition_settings--contact_column_to_data_action_field_mappings"></a> | ||
### Nested Schema for `rules.conditions.data_action_condition_settings.contact_column_to_data_action_field_mappings` | ||
|
||
Required: | ||
|
||
- `contact_column_name` (String) The name of a contact column whose data will be passed to the data action | ||
- `data_action_field` (String) The name of an input field from the data action that the contact column data will be passed to | ||
|
||
|
||
<a id="nestedblock--rules--conditions--data_action_condition_settings--predicates"></a> | ||
### Nested Schema for `rules.conditions.data_action_condition_settings.predicates` | ||
|
||
Required: | ||
|
||
- `comparison_value` (String) The value to compare against for this condition | ||
- `inverted` (Boolean) If true, inverts the result of evaluating this Predicate. Default is false. | ||
- `output_field` (String) The name of an output field from the data action's output to use for this condition | ||
- `output_field_missing_resolution` (Boolean) The result of this predicate if the requested output field is missing from the data action's result | ||
- `output_operator` (String) The operation with which to evaluate this condition | ||
|
||
|
||
|
||
<a id="nestedblock--rules--conditions--last_attempt_by_column_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.last_attempt_by_column_condition_settings` | ||
|
||
Required: | ||
|
||
- `operator` (String) The operator to use when comparing values. | ||
- `value` (String) The period value to compare against the contact's data. | ||
|
||
Optional: | ||
|
||
- `email_column_name` (String) The name of the contact column to evaluate for Email. | ||
- `sms_column_name` (String) The name of the contact column to evaluate for SMS. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--last_attempt_overall_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.last_attempt_overall_condition_settings` | ||
|
||
Required: | ||
|
||
- `media_types` (List of String) A list of media types to evaluate. | ||
- `operator` (String) The operator to use when comparing values. | ||
- `value` (String) The period value to compare against the contact's data. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--last_result_by_column_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.last_result_by_column_condition_settings` | ||
|
||
Optional: | ||
|
||
- `email_column_name` (String) The name of the contact column to evaluate for Email. | ||
- `email_wrapup_codes` (List of String) A list of wrapup code identifiers to match for Email. | ||
- `sms_column_name` (String) The name of the contact column to evaluate for SMS. | ||
- `sms_wrapup_codes` (List of String) A list of wrapup code identifiers to match for SMS. | ||
|
||
|
||
<a id="nestedblock--rules--conditions--last_result_overall_condition_settings"></a> | ||
### Nested Schema for `rules.conditions.last_result_overall_condition_settings` | ||
|
||
Optional: | ||
|
||
- `email_wrapup_codes` (List of String) A list of wrapup code identifiers to match for Email. | ||
- `sms_wrapup_codes` (List of String) A list of wrapup code identifiers to match for SMS. | ||
|
3 changes: 3 additions & 0 deletions
3
examples/data-sources/genesyscloud_outbound_digitalruleset/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "genesyscloud_outbound_digitalruleset" "digital-ruleset" { | ||
name = "Digital RuleSet Test" | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/resources/genesyscloud_outbound_digitalruleset/apis.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* [POST /api/v2/outbound/digitalrulesets](https://developer.genesys.cloud/devapps/api-explorer#post-api-v2-outbound-digitalrulesets) | ||
* [GET /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [PUT /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#put-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [DELETE /api/v2/outbound/digitalrulesets/{digitalRuleSetId}](https://developer.genesys.cloud/devapps/api-explorer#delete-api-v2-outbound-digitalrulesets--digitalRuleSetId-) | ||
* [GET /api/v2/outbound/digitalrulesets](https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-outbound-digitalrulesets) | ||
|
23 changes: 23 additions & 0 deletions
23
examples/resources/genesyscloud_outbound_digitalruleset/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
resource "genesyscloud_outbound_digitalruleset" "test_ruleset_sample" { | ||
name = "Test Digital RuleSet - 13" | ||
version = 1 | ||
contact_list_id = "c2406f62-63e3-4826-a6f9-ae635bd731e0" | ||
rules { | ||
name = "Rule-1" | ||
order = 0 | ||
category = "PreContact" | ||
conditions { | ||
inverted = true | ||
contact_column_condition_settings { | ||
column_name = "Work" | ||
operator = "Equals" | ||
value = "\"XYZ\"" | ||
value_type = "String" | ||
} | ||
} | ||
actions { | ||
do_not_send_action_settings = jsonencode({}) | ||
} | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
genesyscloud/outbound_digitalruleset/data_source_genesyscloud_outbound_digitalruleset.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package outbound_digitalruleset | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" | ||
|
||
"terraform-provider-genesyscloud/genesyscloud/provider" | ||
"terraform-provider-genesyscloud/genesyscloud/util" | ||
) | ||
|
||
/* | ||
The data_source_genesyscloud_outbound_digitalruleset.go contains the data source implementation | ||
for the resource. | ||
*/ | ||
|
||
// dataSourceOutboundDigitalrulesetRead retrieves by name the id in question | ||
func dataSourceOutboundDigitalrulesetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
sdkConfig := meta.(*provider.ProviderMeta).ClientConfig | ||
proxy := getOutboundDigitalrulesetProxy(sdkConfig) | ||
|
||
name := d.Get("name").(string) | ||
|
||
return util.WithRetries(ctx, 15*time.Second, func() *retry.RetryError { | ||
digitalRuleSetId, resp, retryable, err := proxy.getOutboundDigitalrulesetIdByName(ctx, name) | ||
|
||
if err != nil && !retryable { | ||
return retry.NonRetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("Error searching outbound digitalruleset %s: %s", name, err), resp)) | ||
} | ||
|
||
if retryable { | ||
return retry.RetryableError(util.BuildWithRetriesApiDiagnosticError(resourceName, fmt.Sprintf("No outbound digitalruleset found with name %s", name), resp)) | ||
} | ||
|
||
d.SetId(digitalRuleSetId) | ||
return nil | ||
}) | ||
} |
Oops, something went wrong.