{
 "additionalProperties": false,
 "definitions": {
  "AdditionalAnalyses": {
   "enum": [
    "ALLOWED",
    "REQUIRED",
    "NOT_ALLOWED"
   ],
   "type": "string"
  },
  "AggregateColumn": {
   "additionalProperties": false,
   "properties": {
    "ColumnNames": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AnalysisRuleColumnName"
     },
     "minItems": 1,
     "type": "array"
    },
    "Function": {
     "$ref": "#/definitions/AggregateFunctionName"
    }
   },
   "required": [
    "ColumnNames",
    "Function"
   ],
   "type": "object"
  },
  "AggregateFunctionName": {
   "enum": [
    "SUM",
    "SUM_DISTINCT",
    "COUNT",
    "COUNT_DISTINCT",
    "AVG"
   ],
   "type": "string"
  },
  "AggregationConstraint": {
   "additionalProperties": false,
   "properties": {
    "ColumnName": {
     "$ref": "#/definitions/AnalysisRuleColumnName"
    },
    "Minimum": {
     "maximum": 100000,
     "minimum": 2,
     "type": "number"
    },
    "Type": {
     "$ref": "#/definitions/AggregationType"
    }
   },
   "required": [
    "ColumnName",
    "Minimum",
    "Type"
   ],
   "type": "object"
  },
  "AggregationType": {
   "enum": [
    "COUNT_DISTINCT"
   ],
   "type": "string"
  },
  "AllowedAnalyses": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/AllowedAnalysis"
   },
   "minItems": 0,
   "type": "array"
  },
  "AllowedAnalysis": {
   "maxLength": 200,
   "minLength": 0,
   "pattern": "(ANY_QUERY|ANY_JOB|arn:[\\w]{3}:cleanrooms:[\\w]{2}-[\\w]{4,9}-[\\d]:[\\d]{12}:membership/[\\d\\w-]+/analysistemplate/[\\d\\w-]+)",
   "type": "string"
  },
  "AllowedAnalysisProvider": {
   "maxLength": 12,
   "minLength": 12,
   "pattern": "\\d+",
   "type": "string"
  },
  "AllowedAnalysisProviders": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/AllowedAnalysisProvider"
   },
   "minItems": 0,
   "type": "array"
  },
  "AnalysisMethod": {
   "enum": [
    "DIRECT_QUERY",
    "DIRECT_JOB",
    "MULTIPLE"
   ],
   "type": "string"
  },
  "AnalysisRule": {
   "additionalProperties": false,
   "properties": {
    "Policy": {
     "$ref": "#/definitions/ConfiguredTableAnalysisRulePolicy"
    },
    "Type": {
     "$ref": "#/definitions/ConfiguredTableAnalysisRuleType"
    }
   },
   "required": [
    "Type",
    "Policy"
   ],
   "type": "object"
  },
  "AnalysisRuleAggregation": {
   "additionalProperties": false,
   "properties": {
    "AdditionalAnalyses": {
     "$ref": "#/definitions/AdditionalAnalyses"
    },
    "AggregateColumns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AggregateColumn"
     },
     "minItems": 1,
     "type": "array"
    },
    "AllowedJoinOperators": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/JoinOperator"
     },
     "maxItems": 2,
     "type": "array"
    },
    "DimensionColumns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AnalysisRuleColumnName"
     },
     "type": "array"
    },
    "JoinColumns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AnalysisRuleColumnName"
     },
     "type": "array"
    },
    "JoinRequired": {
     "$ref": "#/definitions/JoinRequiredOption"
    },
    "OutputConstraints": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AggregationConstraint"
     },
     "minItems": 1,
     "type": "array"
    },
    "ScalarFunctions": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/ScalarFunctions"
     },
     "type": "array"
    }
   },
   "required": [
    "AggregateColumns",
    "JoinColumns",
    "DimensionColumns",
    "ScalarFunctions",
    "OutputConstraints"
   ],
   "type": "object"
  },
  "AnalysisRuleColumnName": {
   "maxLength": 127,
   "minLength": 1,
   "pattern": "^[a-z0-9_](([a-z0-9_ ]+-)*([a-z0-9_ ]+))?$",
   "type": "string"
  },
  "AnalysisRuleCustom": {
   "additionalProperties": false,
   "properties": {
    "AdditionalAnalyses": {
     "$ref": "#/definitions/AdditionalAnalyses"
    },
    "AllowedAnalyses": {
     "$ref": "#/definitions/AllowedAnalyses"
    },
    "AllowedAnalysisProviders": {
     "$ref": "#/definitions/AllowedAnalysisProviders"
    },
    "DifferentialPrivacy": {
     "$ref": "#/definitions/DifferentialPrivacy"
    },
    "DisallowedOutputColumns": {
     "$ref": "#/definitions/DisallowedOutputColumns"
    }
   },
   "required": [
    "AllowedAnalyses"
   ],
   "type": "object"
  },
  "AnalysisRuleList": {
   "additionalProperties": false,
   "properties": {
    "AdditionalAnalyses": {
     "$ref": "#/definitions/AdditionalAnalyses"
    },
    "AllowedJoinOperators": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/JoinOperator"
     },
     "maxItems": 2,
     "type": "array"
    },
    "JoinColumns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AnalysisRuleColumnName"
     },
     "minItems": 1,
     "type": "array"
    },
    "ListColumns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/AnalysisRuleColumnName"
     },
     "type": "array"
    }
   },
   "required": [
    "JoinColumns",
    "ListColumns"
   ],
   "type": "object"
  },
  "AthenaTableReference": {
   "additionalProperties": false,
   "properties": {
    "CatalogName": {
     "maxLength": 64,
     "minLength": 1,
     "pattern": "^[a-zA-Z0-9_-]+$",
     "type": "string"
    },
    "DatabaseName": {
     "maxLength": 128,
     "type": "string"
    },
    "OutputLocation": {
     "maxLength": 1024,
     "minLength": 8,
     "type": "string"
    },
    "Region": {
     "$ref": "#/definitions/CommercialRegion"
    },
    "TableName": {
     "maxLength": 128,
     "type": "string"
    },
    "WorkGroup": {
     "maxLength": 128,
     "minLength": 1,
     "type": "string"
    }
   },
   "required": [
    "DatabaseName",
    "TableName",
    "WorkGroup"
   ],
   "type": "object"
  },
  "CommercialRegion": {
   "enum": [
    "us-west-1",
    "us-west-2",
    "us-east-1",
    "us-east-2",
    "af-south-1",
    "ap-east-1",
    "ap-south-2",
    "ap-southeast-1",
    "ap-southeast-2",
    "ap-southeast-5",
    "ap-southeast-4",
    "ap-southeast-7",
    "ap-south-1",
    "ap-northeast-3",
    "ap-northeast-1",
    "ap-northeast-2",
    "ca-central-1",
    "ca-west-1",
    "eu-south-1",
    "eu-west-3",
    "eu-south-2",
    "eu-central-2",
    "eu-central-1",
    "eu-north-1",
    "eu-west-1",
    "eu-west-2",
    "me-south-1",
    "me-central-1",
    "il-central-1",
    "sa-east-1",
    "mx-central-1",
    "ap-east-2"
   ],
   "type": "string"
  },
  "ConfiguredTableAnalysisRulePolicy": {
   "additionalProperties": false,
   "properties": {
    "V1": {
     "$ref": "#/definitions/ConfiguredTableAnalysisRulePolicyV1"
    }
   },
   "required": [
    "V1"
   ],
   "title": "V1",
   "type": "object"
  },
  "ConfiguredTableAnalysisRulePolicyV1": {
   "oneOf": [
    {
     "additionalProperties": false,
     "properties": {
      "List": {
       "$ref": "#/definitions/AnalysisRuleList"
      }
     },
     "required": [
      "List"
     ],
     "title": "List",
     "type": "object"
    },
    {
     "additionalProperties": false,
     "properties": {
      "Aggregation": {
       "$ref": "#/definitions/AnalysisRuleAggregation"
      }
     },
     "required": [
      "Aggregation"
     ],
     "title": "Aggregation",
     "type": "object"
    },
    {
     "additionalProperties": false,
     "properties": {
      "Custom": {
       "$ref": "#/definitions/AnalysisRuleCustom"
      }
     },
     "required": [
      "Custom"
     ],
     "title": "Custom",
     "type": "object"
    }
   ]
  },
  "ConfiguredTableAnalysisRuleType": {
   "enum": [
    "AGGREGATION",
    "LIST",
    "CUSTOM"
   ],
   "type": "string"
  },
  "DifferentialPrivacy": {
   "additionalProperties": false,
   "properties": {
    "Columns": {
     "insertionOrder": false,
     "items": {
      "$ref": "#/definitions/DifferentialPrivacyColumn"
     },
     "minItems": 1,
     "type": "array"
    }
   },
   "required": [
    "Columns"
   ],
   "type": "object"
  },
  "DifferentialPrivacyColumn": {
   "additionalProperties": false,
   "properties": {
    "Name": {
     "type": "string"
    }
   },
   "required": [
    "Name"
   ],
   "type": "object"
  },
  "DisallowedOutputColumns": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/AnalysisRuleColumnName"
   },
   "minItems": 0,
   "type": "array"
  },
  "GlueTableReference": {
   "additionalProperties": false,
   "properties": {
    "DatabaseName": {
     "maxLength": 128,
     "pattern": "^[a-zA-Z0-9_](([a-zA-Z0-9_ ]+-)*([a-zA-Z0-9_ ]+))?$",
     "type": "string"
    },
    "Region": {
     "$ref": "#/definitions/CommercialRegion"
    },
    "TableName": {
     "maxLength": 128,
     "pattern": "^[a-zA-Z0-9_](([a-zA-Z0-9_ ]+-)*([a-zA-Z0-9_ ]+))?$",
     "type": "string"
    }
   },
   "required": [
    "DatabaseName",
    "TableName"
   ],
   "type": "object"
  },
  "JoinOperator": {
   "enum": [
    "OR",
    "AND"
   ],
   "type": "string"
  },
  "JoinRequiredOption": {
   "enum": [
    "QUERY_RUNNER"
   ],
   "type": "string"
  },
  "ScalarFunctions": {
   "enum": [
    "TRUNC",
    "ABS",
    "CEILING",
    "FLOOR",
    "LN",
    "LOG",
    "ROUND",
    "SQRT",
    "CAST",
    "LOWER",
    "RTRIM",
    "UPPER",
    "COALESCE",
    "CONVERT",
    "CURRENT_DATE",
    "DATEADD",
    "EXTRACT",
    "GETDATE",
    "SUBSTRING",
    "TO_CHAR",
    "TO_DATE",
    "TO_NUMBER",
    "TO_TIMESTAMP",
    "TRIM"
   ],
   "type": "string"
  },
  "SelectedAnalysisMethod": {
   "enum": [
    "DIRECT_QUERY",
    "DIRECT_JOB"
   ],
   "type": "string"
  },
  "SelectedAnalysisMethods": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/SelectedAnalysisMethod"
   },
   "type": "array"
  },
  "SnowflakeTableReference": {
   "additionalProperties": false,
   "properties": {
    "AccountIdentifier": {
     "maxLength": 256,
     "minLength": 3,
     "type": "string"
    },
    "DatabaseName": {
     "maxLength": 256,
     "minLength": 1,
     "type": "string"
    },
    "SchemaName": {
     "maxLength": 256,
     "minLength": 1,
     "type": "string"
    },
    "SecretArn": {
     "maxLength": 256,
     "type": "string"
    },
    "TableName": {
     "maxLength": 256,
     "minLength": 1,
     "type": "string"
    },
    "TableSchema": {
     "$ref": "#/definitions/SnowflakeTableSchema"
    }
   },
   "required": [
    "AccountIdentifier",
    "DatabaseName",
    "SchemaName",
    "SecretArn",
    "TableName",
    "TableSchema"
   ],
   "type": "object"
  },
  "SnowflakeTableSchema": {
   "oneOf": [
    {
     "additionalProperties": false,
     "properties": {
      "V1": {
       "insertionOrder": false,
       "items": {
        "$ref": "#/definitions/SnowflakeTableSchemaV1"
       },
       "maxItems": 250,
       "minItems": 1,
       "type": "array"
      }
     },
     "required": [
      "V1"
     ],
     "title": "V1",
     "type": "object"
    }
   ]
  },
  "SnowflakeTableSchemaV1": {
   "additionalProperties": false,
   "properties": {
    "ColumnName": {
     "maxLength": 128,
     "type": "string"
    },
    "ColumnType": {
     "maxLength": 255,
     "type": "string"
    }
   },
   "required": [
    "ColumnName",
    "ColumnType"
   ],
   "type": "object"
  },
  "TableReference": {
   "oneOf": [
    {
     "additionalProperties": false,
     "properties": {
      "Glue": {
       "$ref": "#/definitions/GlueTableReference"
      }
     },
     "required": [
      "Glue"
     ],
     "title": "Glue",
     "type": "object"
    },
    {
     "additionalProperties": false,
     "properties": {
      "Snowflake": {
       "$ref": "#/definitions/SnowflakeTableReference"
      }
     },
     "required": [
      "Snowflake"
     ],
     "title": "Snowflake",
     "type": "object"
    },
    {
     "additionalProperties": false,
     "properties": {
      "Athena": {
       "$ref": "#/definitions/AthenaTableReference"
      }
     },
     "required": [
      "Athena"
     ],
     "title": "Athena",
     "type": "object"
    }
   ]
  },
  "Tag": {
   "additionalProperties": false,
   "properties": {
    "Key": {
     "maxLength": 128,
     "minLength": 1,
     "type": "string"
    },
    "Value": {
     "maxLength": 256,
     "minLength": 1,
     "type": "string"
    }
   },
   "required": [
    "Value",
    "Key"
   ],
   "type": "object"
  }
 },
 "primaryIdentifier": [
  "/properties/ConfiguredTableIdentifier"
 ],
 "properties": {
  "AllowedColumns": {
   "insertionOrder": false,
   "items": {
    "maxLength": 128,
    "pattern": "^[a-z0-9_](([a-z0-9_ ]+-)*([a-z0-9_ ]+))?$",
    "type": "string"
   },
   "maxItems": 100,
   "minItems": 1,
   "type": "array"
  },
  "AnalysisMethod": {
   "$ref": "#/definitions/AnalysisMethod"
  },
  "AnalysisRules": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/AnalysisRule"
   },
   "maxItems": 1,
   "minItems": 1,
   "type": "array"
  },
  "Arn": {
   "maxLength": 100,
   "type": "string"
  },
  "ConfiguredTableIdentifier": {
   "maxLength": 36,
   "minLength": 36,
   "pattern": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
   "type": "string"
  },
  "Description": {
   "maxLength": 255,
   "pattern": "^[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDBFF-\\uDC00\\uDFFF\\t\\r\\n]*$",
   "type": "string"
  },
  "Name": {
   "maxLength": 100,
   "minLength": 1,
   "pattern": "^(?!\\s*$)[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDBFF-\\uDC00\\uDFFF\\t]*$",
   "type": "string"
  },
  "SelectedAnalysisMethods": {
   "$ref": "#/definitions/SelectedAnalysisMethods"
  },
  "TableReference": {
   "$ref": "#/definitions/TableReference"
  },
  "Tags": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/Tag"
   },
   "type": "array",
   "uniqueItems": true
  }
 },
 "readOnlyProperties": [
  "/properties/Arn",
  "/properties/ConfiguredTableIdentifier"
 ],
 "required": [
  "AllowedColumns",
  "AnalysisMethod",
  "Name",
  "TableReference"
 ],
 "tagging": {
  "cloudFormationSystemTags": true,
  "tagOnCreate": true,
  "tagProperty": "/properties/Tags",
  "tagUpdatable": true,
  "taggable": true
 },
 "typeName": "AWS::CleanRooms::ConfiguredTable"
}
