{
  "typeName" : "AWS::FraudDetector::Detector",
  "description" : "A resource schema for a Detector in Amazon Fraud Detector.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "Tag" : {
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "EventVariable" : {
      "type" : "object",
      "properties" : {
        "Arn" : {
          "type" : "string"
        },
        "Inline" : {
          "type" : "boolean"
        },
        "Name" : {
          "type" : "string"
        },
        "DataSource" : {
          "type" : "string",
          "enum" : [ "EVENT" ]
        },
        "DataType" : {
          "type" : "string",
          "enum" : [ "STRING", "INTEGER", "FLOAT", "BOOLEAN" ]
        },
        "DefaultValue" : {
          "type" : "string"
        },
        "VariableType" : {
          "type" : "string",
          "enum" : [ "AUTH_CODE", "AVS", "BILLING_ADDRESS_L1", "BILLING_ADDRESS_L2", "BILLING_CITY", "BILLING_COUNTRY", "BILLING_NAME", "BILLING_PHONE", "BILLING_STATE", "BILLING_ZIP", "CARD_BIN", "CATEGORICAL", "CURRENCY_CODE", "EMAIL_ADDRESS", "FINGERPRINT", "FRAUD_LABEL", "FREE_FORM_TEXT", "IP_ADDRESS", "NUMERIC", "ORDER_ID", "PAYMENT_TYPE", "PHONE_NUMBER", "PRICE", "PRODUCT_CATEGORY", "SHIPPING_ADDRESS_L1", "SHIPPING_ADDRESS_L2", "SHIPPING_CITY", "SHIPPING_COUNTRY", "SHIPPING_NAME", "SHIPPING_PHONE", "SHIPPING_STATE", "SHIPPING_ZIP", "USERAGENT" ]
        },
        "Description" : {
          "description" : "The description.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "Tags" : {
          "description" : "Tags associated with this event variable.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "CreatedTime" : {
          "description" : "The time when the event variable was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the event variable was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "Label" : {
      "type" : "object",
      "properties" : {
        "Arn" : {
          "type" : "string"
        },
        "Inline" : {
          "type" : "boolean"
        },
        "Name" : {
          "type" : "string"
        },
        "Description" : {
          "description" : "The description.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "Tags" : {
          "description" : "Tags associated with this label.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "CreatedTime" : {
          "description" : "The time when the label was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the label was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "Outcome" : {
      "type" : "object",
      "properties" : {
        "Arn" : {
          "type" : "string"
        },
        "Inline" : {
          "type" : "boolean"
        },
        "Name" : {
          "type" : "string"
        },
        "Description" : {
          "description" : "The description.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "Tags" : {
          "description" : "Tags associated with this outcome.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "CreatedTime" : {
          "description" : "The time when the outcome was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the outcome was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "Rule" : {
      "type" : "object",
      "properties" : {
        "RuleId" : {
          "type" : "string"
        },
        "RuleVersion" : {
          "type" : "string"
        },
        "DetectorId" : {
          "type" : "string"
        },
        "Expression" : {
          "type" : "string"
        },
        "Language" : {
          "type" : "string",
          "enum" : [ "DETECTORPL" ]
        },
        "Outcomes" : {
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "minItems" : 1,
          "items" : {
            "$ref" : "#/definitions/Outcome"
          }
        },
        "Arn" : {
          "type" : "string"
        },
        "Description" : {
          "description" : "The description.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "Tags" : {
          "description" : "Tags associated with this event type.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "CreatedTime" : {
          "description" : "The time when the event type was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the event type was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "EntityType" : {
      "type" : "object",
      "properties" : {
        "Arn" : {
          "type" : "string"
        },
        "Inline" : {
          "type" : "boolean"
        },
        "Name" : {
          "type" : "string"
        },
        "Description" : {
          "description" : "The description.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        },
        "Tags" : {
          "description" : "Tags associated with this entity type.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "CreatedTime" : {
          "description" : "The time when the entity type was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the entity type was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "EventType" : {
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name for the event type",
          "type" : "string",
          "pattern" : "^[0-9a-z_-]+$",
          "minLength" : 1,
          "maxLength" : 64
        },
        "Inline" : {
          "type" : "boolean"
        },
        "Tags" : {
          "description" : "Tags associated with this event type.",
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "maxItems" : 200,
          "items" : {
            "$ref" : "#/definitions/Tag"
          }
        },
        "Description" : {
          "description" : "The description of the event type.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128
        },
        "EventVariables" : {
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "minItems" : 1,
          "items" : {
            "$ref" : "#/definitions/EventVariable"
          }
        },
        "Labels" : {
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "minItems" : 2,
          "items" : {
            "$ref" : "#/definitions/Label"
          }
        },
        "EntityTypes" : {
          "type" : "array",
          "uniqueItems" : false,
          "insertionOrder" : false,
          "minItems" : 1,
          "items" : {
            "$ref" : "#/definitions/EntityType"
          }
        },
        "Arn" : {
          "description" : "The ARN of the event type.",
          "type" : "string"
        },
        "CreatedTime" : {
          "description" : "The time when the event type was created.",
          "type" : "string"
        },
        "LastUpdatedTime" : {
          "description" : "The time when the event type was last updated.",
          "type" : "string"
        }
      },
      "additionalProperties" : false
    },
    "Model" : {
      "description" : "A model to associate with a detector.",
      "type" : "object",
      "properties" : {
        "Arn" : {
          "type" : "string"
        }
      },
      "additionalProperties" : false
    }
  },
  "properties" : {
    "DetectorId" : {
      "description" : "The ID of the detector",
      "type" : "string",
      "pattern" : "^[0-9a-z_-]+$",
      "minLength" : 1,
      "maxLength" : 64
    },
    "DetectorVersionStatus" : {
      "description" : "The desired detector version status for the detector",
      "type" : "string",
      "enum" : [ "DRAFT", "ACTIVE" ]
    },
    "DetectorVersionId" : {
      "description" : "The active version ID of the detector",
      "type" : "string"
    },
    "RuleExecutionMode" : {
      "type" : "string",
      "enum" : [ "FIRST_MATCHED", "ALL_MATCHED" ]
    },
    "Tags" : {
      "description" : "Tags associated with this detector.",
      "type" : "array",
      "uniqueItems" : false,
      "insertionOrder" : false,
      "maxItems" : 200,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "Description" : {
      "description" : "The description of the detector.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 128
    },
    "Rules" : {
      "type" : "array",
      "uniqueItems" : false,
      "insertionOrder" : false,
      "minItems" : 1,
      "items" : {
        "$ref" : "#/definitions/Rule"
      }
    },
    "EventType" : {
      "description" : "The event type to associate this detector with.",
      "$ref" : "#/definitions/EventType"
    },
    "Arn" : {
      "description" : "The ARN of the detector.",
      "type" : "string"
    },
    "CreatedTime" : {
      "description" : "The time when the detector was created.",
      "type" : "string"
    },
    "LastUpdatedTime" : {
      "description" : "The time when the detector was last updated.",
      "type" : "string"
    },
    "AssociatedModels" : {
      "description" : "The models to associate with this detector.",
      "type" : "array",
      "uniqueItems" : false,
      "insertionOrder" : false,
      "maxItems" : 10,
      "items" : {
        "$ref" : "#/definitions/Model"
      }
    }
  },
  "additionalProperties" : false,
  "required" : [ "DetectorId", "EventType", "Rules" ],
  "createOnlyProperties" : [ "/properties/DetectorId" ],
  "readOnlyProperties" : [ "/properties/Arn", "/properties/DetectorVersionId", "/properties/CreatedTime", "/properties/LastUpdatedTime", "/properties/Rules/*/RuleVersion", "/properties/Rules/*/Arn", "/properties/Rules/*/CreatedTime", "/properties/Rules/*/LastUpdatedTime", "/properties/Rules/*/Outcomes/*/Arn", "/properties/Rules/*/Outcomes/*/CreatedTime", "/properties/Rules/*/Outcomes/*/LastUpdatedTime", "/properties/EventType/Arn", "/properties/EventType/CreatedTime", "/properties/EventType/LastUpdatedTime", "/properties/EventType/EventVariables/*/Arn", "/properties/EventType/EventVariables/*/CreatedTime", "/properties/EventType/EventVariables/*/LastUpdatedTime", "/properties/EventType/Labels/*/Arn", "/properties/EventType/Labels/*/CreatedTime", "/properties/EventType/Labels/*/LastUpdatedTime", "/properties/EventType/EntityTypes/*/Arn", "/properties/EventType/EntityTypes/*/CreatedTime", "/properties/EventType/EntityTypes/*/LastUpdatedTime", "/properties/AssociatedModels/*/Arn" ],
  "primaryIdentifier" : [ "/properties/Arn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "frauddetector:PutDetector", "frauddetector:CreateDetectorVersion", "frauddetector:UpdateDetectorVersionStatus", "frauddetector:CreateRule", "frauddetector:CreateVariable", "frauddetector:PutLabel", "frauddetector:PutOutcome", "frauddetector:PutEntityType", "frauddetector:PutEventType", "frauddetector:DescribeDetector", "frauddetector:GetDetectors", "frauddetector:GetDetectorVersion", "frauddetector:GetRules", "frauddetector:GetVariables", "frauddetector:GetEventTypes", "frauddetector:GetExternalModels", "frauddetector:GetModelVersion", "frauddetector:GetLabels", "frauddetector:GetOutcomes", "frauddetector:GetEntityTypes", "frauddetector:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "frauddetector:GetDetectors", "frauddetector:GetDetectorVersion", "frauddetector:PutDetector", "frauddetector:UpdateDetectorVersion", "frauddetector:UpdateDetectorVersionStatus", "frauddetector:UpdateDetectorVersionMetadata", "frauddetector:UpdateRuleVersion", "frauddetector:UpdateRuleMetadata", "frauddetector:CreateRule", "frauddetector:CreateVariable", "frauddetector:UpdateVariable", "frauddetector:GetVariables", "frauddetector:PutLabel", "frauddetector:PutOutcome", "frauddetector:PutEntityType", "frauddetector:PutEventType", "frauddetector:GetRules", "frauddetector:GetEventTypes", "frauddetector:GetLabels", "frauddetector:GetOutcomes", "frauddetector:GetEntityTypes", "frauddetector:GetExternalModels", "frauddetector:GetModelVersion", "frauddetector:DeleteEventType", "frauddetector:DeleteVariable", "frauddetector:DeleteLabel", "frauddetector:DeleteEntityType", "frauddetector:ListTagsForResource", "frauddetector:TagResource", "frauddetector:UntagResource" ]
    },
    "delete" : {
      "permissions" : [ "frauddetector:GetDetectors", "frauddetector:GetDetectorVersion", "frauddetector:DescribeDetector", "frauddetector:GetRules", "frauddetector:GetVariables", "frauddetector:GetEventTypes", "frauddetector:GetLabels", "frauddetector:GetOutcomes", "frauddetector:GetEntityTypes", "frauddetector:DeleteDetector", "frauddetector:DeleteDetectorVersion", "frauddetector:DeleteRule", "frauddetector:DeleteEventType", "frauddetector:DeleteVariable", "frauddetector:DeleteLabel", "frauddetector:DeleteOutcome", "frauddetector:DeleteEntityType", "frauddetector:ListTagsForResource" ]
    },
    "read" : {
      "permissions" : [ "frauddetector:GetDetectors", "frauddetector:GetDetectorVersion", "frauddetector:DescribeDetector", "frauddetector:GetRules", "frauddetector:GetVariables", "frauddetector:GetEventTypes", "frauddetector:GetExternalModels", "frauddetector:GetModelVersion", "frauddetector:GetLabels", "frauddetector:GetOutcomes", "frauddetector:GetEntityTypes", "frauddetector:ListTagsForResource" ]
    },
    "list" : {
      "permissions" : [ "frauddetector:GetDetectors", "frauddetector:GetDetectorVersion", "frauddetector:DescribeDetector", "frauddetector:GetRules", "frauddetector:GetVariables", "frauddetector:GetEventTypes", "frauddetector:GetExternalModels", "frauddetector:GetModelVersion", "frauddetector:GetLabels", "frauddetector:GetOutcomes", "frauddetector:GetEntityTypes", "frauddetector:ListTagsForResource" ]
    }
  }
}