Class: AWSCDK::AppSync::MappingTemplate

Inherits:
Jsii::Object
  • Object
show all
Defined in:
app_sync/mapping_template.rb

Overview

MappingTemplates for AppSync resolvers.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMappingTemplate

Returns a new instance of MappingTemplate.



8
9
10
# File 'app_sync/mapping_template.rb', line 8

def initialize
  Jsii::Object.instance_method(:initialize).bind(self).call
end

Class Method Details

.dynamo_db_delete_item(key_name, id_arg) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to delete a single item from a DynamoDB table.

Parameters:

  • key_name (String)

    the name of the hash key field.

  • id_arg (String)

    the name of the Mutation argument.

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


23
24
25
26
27
# File 'app_sync/mapping_template.rb', line 23

def self.dynamo_db_delete_item(key_name, id_arg)
  Jsii::Type.check_type(key_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "keyName")
  Jsii::Type.check_type(id_arg, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "idArg")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbDeleteItem", [key_name, id_arg])
end

.dynamo_db_get_item(key_name, id_arg, consistent_read = nil) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to get a single item from a DynamoDB table.

Parameters:

  • key_name (String)

    the name of the hash key field.

  • id_arg (String)

    the name of the Query argument.

  • consistent_read (Boolean, nil) (defaults to: nil)

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


35
36
37
38
39
40
# File 'app_sync/mapping_template.rb', line 35

def self.dynamo_db_get_item(key_name, id_arg, consistent_read = nil)
  Jsii::Type.check_type(key_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "keyName")
  Jsii::Type.check_type(id_arg, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "idArg")
  Jsii::Type.check_type(consistent_read, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "consistentRead") unless consistent_read.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbGetItem", [key_name, id_arg, consistent_read])
end

.dynamo_db_put_item(key, values) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to save a single item to a DynamoDB table.

Parameters:

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


47
48
49
50
51
# File 'app_sync/mapping_template.rb', line 47

def self.dynamo_db_put_item(key, values)
  Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBwc3luYy5QcmltYXJ5S2V5In0=")), "key")
  Jsii::Type.check_type(values, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBwc3luYy5BdHRyaWJ1dGVWYWx1ZXMifQ==")), "values")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbPutItem", [key, values])
end

.dynamo_db_query(cond, index_name = nil, consistent_read = nil) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to query a set of items from a DynamoDB table.

Parameters:

  • cond (AWSCDK::AppSync::KeyCondition)

    the key condition for the query.

  • index_name (String, nil) (defaults to: nil)
  • consistent_read (Boolean, nil) (defaults to: nil)

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


59
60
61
62
63
64
# File 'app_sync/mapping_template.rb', line 59

def self.dynamo_db_query(cond, index_name = nil, consistent_read = nil)
  Jsii::Type.check_type(cond, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBwc3luYy5LZXlDb25kaXRpb24ifQ==")), "cond")
  Jsii::Type.check_type(index_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "indexName") unless index_name.nil?
  Jsii::Type.check_type(consistent_read, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "consistentRead") unless consistent_read.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbQuery", [cond, index_name, consistent_read])
end

.dynamo_db_result_itemAWSCDK::AppSync::MappingTemplate

Mapping template for a single result item from DynamoDB.

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


69
70
71
# File 'app_sync/mapping_template.rb', line 69

def self.dynamo_db_result_item()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbResultItem", [])
end

.dynamo_db_result_listAWSCDK::AppSync::MappingTemplate

Mapping template for a result list from DynamoDB.

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


76
77
78
# File 'app_sync/mapping_template.rb', line 76

def self.dynamo_db_result_list()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbResultList", [])
end

.dynamo_db_scan_table(consistent_read = nil) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to scan a DynamoDB table to fetch all entries.

Parameters:

  • consistent_read (Boolean, nil) (defaults to: nil)

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


84
85
86
87
# File 'app_sync/mapping_template.rb', line 84

def self.dynamo_db_scan_table(consistent_read = nil)
  Jsii::Type.check_type(consistent_read, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "consistentRead") unless consistent_read.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "dynamoDbScanTable", [consistent_read])
end

.from_file(file_name) ⇒ AWSCDK::AppSync::MappingTemplate

Create a mapping template from the given file.

Parameters:

  • file_name (String)

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


93
94
95
96
# File 'app_sync/mapping_template.rb', line 93

def self.from_file(file_name)
  Jsii::Type.check_type(file_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fileName")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "fromFile", [file_name])
end

.from_string(template) ⇒ AWSCDK::AppSync::MappingTemplate

Create a mapping template from the given string.

Parameters:

  • template (String)

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


102
103
104
105
# File 'app_sync/mapping_template.rb', line 102

def self.from_string(template)
  Jsii::Type.check_type(template, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "template")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "fromString", [template])
end

.jsii_overridable_methodsObject



12
13
14
15
16
# File 'app_sync/mapping_template.rb', line 12

def self.jsii_overridable_methods
  {
    :render_template => { kind: :method, name: "renderTemplate", is_optional: false },
  }
end

.lambda_request(payload = nil, operation = nil) ⇒ AWSCDK::AppSync::MappingTemplate

Mapping template to invoke a Lambda function.

Parameters:

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

    the VTL template snippet of the payload to send to the lambda.

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

    the type of operation AppSync should perform on the data source.

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


112
113
114
115
116
# File 'app_sync/mapping_template.rb', line 112

def self.lambda_request(payload = nil, operation = nil)
  Jsii::Type.check_type(payload, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "payload") unless payload.nil?
  Jsii::Type.check_type(operation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "operation") unless operation.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "lambdaRequest", [payload, operation])
end

.lambda_resultAWSCDK::AppSync::MappingTemplate

Mapping template to return the Lambda result to the caller.

Returns:

  • (AWSCDK::AppSync::MappingTemplate)


121
122
123
# File 'app_sync/mapping_template.rb', line 121

def self.lambda_result()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_appsync.MappingTemplate", "lambdaResult", [])
end

Instance Method Details

#render_templateString

this is called to render the mapping template to a VTL string.

Returns:

  • (String)


128
129
130
# File 'app_sync/mapping_template.rb', line 128

def render_template()
  jsii_call_method("renderTemplate", [])
end