Class: AWSCDK::IoTEvents::CfnDetectorModel::DynamoDBProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
io_t_events/cfn_detector_model.rb

Overview

Defines an action to write to the Amazon DynamoDB table that you created.

The standard action payload contains all the information about the detector model instance and the event that triggered the action. You can customize the payload . One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify.

You must use expressions for all parameters in DynamoDBAction . The expressions accept literals, operators, functions, references, and substitution templates.

Examples - For literal values, the expressions must contain single quotes. For example, the value for the hash_key_type parameter can be 'STRING' .

  • For references, you must specify either variables or input values. For example, the value for the hash_key_field parameter can be $input.GreenhouseInput.name .
  • For a substitution template, you must use ${} , and the template must be in single quotes. A substitution template can also contain a combination of literals, operators, functions, references, and substitution templates.

In the following example, the value for the hash_key_value parameter uses a substitution template.

'${$input.GreenhouseInput.temperature * 6 / 5 + 32} in Fahrenheit'

  • For a string concatenation, you must use + . A string concatenation can also contain a combination of literals, operators, functions, references, and substitution templates.

In the following example, the value for the table_name parameter uses a string concatenation.

'GreenhouseTemperatureTable ' + $input.GreenhouseInput.date

For more information, see Expressions in the AWS IoT Events Developer Guide .

If the defined payload type is a string, DynamoDBAction writes non-JSON data to the DynamoDB table as binary data. The DynamoDB console displays the data as Base64-encoded text. The value for the payload_field parameter is <payload-field>_raw .

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_key_field:, hash_key_value:, table_name:, hash_key_type: nil, operation: nil, payload: nil, payload_field: nil, range_key_field: nil, range_key_type: nil, range_key_value: nil) ⇒ DynamoDBProperty

Returns a new instance of DynamoDBProperty.

Parameters:

  • hash_key_field (String)

    The name of the hash key (also called the partition key).

  • hash_key_value (String)

    The value of the hash key (also called the partition key).

  • table_name (String)

    The name of the DynamoDB table.

  • hash_key_type (String, nil) (defaults to: nil)

    The data type for the hash key (also called the partition key). You can specify the following values:.

  • operation (String, nil) (defaults to: nil)

    The type of operation to perform. You can specify the following values:.

  • payload (AWSCDK::IResolvable, AWSCDK::IoTEvents::CfnDetectorModel::PayloadProperty, nil) (defaults to: nil)

    Information needed to configure the payload.

  • payload_field (String, nil) (defaults to: nil)

    The name of the DynamoDB column that receives the action payload.

  • range_key_field (String, nil) (defaults to: nil)

    The name of the range key (also called the sort key).

  • range_key_type (String, nil) (defaults to: nil)

    The data type for the range key (also called the sort key), You can specify the following values:.

  • range_key_value (String, nil) (defaults to: nil)

    The value of the range key (also called the sort key).



1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'io_t_events/cfn_detector_model.rb', line 1089

def initialize(hash_key_field:, hash_key_value:, table_name:, hash_key_type: nil, operation: nil, payload: nil, payload_field: nil, range_key_field: nil, range_key_type: nil, range_key_value: nil)
  @hash_key_field = hash_key_field
  Jsii::Type.check_type(@hash_key_field, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "hashKeyField")
  @hash_key_value = hash_key_value
  Jsii::Type.check_type(@hash_key_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "hashKeyValue")
  @table_name = table_name
  Jsii::Type.check_type(@table_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "tableName")
  @hash_key_type = hash_key_type
  Jsii::Type.check_type(@hash_key_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "hashKeyType") unless @hash_key_type.nil?
  @operation = operation
  Jsii::Type.check_type(@operation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "operation") unless @operation.nil?
  @payload = payload.is_a?(Hash) ? ::AWSCDK::IoTEvents::CfnDetectorModel::PayloadProperty.new(**payload.transform_keys(&:to_sym)) : payload
  Jsii::Type.check_type(@payload, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pb3RldmVudHMuQ2ZuRGV0ZWN0b3JNb2RlbC5QYXlsb2FkUHJvcGVydHkifV19fQ==")), "payload") unless @payload.nil?
  @payload_field = payload_field
  Jsii::Type.check_type(@payload_field, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "payloadField") unless @payload_field.nil?
  @range_key_field = range_key_field
  Jsii::Type.check_type(@range_key_field, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "rangeKeyField") unless @range_key_field.nil?
  @range_key_type = range_key_type
  Jsii::Type.check_type(@range_key_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "rangeKeyType") unless @range_key_type.nil?
  @range_key_value = range_key_value
  Jsii::Type.check_type(@range_key_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "rangeKeyValue") unless @range_key_value.nil?
end

Instance Attribute Details

#hash_key_fieldString (readonly)

The name of the hash key (also called the partition key).

The hash_key_field value must match the partition key of the target DynamoDB table.



1118
1119
1120
# File 'io_t_events/cfn_detector_model.rb', line 1118

def hash_key_field
  @hash_key_field
end

#hash_key_typeString? (readonly)

The data type for the hash key (also called the partition key). You can specify the following values:.

  • 'STRING' - The hash key is a string.
  • 'NUMBER' - The hash key is a number.

If you don't specify hash_key_type , the default value is 'STRING' .



1140
1141
1142
# File 'io_t_events/cfn_detector_model.rb', line 1140

def hash_key_type
  @hash_key_type
end

#hash_key_valueString (readonly)

The value of the hash key (also called the partition key).



1123
1124
1125
# File 'io_t_events/cfn_detector_model.rb', line 1123

def hash_key_value
  @hash_key_value
end

#operationString? (readonly)

The type of operation to perform. You can specify the following values:.

  • 'INSERT' - Insert data as a new item into the DynamoDB table. This item uses the specified hash key as a partition key. If you specified a range key, the item uses the range key as a sort key.
  • 'UPDATE' - Update an existing item of the DynamoDB table with new data. This item's partition key must match the specified hash key. If you specified a range key, the range key must match the item's sort key.
  • 'DELETE' - Delete an existing item of the DynamoDB table. This item's partition key must match the specified hash key. If you specified a range key, the range key must match the item's sort key.

If you don't specify this parameter, AWS IoT Events triggers the 'INSERT' operation.



1151
1152
1153
# File 'io_t_events/cfn_detector_model.rb', line 1151

def operation
  @operation
end

#payloadAWSCDK::IResolvable, ... (readonly)

Information needed to configure the payload.

By default, AWS IoT Events generates a standard payload in JSON for any action. This action payload contains all attribute-value pairs that have the information about the detector model instance and the event triggered the action. To configure the action payload, you can use content_expression .



1158
1159
1160
# File 'io_t_events/cfn_detector_model.rb', line 1158

def payload
  @payload
end

#payload_fieldString? (readonly)

The name of the DynamoDB column that receives the action payload.

If you don't specify this parameter, the name of the DynamoDB column is payload .



1165
1166
1167
# File 'io_t_events/cfn_detector_model.rb', line 1165

def payload_field
  @payload_field
end

#range_key_fieldString? (readonly)

The name of the range key (also called the sort key).

The range_key_field value must match the sort key of the target DynamoDB table.



1172
1173
1174
# File 'io_t_events/cfn_detector_model.rb', line 1172

def range_key_field
  @range_key_field
end

#range_key_typeString? (readonly)

The data type for the range key (also called the sort key), You can specify the following values:.

  • 'STRING' - The range key is a string.
  • 'NUMBER' - The range key is number.

If you don't specify range_key_field , the default value is 'STRING' .



1182
1183
1184
# File 'io_t_events/cfn_detector_model.rb', line 1182

def range_key_type
  @range_key_type
end

#range_key_valueString? (readonly)

The value of the range key (also called the sort key).



1187
1188
1189
# File 'io_t_events/cfn_detector_model.rb', line 1187

def range_key_value
  @range_key_value
end

#table_nameString (readonly)

The name of the DynamoDB table.

The table_name value must match the table name of the target DynamoDB table.



1130
1131
1132
# File 'io_t_events/cfn_detector_model.rb', line 1130

def table_name
  @table_name
end

Class Method Details

.jsii_propertiesObject



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
# File 'io_t_events/cfn_detector_model.rb', line 1189

def self.jsii_properties
  {
    :hash_key_field => "hashKeyField",
    :hash_key_value => "hashKeyValue",
    :table_name => "tableName",
    :hash_key_type => "hashKeyType",
    :operation => "operation",
    :payload => "payload",
    :payload_field => "payloadField",
    :range_key_field => "rangeKeyField",
    :range_key_type => "rangeKeyType",
    :range_key_value => "rangeKeyValue",
  }
end

Instance Method Details

#to_jsiiObject



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
# File 'io_t_events/cfn_detector_model.rb', line 1204

def to_jsii
  result = {}
  result.merge!({
    "hashKeyField" => @hash_key_field,
    "hashKeyValue" => @hash_key_value,
    "tableName" => @table_name,
    "hashKeyType" => @hash_key_type,
    "operation" => @operation,
    "payload" => @payload,
    "payloadField" => @payload_field,
    "rangeKeyField" => @range_key_field,
    "rangeKeyType" => @range_key_type,
    "rangeKeyValue" => @range_key_value,
  })
  result.compact
end