Class: AWSCDK::APIGateway::RequestContext

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
api_gateway/request_context.rb

Overview

Configure what must be included in the requestContext.

More details can be found at mapping templates documentation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id: nil, api_id: nil, api_key: nil, authorizer_principal_id: nil, caller: nil, cognito_authentication_provider: nil, cognito_authentication_type: nil, cognito_identity_id: nil, cognito_identity_pool_id: nil, http_method: nil, request_id: nil, resource_id: nil, resource_path: nil, source_ip: nil, stage: nil, user: nil, user_agent: nil, user_arn: nil) ⇒ RequestContext

Returns a new instance of RequestContext.

Parameters:

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

    Represents the information of $context.identity.accountId.

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

    Represents the information of $context.apiId.

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

    Represents the information of $context.identity.apiKey.

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

    Represents the information of $context.authorizer.principalId.

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

    Represents the information of $context.identity.caller.

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

    Represents the information of $context.identity.cognitoAuthenticationProvider.

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

    Represents the information of $context.identity.cognitoAuthenticationType.

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

    Represents the information of $context.identity.cognitoIdentityId.

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

    Represents the information of $context.identity.cognitoIdentityPoolId.

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

    Represents the information of $context.httpMethod.

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

    Represents the information of $context.requestId.

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

    Represents the information of $context.resourceId.

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

    Represents the information of $context.resourcePath.

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

    Represents the information of $context.identity.sourceIp.

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

    Represents the information of $context.stage.

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

    Represents the information of $context.identity.user.

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

    Represents the information of $context.identity.userAgent.

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

    Represents the information of $context.identity.userArn.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'api_gateway/request_context.rb', line 29

def initialize(account_id: nil, api_id: nil, api_key: nil, authorizer_principal_id: nil, caller: nil, cognito_authentication_provider: nil, cognito_authentication_type: nil, cognito_identity_id: nil, cognito_identity_pool_id: nil, http_method: nil, request_id: nil, resource_id: nil, resource_path: nil, source_ip: nil, stage: nil, user: nil, user_agent: nil, user_arn: nil)
  @account_id = 
  Jsii::Type.check_type(@account_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "accountId") unless @account_id.nil?
  @api_id = api_id
  Jsii::Type.check_type(@api_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "apiId") unless @api_id.nil?
  @api_key = api_key
  Jsii::Type.check_type(@api_key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "apiKey") unless @api_key.nil?
  @authorizer_principal_id = authorizer_principal_id
  Jsii::Type.check_type(@authorizer_principal_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "authorizerPrincipalId") unless @authorizer_principal_id.nil?
  @caller = caller
  Jsii::Type.check_type(@caller, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "caller") unless @caller.nil?
  @cognito_authentication_provider = cognito_authentication_provider
  Jsii::Type.check_type(@cognito_authentication_provider, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cognitoAuthenticationProvider") unless @cognito_authentication_provider.nil?
  @cognito_authentication_type = cognito_authentication_type
  Jsii::Type.check_type(@cognito_authentication_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cognitoAuthenticationType") unless @cognito_authentication_type.nil?
  @cognito_identity_id = cognito_identity_id
  Jsii::Type.check_type(@cognito_identity_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cognitoIdentityId") unless @cognito_identity_id.nil?
  @cognito_identity_pool_id = cognito_identity_pool_id
  Jsii::Type.check_type(@cognito_identity_pool_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cognitoIdentityPoolId") unless @cognito_identity_pool_id.nil?
  @http_method = http_method
  Jsii::Type.check_type(@http_method, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "httpMethod") unless @http_method.nil?
  @request_id = request_id
  Jsii::Type.check_type(@request_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "requestId") unless @request_id.nil?
  @resource_id = resource_id
  Jsii::Type.check_type(@resource_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "resourceId") unless @resource_id.nil?
  @resource_path = resource_path
  Jsii::Type.check_type(@resource_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "resourcePath") unless @resource_path.nil?
  @source_ip = source_ip
  Jsii::Type.check_type(@source_ip, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "sourceIp") unless @source_ip.nil?
  @stage = stage
  Jsii::Type.check_type(@stage, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "stage") unless @stage.nil?
  @user = user
  Jsii::Type.check_type(@user, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "user") unless @user.nil?
  @user_agent = user_agent
  Jsii::Type.check_type(@user_agent, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "userAgent") unless @user_agent.nil?
  @user_arn = user_arn
  Jsii::Type.check_type(@user_arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "userArn") unless @user_arn.nil?
end

Instance Attribute Details

#account_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.accountId.

Whether the AWS account of the API owner should be included in the request context

Returns:

  • (Boolean, nil)


74
75
76
# File 'api_gateway/request_context.rb', line 74

def 
  @account_id
end

#api_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.apiId.

Whether the identifier API Gateway assigns to your API should be included in the request context.

Returns:

  • (Boolean, nil)


81
82
83
# File 'api_gateway/request_context.rb', line 81

def api_id
  @api_id
end

#api_keyBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.apiKey.

Whether the API key associated with the request should be included in request context.

Returns:

  • (Boolean, nil)


88
89
90
# File 'api_gateway/request_context.rb', line 88

def api_key
  @api_key
end

#authorizer_principal_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.authorizer.principalId.

Whether the principal user identifier associated with the token sent by the client and returned from an API Gateway Lambda authorizer should be included in the request context.

Returns:

  • (Boolean, nil)


96
97
98
# File 'api_gateway/request_context.rb', line 96

def authorizer_principal_id
  @authorizer_principal_id
end

#callerBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.caller.

Whether the principal identifier of the caller that signed the request should be included in the request context. Supported for resources that use IAM authorization.

Returns:

  • (Boolean, nil)


104
105
106
# File 'api_gateway/request_context.rb', line 104

def caller
  @caller
end

#cognito_authentication_providerBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.cognitoAuthenticationProvider.

Whether the list of the Amazon Cognito authentication providers used by the caller making the request should be included in the request context. Available only if the request was signed with Amazon Cognito credentials.

Returns:

  • (Boolean, nil)


112
113
114
# File 'api_gateway/request_context.rb', line 112

def cognito_authentication_provider
  @cognito_authentication_provider
end

#cognito_authentication_typeBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.cognitoAuthenticationType.

Whether the Amazon Cognito authentication type of the caller making the request should be included in the request context. Available only if the request was signed with Amazon Cognito credentials. Possible values include authenticated for authenticated identities and unauthenticated for unauthenticated identities.

Returns:

  • (Boolean, nil)


121
122
123
# File 'api_gateway/request_context.rb', line 121

def cognito_authentication_type
  @cognito_authentication_type
end

#cognito_identity_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.cognitoIdentityId.

Whether the Amazon Cognito identity ID of the caller making the request should be included in the request context. Available only if the request was signed with Amazon Cognito credentials.

Returns:

  • (Boolean, nil)


129
130
131
# File 'api_gateway/request_context.rb', line 129

def cognito_identity_id
  @cognito_identity_id
end

#cognito_identity_pool_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.cognitoIdentityPoolId.

Whether the Amazon Cognito identity pool ID of the caller making the request should be included in the request context. Available only if the request was signed with Amazon Cognito credentials.

Returns:

  • (Boolean, nil)


137
138
139
# File 'api_gateway/request_context.rb', line 137

def cognito_identity_pool_id
  @cognito_identity_pool_id
end

#http_methodBoolean? (readonly)

Note:

Default: false

Represents the information of $context.httpMethod.

Whether the HTTP method used should be included in the request context. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.

Returns:

  • (Boolean, nil)


145
146
147
# File 'api_gateway/request_context.rb', line 145

def http_method
  @http_method
end

#request_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.requestId.

Whether the ID for the request should be included in the request context.

Returns:

  • (Boolean, nil)


152
153
154
# File 'api_gateway/request_context.rb', line 152

def request_id
  @request_id
end

#resource_idBoolean? (readonly)

Note:

Default: false

Represents the information of $context.resourceId.

Whether the identifier that API Gateway assigns to your resource should be included in the request context.

Returns:

  • (Boolean, nil)


159
160
161
# File 'api_gateway/request_context.rb', line 159

def resource_id
  @resource_id
end

#resource_pathBoolean? (readonly)

Note:

Default: false

Represents the information of $context.resourcePath.

Whether the path to the resource should be included in the request context.

Returns:

  • (Boolean, nil)


166
167
168
# File 'api_gateway/request_context.rb', line 166

def resource_path
  @resource_path
end

#source_ipBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.sourceIp.

Whether the source IP address of the immediate TCP connection making the request to API Gateway endpoint should be included in the request context.

Returns:

  • (Boolean, nil)


174
175
176
# File 'api_gateway/request_context.rb', line 174

def source_ip
  @source_ip
end

#stageBoolean? (readonly)

Note:

Default: false

Represents the information of $context.stage.

Whether the deployment stage of the API request should be included in the request context.

Returns:

  • (Boolean, nil)


181
182
183
# File 'api_gateway/request_context.rb', line 181

def stage
  @stage
end

#userBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.user.

Whether the principal identifier of the user that will be authorized should be included in the request context. Supported for resources that use IAM authorization.

Returns:

  • (Boolean, nil)


189
190
191
# File 'api_gateway/request_context.rb', line 189

def user
  @user
end

#user_agentBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.userAgent.

Whether the User-Agent header of the API caller should be included in the request context.

Returns:

  • (Boolean, nil)


196
197
198
# File 'api_gateway/request_context.rb', line 196

def user_agent
  @user_agent
end

#user_arnBoolean? (readonly)

Note:

Default: false

Represents the information of $context.identity.userArn.

Whether the Amazon Resource Name (ARN) of the effective user identified after authentication should be included in the request context.

Returns:

  • (Boolean, nil)


203
204
205
# File 'api_gateway/request_context.rb', line 203

def user_arn
  @user_arn
end

Class Method Details

.jsii_propertiesObject



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'api_gateway/request_context.rb', line 205

def self.jsii_properties
  {
    :account_id => "accountId",
    :api_id => "apiId",
    :api_key => "apiKey",
    :authorizer_principal_id => "authorizerPrincipalId",
    :caller => "caller",
    :cognito_authentication_provider => "cognitoAuthenticationProvider",
    :cognito_authentication_type => "cognitoAuthenticationType",
    :cognito_identity_id => "cognitoIdentityId",
    :cognito_identity_pool_id => "cognitoIdentityPoolId",
    :http_method => "httpMethod",
    :request_id => "requestId",
    :resource_id => "resourceId",
    :resource_path => "resourcePath",
    :source_ip => "sourceIp",
    :stage => "stage",
    :user => "user",
    :user_agent => "userAgent",
    :user_arn => "userArn",
  }
end

Instance Method Details

#to_jsiiObject



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'api_gateway/request_context.rb', line 228

def to_jsii
  result = {}
  result.merge!({
    "accountId" => @account_id,
    "apiId" => @api_id,
    "apiKey" => @api_key,
    "authorizerPrincipalId" => @authorizer_principal_id,
    "caller" => @caller,
    "cognitoAuthenticationProvider" => @cognito_authentication_provider,
    "cognitoAuthenticationType" => @cognito_authentication_type,
    "cognitoIdentityId" => @cognito_identity_id,
    "cognitoIdentityPoolId" => @cognito_identity_pool_id,
    "httpMethod" => @http_method,
    "requestId" => @request_id,
    "resourceId" => @resource_id,
    "resourcePath" => @resource_path,
    "sourceIp" => @source_ip,
    "stage" => @stage,
    "user" => @user,
    "userAgent" => @user_agent,
    "userArn" => @user_arn,
  })
  result.compact
end