diff --git a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route.go b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route.go index 2b7615def..bca09f5ab 100644 --- a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route.go +++ b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route.go @@ -127,12 +127,14 @@ func readRoutingEmailRoute(ctx context.Context, d *schema.ResourceData, meta int resourcedata.SetNillableValue(d, "pattern", route.Pattern) resourcedata.SetNillableReference(d, "queue_id", route.Queue) resourcedata.SetNillableValue(d, "priority", route.Priority) + resourcedata.SetNillableValue(d, "history_inclusion", route.HistoryInclusion) resourcedata.SetNillableReference(d, "language_id", route.Language) resourcedata.SetNillableValue(d, "from_name", route.FromName) resourcedata.SetNillableValue(d, "from_email", route.FromEmail) resourcedata.SetNillableReference(d, "flow_id", route.Flow) resourcedata.SetNillableValueWithInterfaceArrayWithFunc(d, "auto_bcc", route.AutoBcc, flattenAutoBccEmailAddress) resourcedata.SetNillableReference(d, "spam_flow_id", route.SpamFlow) + resourcedata.SetNillableValue(d, "allow_multiple_actions", route.AllowMultipleActions) if route.Skills != nil { _ = d.Set("skill_ids", util.SdkDomainEntityRefArrToSet(*route.Skills)) diff --git a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_schema.go b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_schema.go index 3440646a0..62a9f4cfc 100644 --- a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_schema.go +++ b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_schema.go @@ -1,6 +1,7 @@ package routing_email_route import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "terraform-provider-genesyscloud/genesyscloud/provider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -103,6 +104,18 @@ func ResourceRoutingEmailRoute() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "history_inclusion": { + Description: "The configuration to indicate how the history of a conversation has to be included in a draft.", + Type: schema.TypeString, + Optional: true, + Default: "Optional", + ValidateFunc: validation.StringInSlice([]string{"Include", "Exclude", "Optional"}, true), + }, + "allow_multiple_actions": { + Description: "Control if multiple actions are allowed on this route. When true the disconnect has to be done manually. When false a conversation will be disconnected by the system after every action.", + Type: schema.TypeBool, + Optional: true, + }, "reply_email_address": { Description: "The route to use for email replies. This should not be set if from_email or auto_bcc are specified.", Type: schema.TypeList, 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 aded63f2d..36a71bba0 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 @@ -23,26 +23,28 @@ import ( func TestAccResourceRoutingEmailRoute(t *testing.T) { var ( - domainResourceLabel = "routing-domain1" - domainId = fmt.Sprintf("terraformroutes.%s.com", strings.Replace(uuid.NewString(), "-", "", -1)) - queueResourceLabel = "email-queue" - queueName = "Terraform Email Queue-" + uuid.NewString() - langResourceLabel = "email-lang" - langName = "tflang" + uuid.NewString() - skillResourceLabel = "test-skill1" - skillName = "Terraform Skill" + uuid.NewString() - routeResourceLabel1 = "email-route1" - routeResourceLabel2 = "email-route2" - routePattern1 = "terraform1" - routePattern2 = "terraform2" - routePattern3 = "terraform3" - fromEmail1 = "terraform1@test.com" - fromEmail2 = "terraform2@test.com" - fromName1 = "John Terraform" - fromName2 = "Jane Terraform" - priority1 = "1" - bccEmail1 = "test1@" + domainId - bccEmail2 = "test2@" + domainId + domainResourceLabel = "routing-domain1" + domainId = fmt.Sprintf("terraformroutes.%s.com", strings.Replace(uuid.NewString(), "-", "", -1)) + queueResourceLabel = "email-queue" + queueName = "Terraform Email Queue-" + uuid.NewString() + langResourceLabel = "email-lang" + langName = "tflang" + uuid.NewString() + skillResourceLabel = "test-skill1" + skillName = "Terraform Skill" + uuid.NewString() + routeResourceLabel1 = "email-route1" + routeResourceLabel2 = "email-route2" + routePattern1 = "terraform1" + routePattern2 = "terraform2" + routePattern3 = "terraform3" + fromEmail1 = "terraform1@test.com" + fromEmail2 = "terraform2@test.com" + fromName1 = "John Terraform" + fromName2 = "Jane Terraform" + priority1 = "1" + bccEmail1 = "test1@" + domainId + bccEmail2 = "test2@" + domainId + allowMultipleActions = "true" + historyInclusion = "Include" ) CleanupRoutingEmailDomains() @@ -65,6 +67,8 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { routePattern1, fromName1, fmt.Sprintf("from_email = \"%s\"", fromEmail1), + fmt.Sprintf("allow_multiple_actions = \"%s\"", allowMultipleActions), + fmt.Sprintf("history_inclusion = \"%s\"", historyInclusion), generateRoutingAutoBcc(fromName1, bccEmail1), ), Check: resource.ComposeTestCheckFunc( @@ -74,6 +78,8 @@ func TestAccResourceRoutingEmailRoute(t *testing.T) { resource.TestCheckResourceAttr("genesyscloud_routing_email_route."+routeResourceLabel1, "from_email", fromEmail1), resource.TestCheckResourceAttr("genesyscloud_routing_email_route."+routeResourceLabel1, "auto_bcc.0.name", fromName1), resource.TestCheckResourceAttr("genesyscloud_routing_email_route."+routeResourceLabel1, "auto_bcc.0.email", bccEmail1), + resource.TestCheckResourceAttr("genesyscloud_routing_email_route."+routeResourceLabel1, "allow_multiple_actions", allowMultipleActions), + resource.TestCheckResourceAttr("genesyscloud_routing_email_route."+routeResourceLabel1, "history_inclusion", historyInclusion), ), }, { diff --git a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_utils.go b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_utils.go index ea44ff546..e5d931232 100644 --- a/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_utils.go +++ b/genesyscloud/routing_email_route/resource_genesyscloud_routing_email_route_utils.go @@ -19,7 +19,7 @@ and unmarshal data into formats consumable by Terraform and/or Genesys Cloud. // getRoutingEmailRouteFromResourceData maps data from schema ResourceData object to a platformclientv2.Inboundroute func getRoutingEmailRouteFromResourceData(d *schema.ResourceData) platformclientv2.Inboundroute { id := d.Id() - return platformclientv2.Inboundroute{ + inboundRoute := platformclientv2.Inboundroute{ Id: &id, Pattern: platformclientv2.String(d.Get("pattern").(string)), Queue: util.BuildSdkDomainEntityRef(d, "queue_id"), @@ -32,6 +32,16 @@ func getRoutingEmailRouteFromResourceData(d *schema.ResourceData) platformclient AutoBcc: buildAutoBccEmailAddresses(d), SpamFlow: util.BuildSdkDomainEntityRef(d, "spam_flow_id"), } + + if d.Get("history_inclusion") != "" { + fmt.Println("reached") + fmt.Printf("%v ", platformclientv2.String(d.Get("history_inclusion").(string))) + inboundRoute.HistoryInclusion = platformclientv2.String(d.Get("history_inclusion").(string)) + } + if d.Get("allow_multiple_actions") != "" { + inboundRoute.AllowMultipleActions = platformclientv2.Bool(d.Get("allow_multiple_actions").(bool)) + } + return inboundRoute } // Build Functions @@ -166,11 +176,14 @@ func GenerateRoutingEmailRouteResource( pattern string, fromName string, otherAttrs ...string) string { - return fmt.Sprintf(`resource "genesyscloud_routing_email_route" "%s" { + hh := fmt.Sprintf(`resource "genesyscloud_routing_email_route" "%s" { domain_id = %s pattern = "%s" from_name = "%s" %s } `, resourceLabel, domainID, pattern, fromName, strings.Join(otherAttrs, "\n")) + + fmt.Println(hh) + return hh }