Class: AWSCDK::APIGatewayv2::CorsPreflightOptions

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
api_gatewayv2/cors_preflight_options.rb

Overview

Options for the CORS Configuration.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_credentials: nil, allow_headers: nil, allow_methods: nil, allow_origins: nil, expose_headers: nil, max_age: nil) ⇒ CorsPreflightOptions

Returns a new instance of CorsPreflightOptions.

Parameters:

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

    Specifies whether credentials are included in the CORS request.

  • allow_headers (Array<String>, nil) (defaults to: nil)

    Represents a collection of allowed headers.

  • allow_methods (Array<AWSCDK::APIGatewayv2::CorsHttpMethod>, nil) (defaults to: nil)

    Represents a collection of allowed HTTP methods.

  • allow_origins (Array<String>, nil) (defaults to: nil)

    Represents a collection of allowed origins.

  • expose_headers (Array<String>, nil) (defaults to: nil)

    Represents a collection of exposed headers.

  • max_age (AWSCDK::Duration, nil) (defaults to: nil)

    The duration that the browser should cache preflight request results.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'api_gatewayv2/cors_preflight_options.rb', line 13

def initialize(allow_credentials: nil, allow_headers: nil, allow_methods: nil, allow_origins: nil, expose_headers: nil, max_age: nil)
  @allow_credentials = allow_credentials
  Jsii::Type.check_type(@allow_credentials, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "allowCredentials") unless @allow_credentials.nil?
  @allow_headers = allow_headers
  Jsii::Type.check_type(@allow_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowHeaders") unless @allow_headers.nil?
  @allow_methods = allow_methods
  Jsii::Type.check_type(@allow_methods, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hcGlnYXRld2F5djIuQ29yc0h0dHBNZXRob2QifSwia2luZCI6ImFycmF5In19")), "allowMethods") unless @allow_methods.nil?
  @allow_origins = allow_origins
  Jsii::Type.check_type(@allow_origins, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowOrigins") unless @allow_origins.nil?
  @expose_headers = expose_headers
  Jsii::Type.check_type(@expose_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exposeHeaders") unless @expose_headers.nil?
  @max_age = max_age
  Jsii::Type.check_type(@max_age, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "maxAge") unless @max_age.nil?
end

Instance Attribute Details

#allow_credentialsBoolean? (readonly)

Note:

Default: false

Specifies whether credentials are included in the CORS request.

Returns:

  • (Boolean, nil)


32
33
34
# File 'api_gatewayv2/cors_preflight_options.rb', line 32

def allow_credentials
  @allow_credentials
end

#allow_headersArray<String>? (readonly)

Note:

Default: - No Headers are allowed.

Represents a collection of allowed headers.

Returns:

  • (Array<String>, nil)


37
38
39
# File 'api_gatewayv2/cors_preflight_options.rb', line 37

def allow_headers
  @allow_headers
end

#allow_methodsArray<AWSCDK::APIGatewayv2::CorsHttpMethod>? (readonly)

Note:

Default: - No Methods are allowed.

Represents a collection of allowed HTTP methods.

Returns:



42
43
44
# File 'api_gatewayv2/cors_preflight_options.rb', line 42

def allow_methods
  @allow_methods
end

#allow_originsArray<String>? (readonly)

Note:

Default: - No Origins are allowed.

Represents a collection of allowed origins.

Returns:

  • (Array<String>, nil)


47
48
49
# File 'api_gatewayv2/cors_preflight_options.rb', line 47

def allow_origins
  @allow_origins
end

#expose_headersArray<String>? (readonly)

Note:

Default: - No Expose Headers are allowed.

Represents a collection of exposed headers.

Returns:

  • (Array<String>, nil)


52
53
54
# File 'api_gatewayv2/cors_preflight_options.rb', line 52

def expose_headers
  @expose_headers
end

#max_ageAWSCDK::Duration? (readonly)

Note:

Default: Duration.seconds(0)

The duration that the browser should cache preflight request results.

Returns:



57
58
59
# File 'api_gatewayv2/cors_preflight_options.rb', line 57

def max_age
  @max_age
end

Class Method Details

.jsii_propertiesObject



59
60
61
62
63
64
65
66
67
68
# File 'api_gatewayv2/cors_preflight_options.rb', line 59

def self.jsii_properties
  {
    :allow_credentials => "allowCredentials",
    :allow_headers => "allowHeaders",
    :allow_methods => "allowMethods",
    :allow_origins => "allowOrigins",
    :expose_headers => "exposeHeaders",
    :max_age => "maxAge",
  }
end

Instance Method Details

#to_jsiiObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'api_gatewayv2/cors_preflight_options.rb', line 70

def to_jsii
  result = {}
  result.merge!({
    "allowCredentials" => @allow_credentials,
    "allowHeaders" => @allow_headers,
    "allowMethods" => @allow_methods,
    "allowOrigins" => @allow_origins,
    "exposeHeaders" => @expose_headers,
    "maxAge" => @max_age,
  })
  result.compact
end