{
  "typeName" : "AWS::CleanRooms::ConfiguredTable",
  "description" : "Represents a table that can be associated with collaborations",
  "definitions" : {
    "AnalysisRuleColumnName" : {
      "type" : "string",
      "maxLength" : 127,
      "minLength" : 1,
      "pattern" : "^[a-z0-9_](([a-z0-9_ ]+-)*([a-z0-9_ ]+))?$"
    },
    "AggregateColumn" : {
      "type" : "object",
      "properties" : {
        "ColumnNames" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AnalysisRuleColumnName"
          },
          "minItems" : 1
        },
        "Function" : {
          "$ref" : "#/definitions/AggregateFunctionName"
        }
      },
      "required" : [ "ColumnNames", "Function" ],
      "additionalProperties" : false
    },
    "AggregateFunctionName" : {
      "type" : "string",
      "enum" : [ "SUM", "SUM_DISTINCT", "COUNT", "COUNT_DISTINCT", "AVG" ]
    },
    "AggregationConstraint" : {
      "type" : "object",
      "properties" : {
        "ColumnName" : {
          "$ref" : "#/definitions/AnalysisRuleColumnName"
        },
        "Minimum" : {
          "type" : "number",
          "minimum" : 2,
          "maximum" : 100000
        },
        "Type" : {
          "$ref" : "#/definitions/AggregationType"
        }
      },
      "required" : [ "ColumnName", "Minimum", "Type" ],
      "additionalProperties" : false
    },
    "AggregationType" : {
      "type" : "string",
      "enum" : [ "COUNT_DISTINCT" ]
    },
    "JoinOperator" : {
      "type" : "string",
      "enum" : [ "OR", "AND" ]
    },
    "AnalysisMethod" : {
      "type" : "string",
      "enum" : [ "DIRECT_QUERY", "DIRECT_JOB", "MULTIPLE" ]
    },
    "SelectedAnalysisMethod" : {
      "type" : "string",
      "enum" : [ "DIRECT_QUERY", "DIRECT_JOB" ]
    },
    "SelectedAnalysisMethods" : {
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/SelectedAnalysisMethod"
      }
    },
    "JoinRequiredOption" : {
      "type" : "string",
      "enum" : [ "QUERY_RUNNER" ]
    },
    "ScalarFunctions" : {
      "type" : "string",
      "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" ]
    },
    "AnalysisRuleAggregation" : {
      "type" : "object",
      "properties" : {
        "AggregateColumns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AggregateColumn"
          },
          "minItems" : 1
        },
        "JoinColumns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AnalysisRuleColumnName"
          }
        },
        "AllowedJoinOperators" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/JoinOperator"
          },
          "maxItems" : 2
        },
        "JoinRequired" : {
          "$ref" : "#/definitions/JoinRequiredOption"
        },
        "DimensionColumns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AnalysisRuleColumnName"
          }
        },
        "ScalarFunctions" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/ScalarFunctions"
          }
        },
        "OutputConstraints" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AggregationConstraint"
          },
          "minItems" : 1
        },
        "AdditionalAnalyses" : {
          "$ref" : "#/definitions/AdditionalAnalyses"
        }
      },
      "required" : [ "AggregateColumns", "JoinColumns", "DimensionColumns", "ScalarFunctions", "OutputConstraints" ],
      "additionalProperties" : false
    },
    "AnalysisRuleList" : {
      "type" : "object",
      "properties" : {
        "JoinColumns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AnalysisRuleColumnName"
          },
          "minItems" : 1
        },
        "AllowedJoinOperators" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/JoinOperator"
          },
          "maxItems" : 2
        },
        "ListColumns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/AnalysisRuleColumnName"
          }
        },
        "AdditionalAnalyses" : {
          "$ref" : "#/definitions/AdditionalAnalyses"
        }
      },
      "required" : [ "JoinColumns", "ListColumns" ],
      "additionalProperties" : false
    },
    "AllowedAnalysis" : {
      "type" : "string",
      "minLength" : 0,
      "maxLength" : 200,
      "pattern" : "(ANY_QUERY|ANY_JOB|arn:[\\w]{3}:cleanrooms:[\\w]{2}-[\\w]{4,9}-[\\d]:[\\d]{12}:membership/[\\d\\w-]+/analysistemplate/[\\d\\w-]+)"
    },
    "AllowedAnalyses" : {
      "type" : "array",
      "insertionOrder" : false,
      "minItems" : 0,
      "items" : {
        "$ref" : "#/definitions/AllowedAnalysis"
      }
    },
    "AllowedAnalysisProvider" : {
      "type" : "string",
      "minLength" : 12,
      "maxLength" : 12,
      "pattern" : "\\d+"
    },
    "AllowedAnalysisProviders" : {
      "type" : "array",
      "insertionOrder" : false,
      "minItems" : 0,
      "items" : {
        "$ref" : "#/definitions/AllowedAnalysisProvider"
      }
    },
    "DisallowedOutputColumns" : {
      "type" : "array",
      "insertionOrder" : false,
      "minItems" : 0,
      "items" : {
        "$ref" : "#/definitions/AnalysisRuleColumnName"
      }
    },
    "AdditionalAnalyses" : {
      "type" : "string",
      "enum" : [ "ALLOWED", "REQUIRED", "NOT_ALLOWED" ]
    },
    "DifferentialPrivacyColumn" : {
      "type" : "object",
      "properties" : {
        "Name" : {
          "type" : "string"
        }
      },
      "required" : [ "Name" ],
      "additionalProperties" : false
    },
    "DifferentialPrivacy" : {
      "type" : "object",
      "properties" : {
        "Columns" : {
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/DifferentialPrivacyColumn"
          },
          "minItems" : 1
        }
      },
      "required" : [ "Columns" ],
      "additionalProperties" : false
    },
    "AnalysisRuleCustom" : {
      "type" : "object",
      "properties" : {
        "AllowedAnalyses" : {
          "$ref" : "#/definitions/AllowedAnalyses"
        },
        "AllowedAnalysisProviders" : {
          "$ref" : "#/definitions/AllowedAnalysisProviders"
        },
        "DifferentialPrivacy" : {
          "$ref" : "#/definitions/DifferentialPrivacy"
        },
        "DisallowedOutputColumns" : {
          "$ref" : "#/definitions/DisallowedOutputColumns"
        },
        "AdditionalAnalyses" : {
          "$ref" : "#/definitions/AdditionalAnalyses"
        }
      },
      "required" : [ "AllowedAnalyses" ],
      "additionalProperties" : false
    },
    "ConfiguredTableAnalysisRulePolicy" : {
      "type" : "object",
      "title" : "V1",
      "properties" : {
        "V1" : {
          "$ref" : "#/definitions/ConfiguredTableAnalysisRulePolicyV1"
        }
      },
      "required" : [ "V1" ],
      "additionalProperties" : false
    },
    "ConfiguredTableAnalysisRulePolicyV1" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "List",
        "properties" : {
          "List" : {
            "$ref" : "#/definitions/AnalysisRuleList"
          }
        },
        "required" : [ "List" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Aggregation",
        "properties" : {
          "Aggregation" : {
            "$ref" : "#/definitions/AnalysisRuleAggregation"
          }
        },
        "required" : [ "Aggregation" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Custom",
        "properties" : {
          "Custom" : {
            "$ref" : "#/definitions/AnalysisRuleCustom"
          }
        },
        "required" : [ "Custom" ],
        "additionalProperties" : false
      } ]
    },
    "ConfiguredTableAnalysisRuleType" : {
      "type" : "string",
      "enum" : [ "AGGREGATION", "LIST", "CUSTOM" ]
    },
    "CommercialRegion" : {
      "type" : "string",
      "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" ]
    },
    "GlueTableReference" : {
      "type" : "object",
      "properties" : {
        "TableName" : {
          "type" : "string",
          "maxLength" : 128,
          "pattern" : "^[a-zA-Z0-9_](([a-zA-Z0-9_ ]+-)*([a-zA-Z0-9_ ]+))?$"
        },
        "DatabaseName" : {
          "type" : "string",
          "maxLength" : 128,
          "pattern" : "^[a-zA-Z0-9_](([a-zA-Z0-9_ ]+-)*([a-zA-Z0-9_ ]+))?$"
        },
        "Region" : {
          "$ref" : "#/definitions/CommercialRegion"
        }
      },
      "required" : [ "DatabaseName", "TableName" ],
      "additionalProperties" : false
    },
    "SnowflakeTableReference" : {
      "type" : "object",
      "properties" : {
        "SecretArn" : {
          "type" : "string",
          "maxLength" : 256
        },
        "AccountIdentifier" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 3
        },
        "DatabaseName" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 1
        },
        "TableName" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 1
        },
        "SchemaName" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 1
        },
        "TableSchema" : {
          "$ref" : "#/definitions/SnowflakeTableSchema"
        }
      },
      "required" : [ "AccountIdentifier", "DatabaseName", "SchemaName", "SecretArn", "TableName", "TableSchema" ],
      "additionalProperties" : false
    },
    "SnowflakeTableSchema" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "V1",
        "properties" : {
          "V1" : {
            "type" : "array",
            "insertionOrder" : false,
            "items" : {
              "$ref" : "#/definitions/SnowflakeTableSchemaV1"
            },
            "maxItems" : 250,
            "minItems" : 1
          }
        },
        "required" : [ "V1" ],
        "additionalProperties" : false
      } ]
    },
    "SnowflakeTableSchemaV1" : {
      "type" : "object",
      "properties" : {
        "ColumnName" : {
          "type" : "string",
          "maxLength" : 128
        },
        "ColumnType" : {
          "type" : "string",
          "maxLength" : 255
        }
      },
      "required" : [ "ColumnName", "ColumnType" ],
      "additionalProperties" : false
    },
    "AthenaTableReference" : {
      "type" : "object",
      "properties" : {
        "WorkGroup" : {
          "type" : "string",
          "maxLength" : 128,
          "minLength" : 1
        },
        "OutputLocation" : {
          "type" : "string",
          "maxLength" : 1024,
          "minLength" : 8
        },
        "DatabaseName" : {
          "type" : "string",
          "maxLength" : 128
        },
        "TableName" : {
          "type" : "string",
          "maxLength" : 128
        },
        "Region" : {
          "$ref" : "#/definitions/CommercialRegion"
        },
        "CatalogName" : {
          "type" : "string",
          "maxLength" : 64,
          "minLength" : 1,
          "pattern" : "^[a-zA-Z0-9_-]+$"
        }
      },
      "required" : [ "DatabaseName", "TableName", "WorkGroup" ],
      "additionalProperties" : false
    },
    "AnalysisRule" : {
      "type" : "object",
      "properties" : {
        "Type" : {
          "$ref" : "#/definitions/ConfiguredTableAnalysisRuleType"
        },
        "Policy" : {
          "$ref" : "#/definitions/ConfiguredTableAnalysisRulePolicy"
        }
      },
      "required" : [ "Type", "Policy" ],
      "additionalProperties" : false
    },
    "TableReference" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "Glue",
        "properties" : {
          "Glue" : {
            "$ref" : "#/definitions/GlueTableReference"
          }
        },
        "required" : [ "Glue" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Snowflake",
        "properties" : {
          "Snowflake" : {
            "$ref" : "#/definitions/SnowflakeTableReference"
          }
        },
        "required" : [ "Snowflake" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Athena",
        "properties" : {
          "Athena" : {
            "$ref" : "#/definitions/AthenaTableReference"
          }
        },
        "required" : [ "Athena" ],
        "additionalProperties" : false
      } ]
    },
    "Tag" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Key" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        }
      },
      "required" : [ "Value", "Key" ]
    }
  },
  "properties" : {
    "Arn" : {
      "type" : "string",
      "maxLength" : 100
    },
    "Tags" : {
      "description" : "An arbitrary set of tags (key-value pairs) for this cleanrooms collaboration.",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      },
      "uniqueItems" : true,
      "type" : "array"
    },
    "AllowedColumns" : {
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "type" : "string",
        "maxLength" : 128,
        "pattern" : "^[a-z0-9_](([a-z0-9_ ]+-)*([a-z0-9_ ]+))?$"
      },
      "maxItems" : 100,
      "minItems" : 1
    },
    "AnalysisMethod" : {
      "$ref" : "#/definitions/AnalysisMethod"
    },
    "SelectedAnalysisMethods" : {
      "$ref" : "#/definitions/SelectedAnalysisMethods"
    },
    "ConfiguredTableIdentifier" : {
      "type" : "string",
      "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}"
    },
    "Description" : {
      "type" : "string",
      "maxLength" : 255,
      "pattern" : "^[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDBFF-\\uDC00\\uDFFF\\t\\r\\n]*$"
    },
    "Name" : {
      "type" : "string",
      "maxLength" : 100,
      "minLength" : 1,
      "pattern" : "^(?!\\s*$)[\\u0020-\\uD7FF\\uE000-\\uFFFD\\uD800\\uDBFF-\\uDC00\\uDFFF\\t]*$"
    },
    "AnalysisRules" : {
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/AnalysisRule"
      },
      "maxItems" : 1,
      "minItems" : 1
    },
    "TableReference" : {
      "$ref" : "#/definitions/TableReference"
    }
  },
  "required" : [ "AllowedColumns", "AnalysisMethod", "Name", "TableReference" ],
  "readOnlyProperties" : [ "/properties/Arn", "/properties/ConfiguredTableIdentifier" ],
  "primaryIdentifier" : [ "/properties/ConfiguredTableIdentifier" ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "cleanrooms:ListTagsForResource", "cleanrooms:UntagResource", "cleanrooms:TagResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "cleanrooms:CreateConfiguredTable", "cleanrooms:DeleteConfiguredTable", "cleanrooms:DeleteConfiguredTableAnalysisRule", "cleanrooms:CreateConfiguredTableAnalysisRule", "cleanrooms:GetConfiguredTable", "cleanrooms:GetConfiguredTableAnalysisRule", "glue:GetDatabase", "glue:GetDatabases", "glue:GetTable", "glue:GetTables", "glue:GetPartition", "glue:GetPartitions", "glue:BatchGetPartition", "glue:GetSchemaVersion", "cleanrooms:ListTagsForResource", "cleanrooms:TagResource", "cleanrooms:ListConfiguredTables", "athena:GetTableMetadata" ]
    },
    "read" : {
      "permissions" : [ "cleanrooms:GetConfiguredTable", "cleanrooms:GetConfiguredTableAnalysisRule", "cleanrooms:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "cleanrooms:UpdateConfiguredTable", "cleanrooms:UpdateConfiguredTableReference", "cleanrooms:UpdateConfiguredTableAllowedColumns", "cleanrooms:GetConfiguredTable", "cleanrooms:CreateConfiguredTableAnalysisRule", "cleanrooms:UpdateConfiguredTableAnalysisRule", "cleanrooms:GetConfiguredTableAnalysisRule", "cleanrooms:DeleteConfiguredTableAnalysisRule", "cleanrooms:ListTagsForResource", "cleanrooms:TagResource", "cleanrooms:UntagResource", "glue:GetDatabase", "glue:GetDatabases", "glue:GetTable", "glue:GetTables", "glue:GetPartition", "glue:GetPartitions", "glue:BatchGetPartition", "glue:GetSchemaVersion" ]
    },
    "delete" : {
      "permissions" : [ "cleanrooms:DeleteConfiguredTable", "cleanrooms:GetConfiguredTable", "cleanrooms:ListConfiguredTables", "cleanrooms:GetConfiguredTableAnalysisRule", "cleanrooms:DeleteConfiguredTableAnalysisRule", "cleanrooms:ListTagsForResource", "cleanrooms:UntagResource", "glue:GetDatabase", "glue:GetDatabases", "glue:GetTable", "glue:GetTables", "glue:GetPartition", "glue:GetPartitions", "glue:BatchGetPartition", "glue:GetSchemaVersion" ]
    },
    "list" : {
      "permissions" : [ "cleanrooms:ListConfiguredTables" ]
    }
  },
  "additionalProperties" : false
}