{
  "typeName" : "AWS::Connect::Rule",
  "description" : "Creates a rule for the specified CON instance.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-connect",
  "definitions" : {
    "FieldValue" : {
      "description" : "Object for case field values.",
      "type" : "object",
      "properties" : {
        "StringValue" : {
          "type" : "string",
          "description" : ""
        },
        "BooleanValue" : {
          "type" : "boolean",
          "description" : ""
        },
        "DoubleValue" : {
          "type" : "number",
          "description" : ""
        },
        "EmptyValue" : {
          "type" : "object",
          "description" : ""
        }
      },
      "additionalProperties" : false
    },
    "Field" : {
      "description" : "",
      "type" : "object",
      "properties" : {
        "Id" : {
          "description" : "",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 500
        },
        "Value" : {
          "$ref" : "#/definitions/FieldValue",
          "description" : ""
        }
      },
      "required" : [ "Id", "Value" ],
      "additionalProperties" : false
    },
    "Fields" : {
      "description" : "An array of case fields",
      "type" : "array",
      "insertionOrder" : true,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/Field"
      },
      "minItems" : 1,
      "maxItems" : 100
    },
    "UserArn" : {
      "description" : "The Amazon Resource Name (ARN) of the user or a dynamic recipient string starting with '$.'.",
      "type" : "string",
      "pattern" : "^$|arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*/agent/[-a-zA-Z0-9]*$|^\\$\\..+$"
    },
    "NotificationRecipientType" : {
      "description" : "The type of notification recipient.",
      "type" : "object",
      "properties" : {
        "UserTags" : {
          "description" : "The tags used to organize, track, or control access for this resource. For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }. CON users with the specified tags will be notified.",
          "patternProperties" : {
            "^.{1,128}$" : {
              "type" : "string"
            }
          },
          "additionalProperties" : false
        },
        "UserArns" : {
          "description" : "The Amazon Resource Name (ARN) of the user account.",
          "type" : "array",
          "minItems" : 1,
          "maxItems" : 5,
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/UserArn"
          }
        }
      },
      "additionalProperties" : false
    },
    "Reference" : {
      "description" : "Information about the reference when the ``referenceType`` is ``URL``. Otherwise, null. (Supports variable injection in the ``Value`` field.)",
      "type" : "object",
      "properties" : {
        "Value" : {
          "type" : "string",
          "pattern" : "^(/|https:)",
          "description" : "A valid value for the reference. For example, for a URL reference, a formatted URL that is displayed to an agent in the Contact Control Panel (CCP)."
        },
        "Type" : {
          "type" : "string",
          "enum" : [ "URL", "ATTACHMENT", "NUMBER", "STRING", "DATE", "EMAIL" ],
          "description" : "The type of the reference. ``DATE`` must be of type Epoch timestamp. \n *Allowed values*: ``URL`` | ``ATTACHMENT`` | ``NUMBER`` | ``STRING`` | ``DATE`` | ``EMAIL``"
        }
      },
      "required" : [ "Value", "Type" ],
      "additionalProperties" : false
    },
    "TaskAction" : {
      "description" : "Information about the task action. This field is required if ``TriggerEventSource`` is one of the following values: ``OnZendeskTicketCreate`` | ``OnZendeskTicketStatusUpdate`` | ``OnSalesforceCaseCreate``",
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name. Supports variable injection. For more information, see [JSONPath reference](https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-variable-injection.html) in the *Administrators Guide*.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 512
        },
        "Description" : {
          "description" : "The description. Supports variable injection. For more information, see [JSONPath reference](https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-variable-injection.html) in the *Administrators Guide*.",
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 4096
        },
        "ContactFlowArn" : {
          "description" : "The Amazon Resource Name (ARN) of the flow.",
          "type" : "string",
          "pattern" : "^$|arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*/contact-flow/[-a-zA-Z0-9]*$"
        },
        "References" : {
          "description" : "Information about the reference when the ``referenceType`` is ``URL``. Otherwise, null. ``URL`` is the only accepted type. (Supports variable injection in the ``Value`` field.)",
          "patternProperties" : {
            "^.+$" : {
              "$ref" : "#/definitions/Reference"
            }
          },
          "additionalProperties" : false
        }
      },
      "required" : [ "Name", "ContactFlowArn" ],
      "additionalProperties" : false
    },
    "SubmitAutoEvaluationAction" : {
      "description" : "",
      "type" : "object",
      "properties" : {
        "EvaluationFormArn" : {
          "description" : "",
          "type" : "string",
          "pattern" : "^$|arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*/evaluation-form/[-a-zA-Z0-9]*$"
        }
      },
      "required" : [ "EvaluationFormArn" ],
      "additionalProperties" : false
    },
    "EventBridgeAction" : {
      "description" : "The EV action definition.",
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name.",
          "type" : "string",
          "pattern" : "^[a-zA-Z0-9._-]{1,100}$"
        }
      },
      "required" : [ "Name" ],
      "additionalProperties" : false
    },
    "AssignContactCategoryAction" : {
      "description" : "The definition for assigning contact category action.",
      "type" : "object"
    },
    "SendNotificationAction" : {
      "description" : "Information about the send notification action.",
      "type" : "object",
      "properties" : {
        "DeliveryMethod" : {
          "description" : "Notification delivery method.\n *Allowed value*: ``EMAIL``",
          "type" : "string",
          "enum" : [ "EMAIL" ]
        },
        "Subject" : {
          "description" : "The subject of the email if the delivery method is ``EMAIL``. Supports variable injection. For more information, see [JSONPath reference](https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-variable-injection.html) in the *Administrators Guide*.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 200
        },
        "Content" : {
          "description" : "Notification content. Supports variable injection. For more information, see [JSONPath reference](https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-variable-injection.html) in the *Administrators Guide*.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 1024
        },
        "ContentType" : {
          "description" : "Content type format.\n *Allowed value*: ``PLAIN_TEXT``",
          "type" : "string",
          "enum" : [ "PLAIN_TEXT" ]
        },
        "Recipient" : {
          "$ref" : "#/definitions/NotificationRecipientType",
          "description" : "Notification recipient."
        }
      },
      "required" : [ "DeliveryMethod", "Content", "Recipient", "ContentType" ],
      "additionalProperties" : false
    },
    "CreateCaseAction" : {
      "description" : "",
      "type" : "object",
      "properties" : {
        "Fields" : {
          "$ref" : "#/definitions/Fields",
          "description" : ""
        },
        "TemplateId" : {
          "description" : "",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 500
        }
      },
      "required" : [ "Fields", "TemplateId" ],
      "additionalProperties" : false
    },
    "UpdateCaseAction" : {
      "description" : "",
      "type" : "object",
      "properties" : {
        "Fields" : {
          "$ref" : "#/definitions/Fields",
          "description" : ""
        }
      },
      "required" : [ "Fields" ],
      "additionalProperties" : false
    },
    "EndAssociatedTasksAction" : {
      "description" : "The definition for ending associated task action.",
      "type" : "object"
    },
    "AssignContactCategoryActions" : {
      "description" : "This action will assign contact category when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/AssignContactCategoryAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "EventBridgeActions" : {
      "description" : "This action will send event bridge notification when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/EventBridgeAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "RuleTriggerEventSource" : {
      "description" : "The name of the event source.",
      "type" : "object",
      "properties" : {
        "EventSourceName" : {
          "description" : "The name of the event source.",
          "type" : "string",
          "enum" : [ "OnContactEvaluationSubmit", "OnPostCallAnalysisAvailable", "OnRealTimeCallAnalysisAvailable", "OnRealTimeChatAnalysisAvailable", "OnPostChatAnalysisAvailable", "OnZendeskTicketCreate", "OnZendeskTicketStatusUpdate", "OnSalesforceCaseCreate", "OnMetricDataUpdate", "OnCaseCreate", "OnCaseUpdate" ]
        },
        "IntegrationAssociationArn" : {
          "description" : "The Amazon Resource Name (ARN) of the integration association. ``IntegrationAssociationArn`` is required if ``TriggerEventSource`` is one of the following values: ``OnZendeskTicketCreate`` | ``OnZendeskTicketStatusUpdate`` | ``OnSalesforceCaseCreate``",
          "type" : "string",
          "pattern" : "^$|arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*/integration-association/[-a-zA-Z0-9]*$"
        }
      },
      "required" : [ "EventSourceName" ],
      "additionalProperties" : false
    },
    "TaskActions" : {
      "description" : "This action will generate a task when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/TaskAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "SendNotificationActions" : {
      "description" : "The action will send notification when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/SendNotificationAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "CreateCaseActions" : {
      "description" : "This action will create a case when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/CreateCaseAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "UpdateCaseActions" : {
      "description" : "This action will update a case when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/UpdateCaseAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "EndAssociatedTasksActions" : {
      "description" : "This action will end associated tasks when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/EndAssociatedTasksAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "SubmitAutoEvaluationActions" : {
      "description" : "This action will submit an auto contact evaluation when a rule is triggered.",
      "type" : "array",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/SubmitAutoEvaluationAction"
      },
      "minItems" : 1,
      "maxItems" : 1
    },
    "Actions" : {
      "description" : "A list of actions to be run when the rule is triggered.",
      "type" : "object",
      "properties" : {
        "AssignContactCategoryActions" : {
          "$ref" : "#/definitions/AssignContactCategoryActions",
          "description" : "Information about the contact category action. The syntax can be empty, for example, ``{}``."
        },
        "EventBridgeActions" : {
          "$ref" : "#/definitions/EventBridgeActions",
          "description" : "Information about the EV action."
        },
        "TaskActions" : {
          "$ref" : "#/definitions/TaskActions",
          "description" : "Information about the task action. This field is required if ``TriggerEventSource`` is one of the following values: ``OnZendeskTicketCreate`` | ``OnZendeskTicketStatusUpdate`` | ``OnSalesforceCaseCreate``"
        },
        "SendNotificationActions" : {
          "$ref" : "#/definitions/SendNotificationActions",
          "description" : "Information about the send notification action."
        },
        "CreateCaseActions" : {
          "$ref" : "#/definitions/CreateCaseActions",
          "description" : ""
        },
        "UpdateCaseActions" : {
          "$ref" : "#/definitions/UpdateCaseActions",
          "description" : ""
        },
        "EndAssociatedTasksActions" : {
          "$ref" : "#/definitions/EndAssociatedTasksActions",
          "description" : ""
        },
        "SubmitAutoEvaluationActions" : {
          "$ref" : "#/definitions/SubmitAutoEvaluationActions",
          "description" : ""
        }
      },
      "additionalProperties" : false
    },
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Key" : {
          "type" : "string",
          "description" : "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -",
          "pattern" : "^[a-zA-Z+-=._:/]+$",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "description" : "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -",
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ]
    }
  },
  "properties" : {
    "Name" : {
      "description" : "The name of the rule.",
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9._-]{1,200}$"
    },
    "RuleArn" : {
      "description" : "",
      "type" : "string",
      "pattern" : "^arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*/rule/[-a-zA-Z0-9]*$"
    },
    "InstanceArn" : {
      "description" : "The Amazon Resource Name (ARN) of the instance.",
      "type" : "string",
      "pattern" : "^arn:aws[-a-z0-9]*:connect:[-a-z0-9]*:[0-9]{12}:instance/[-a-zA-Z0-9]*$"
    },
    "TriggerEventSource" : {
      "description" : "The event source to trigger the rule.",
      "$ref" : "#/definitions/RuleTriggerEventSource"
    },
    "Function" : {
      "description" : "The conditions of the rule.",
      "type" : "string"
    },
    "Actions" : {
      "description" : "A list of actions to be run when the rule is triggered.",
      "$ref" : "#/definitions/Actions"
    },
    "PublishStatus" : {
      "description" : "The publish status of the rule.\n *Allowed values*: ``DRAFT`` | ``PUBLISHED``",
      "type" : "string",
      "enum" : [ "DRAFT", "PUBLISHED" ]
    },
    "Tags" : {
      "description" : "The tags used to organize, track, or control access for this resource. For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.",
      "type" : "array",
      "maxItems" : 50,
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    }
  },
  "required" : [ "Name", "InstanceArn", "TriggerEventSource", "Function", "Actions", "PublishStatus" ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : false,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "connect:TagResource", "connect:UntagResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "connect:CreateRule", "cases:GetTemplate", "cases:ListFields", "cases:ListFieldOptions", "connect:TagResource", "connect:DeleteRule" ]
    },
    "read" : {
      "permissions" : [ "connect:DescribeRule" ]
    },
    "delete" : {
      "permissions" : [ "connect:DeleteRule", "connect:UntagResource" ]
    },
    "update" : {
      "permissions" : [ "connect:UpdateRule", "cases:GetTemplate", "cases:ListFields", "cases:ListFieldOptions", "connect:TagResource", "connect:UntagResource" ]
    },
    "list" : {
      "handlerSchema" : {
        "properties" : {
          "InstanceArn" : {
            "$ref" : "resource-schema.json#/properties/InstanceArn"
          }
        },
        "required" : [ "InstanceArn" ]
      },
      "permissions" : [ "connect:ListRules" ]
    }
  },
  "additionalProperties" : false,
  "primaryIdentifier" : [ "/properties/RuleArn" ],
  "readOnlyProperties" : [ "/properties/RuleArn" ],
  "createOnlyProperties" : [ "/properties/TriggerEventSource", "/properties/InstanceArn" ],
  "replacementStrategy" : "delete_then_create"
}