Class: AWSCDK::APIGateway::AccessLogFormat

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

Overview

factory methods for access log format.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format) ⇒ AccessLogFormat

Returns a new instance of AccessLogFormat.

Parameters:

  • format (String)


9
10
11
12
# File 'api_gateway/access_log_format.rb', line 9

def initialize(format)
  Jsii::Type.check_type(format, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "format")
  Jsii::Object.instance_method(:initialize).bind(self).call(format)
end

Class Method Details

.clfAWSCDK::APIGateway::AccessLogFormat

Generate Common Log Format.

Returns:

  • (AWSCDK::APIGateway::AccessLogFormat)


23
24
25
# File 'api_gateway/access_log_format.rb', line 23

def self.clf()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_apigateway.AccessLogFormat", "clf", [])
end

.custom(format) ⇒ AWSCDK::APIGateway::AccessLogFormat

Custom log format.

You can create any log format string. You can easily get the $ context variable by using the methods of AccessLogField.

Examples:

AWSCDK::APIGateway::AccessLogFormat.custom(JSON[:stringify]({
    request_id: AWSCDK::APIGateway::AccessLogField.context_request_id,
    source_ip: AWSCDK::APIGateway::AccessLogField.context_identity_source_ip,
    method: AWSCDK::APIGateway::AccessLogField.context_http_method,
    user_context: {
        sub: AWSCDK::APIGateway::AccessLogField.context_authorizer_claims("sub"),
        email: AWSCDK::APIGateway::AccessLogField.context_authorizer_claims("email"),
    },
}))

Parameters:

  • format (String)

Returns:

  • (AWSCDK::APIGateway::AccessLogFormat)


43
44
45
46
# File 'api_gateway/access_log_format.rb', line 43

def self.custom(format)
  Jsii::Type.check_type(format, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "format")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_apigateway.AccessLogFormat", "custom", [format])
end

.jsii_overridable_methodsObject



14
15
16
17
18
# File 'api_gateway/access_log_format.rb', line 14

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

.json_with_standard_fields(fields = nil) ⇒ AWSCDK::APIGateway::AccessLogFormat

Access log will be produced in the JSON format with a set of fields most useful in the access log.

All fields are turned on by default with the option to turn off specific fields.

Parameters:

Returns:

  • (AWSCDK::APIGateway::AccessLogFormat)


55
56
57
58
59
# File 'api_gateway/access_log_format.rb', line 55

def self.json_with_standard_fields(fields = nil)
  fields = fields.is_a?(Hash) ? ::AWSCDK::APIGateway::JsonWithStandardFieldProps.new(**fields.transform_keys(&:to_sym)) : fields
  Jsii::Type.check_type(fields, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5Kc29uV2l0aFN0YW5kYXJkRmllbGRQcm9wcyJ9")), "fields") unless fields.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_apigateway.AccessLogFormat", "jsonWithStandardFields", [fields])
end

Instance Method Details

#to_stringString

Output a format string to be used with CloudFormation.

Returns:

  • (String)


64
65
66
# File 'api_gateway/access_log_format.rb', line 64

def to_string()
  jsii_call_method("toString", [])
end