{
  "typeName" : "AWS::IoT::TopicRule",
  "description" : "Resource Type definition for AWS::IoT::TopicRule",
  "additionalProperties" : false,
  "properties" : {
    "Id" : {
      "type" : "string"
    },
    "Arn" : {
      "type" : "string"
    },
    "RuleName" : {
      "type" : "string"
    },
    "TopicRulePayload" : {
      "$ref" : "#/definitions/TopicRulePayload"
    }
  },
  "definitions" : {
    "Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "S3" : {
          "$ref" : "#/definitions/S3Action"
        },
        "CloudwatchAlarm" : {
          "$ref" : "#/definitions/CloudwatchAlarmAction"
        },
        "IotEvents" : {
          "$ref" : "#/definitions/IotEventsAction"
        },
        "Firehose" : {
          "$ref" : "#/definitions/FirehoseAction"
        },
        "Republish" : {
          "$ref" : "#/definitions/RepublishAction"
        },
        "StepFunctions" : {
          "$ref" : "#/definitions/StepFunctionsAction"
        },
        "DynamoDB" : {
          "$ref" : "#/definitions/DynamoDBAction"
        },
        "Http" : {
          "$ref" : "#/definitions/HttpAction"
        },
        "DynamoDBv2" : {
          "$ref" : "#/definitions/DynamoDBv2Action"
        },
        "CloudwatchMetric" : {
          "$ref" : "#/definitions/CloudwatchMetricAction"
        },
        "IotSiteWise" : {
          "$ref" : "#/definitions/IotSiteWiseAction"
        },
        "Elasticsearch" : {
          "$ref" : "#/definitions/ElasticsearchAction"
        },
        "Sqs" : {
          "$ref" : "#/definitions/SqsAction"
        },
        "Kinesis" : {
          "$ref" : "#/definitions/KinesisAction"
        },
        "IotAnalytics" : {
          "$ref" : "#/definitions/IotAnalyticsAction"
        },
        "Sns" : {
          "$ref" : "#/definitions/SnsAction"
        },
        "Lambda" : {
          "$ref" : "#/definitions/LambdaAction"
        }
      }
    },
    "ElasticsearchAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Type" : {
          "type" : "string"
        },
        "Index" : {
          "type" : "string"
        },
        "Id" : {
          "type" : "string"
        },
        "Endpoint" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "Type", "Endpoint", "Index", "Id", "RoleArn" ]
    },
    "KinesisAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PartitionKey" : {
          "type" : "string"
        },
        "StreamName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "StreamName", "RoleArn" ]
    },
    "FirehoseAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DeliveryStreamName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "Separator" : {
          "type" : "string"
        }
      },
      "required" : [ "DeliveryStreamName", "RoleArn" ]
    },
    "AssetPropertyTimestamp" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TimeInSeconds" : {
          "type" : "string"
        },
        "OffsetInNanos" : {
          "type" : "string"
        }
      },
      "required" : [ "TimeInSeconds" ]
    },
    "CloudwatchMetricAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "MetricName" : {
          "type" : "string"
        },
        "MetricValue" : {
          "type" : "string"
        },
        "MetricNamespace" : {
          "type" : "string"
        },
        "MetricUnit" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "MetricTimestamp" : {
          "type" : "string"
        }
      },
      "required" : [ "MetricName", "MetricValue", "MetricNamespace", "MetricUnit", "RoleArn" ]
    },
    "AssetPropertyVariant" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "StringValue" : {
          "type" : "string"
        },
        "DoubleValue" : {
          "type" : "string"
        },
        "BooleanValue" : {
          "type" : "string"
        },
        "IntegerValue" : {
          "type" : "string"
        }
      }
    },
    "DynamoDBAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TableName" : {
          "type" : "string"
        },
        "PayloadField" : {
          "type" : "string"
        },
        "RangeKeyField" : {
          "type" : "string"
        },
        "HashKeyField" : {
          "type" : "string"
        },
        "RangeKeyValue" : {
          "type" : "string"
        },
        "RangeKeyType" : {
          "type" : "string"
        },
        "HashKeyType" : {
          "type" : "string"
        },
        "HashKeyValue" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "TableName", "HashKeyField", "HashKeyValue", "RoleArn" ]
    },
    "RepublishAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Qos" : {
          "type" : "integer"
        },
        "Topic" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "Topic", "RoleArn" ]
    },
    "SnsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TargetArn" : {
          "type" : "string"
        },
        "MessageFormat" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "TargetArn", "RoleArn" ]
    },
    "StepFunctionsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ExecutionNamePrefix" : {
          "type" : "string"
        },
        "StateMachineName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "StateMachineName", "RoleArn" ]
    },
    "SqsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "UseBase64" : {
          "type" : "boolean"
        },
        "QueueUrl" : {
          "type" : "string"
        }
      },
      "required" : [ "RoleArn", "QueueUrl" ]
    },
    "SigV4Authorization" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ServiceName" : {
          "type" : "string"
        },
        "SigningRegion" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "ServiceName", "SigningRegion", "RoleArn" ]
    },
    "LambdaAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "FunctionArn" : {
          "type" : "string"
        }
      }
    },
    "PutAssetPropertyValueEntry" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PropertyAlias" : {
          "type" : "string"
        },
        "PropertyValues" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/AssetPropertyValue"
          }
        },
        "AssetId" : {
          "type" : "string"
        },
        "EntryId" : {
          "type" : "string"
        },
        "PropertyId" : {
          "type" : "string"
        }
      },
      "required" : [ "PropertyValues" ]
    },
    "PutItemInput" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TableName" : {
          "type" : "string"
        }
      },
      "required" : [ "TableName" ]
    },
    "S3Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "BucketName" : {
          "type" : "string"
        },
        "Key" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "BucketName", "Key", "RoleArn" ]
    },
    "AssetPropertyValue" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Value" : {
          "$ref" : "#/definitions/AssetPropertyVariant"
        },
        "Timestamp" : {
          "$ref" : "#/definitions/AssetPropertyTimestamp"
        },
        "Quality" : {
          "type" : "string"
        }
      },
      "required" : [ "Value", "Timestamp" ]
    },
    "DynamoDBv2Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PutItem" : {
          "$ref" : "#/definitions/PutItemInput"
        },
        "RoleArn" : {
          "type" : "string"
        }
      }
    },
    "IotEventsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "InputName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "MessageId" : {
          "type" : "string"
        }
      },
      "required" : [ "InputName", "RoleArn" ]
    },
    "HttpAuthorization" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Sigv4" : {
          "$ref" : "#/definitions/SigV4Authorization"
        }
      }
    },
    "TopicRulePayload" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RuleDisabled" : {
          "type" : "boolean"
        },
        "ErrorAction" : {
          "$ref" : "#/definitions/Action"
        },
        "Description" : {
          "type" : "string"
        },
        "AwsIotSqlVersion" : {
          "type" : "string"
        },
        "Actions" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/Action"
          }
        },
        "Sql" : {
          "type" : "string"
        }
      },
      "required" : [ "RuleDisabled", "Actions", "Sql" ]
    },
    "CloudwatchAlarmAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "StateValue" : {
          "type" : "string"
        },
        "AlarmName" : {
          "type" : "string"
        },
        "StateReason" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "AlarmName", "StateReason", "StateValue", "RoleArn" ]
    },
    "IotAnalyticsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "ChannelName" : {
          "type" : "string"
        }
      },
      "required" : [ "ChannelName", "RoleArn" ]
    },
    "HttpActionHeader" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Value" : {
          "type" : "string"
        },
        "Key" : {
          "type" : "string"
        }
      },
      "required" : [ "Value", "Key" ]
    },
    "IotSiteWiseAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "PutAssetPropertyValueEntries" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/PutAssetPropertyValueEntry"
          }
        }
      },
      "required" : [ "PutAssetPropertyValueEntries", "RoleArn" ]
    },
    "HttpAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ConfirmationUrl" : {
          "type" : "string"
        },
        "Headers" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/HttpActionHeader"
          }
        },
        "Url" : {
          "type" : "string"
        },
        "Auth" : {
          "$ref" : "#/definitions/HttpAuthorization"
        }
      },
      "required" : [ "Url" ]
    }
  },
  "required" : [ "TopicRulePayload" ],
  "createOnlyProperties" : [ "/properties/RuleName" ],
  "primaryIdentifier" : [ "/properties/Id" ],
  "readOnlyProperties" : [ "/properties/Id", "/properties/Arn" ]
}