Class: AWSCDK::MediaStore::CfnContainer::CorsRuleProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
media_store/cfn_container.rb

Overview

A rule for a CORS policy.

You can add up to 100 rules to a CORS policy. If more than one rule applies, the service uses the first applicable rule listed.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed_headers: nil, allowed_methods: nil, allowed_origins: nil, expose_headers: nil, max_age_seconds: nil) ⇒ CorsRuleProperty

Returns a new instance of CorsRuleProperty.

Parameters:

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

    Specifies which headers are allowed in a preflight OPTIONS request through the Access-Control-Request-Headers header.

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

    Identifies an HTTP method that the origin that is specified in the rule is allowed to execute.

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

    One or more response headers that you want users to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).

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

    One or more headers in the response that you want users to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).

  • max_age_seconds (Numeric, nil) (defaults to: nil)

    The time in seconds that your browser caches the preflight response for the specified resource.



612
613
614
615
616
617
618
619
620
621
622
623
# File 'media_store/cfn_container.rb', line 612

def initialize(allowed_headers: nil, allowed_methods: nil, allowed_origins: nil, expose_headers: nil, max_age_seconds: nil)
  @allowed_headers = allowed_headers
  Jsii::Type.check_type(@allowed_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedHeaders") unless @allowed_headers.nil?
  @allowed_methods = allowed_methods
  Jsii::Type.check_type(@allowed_methods, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedMethods") unless @allowed_methods.nil?
  @allowed_origins = allowed_origins
  Jsii::Type.check_type(@allowed_origins, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedOrigins") unless @allowed_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_seconds = max_age_seconds
  Jsii::Type.check_type(@max_age_seconds, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "maxAgeSeconds") unless @max_age_seconds.nil?
end

Instance Attribute Details

#allowed_headersArray<String>? (readonly)

Specifies which headers are allowed in a preflight OPTIONS request through the Access-Control-Request-Headers header.

Each header name that is specified in Access-Control-Request-Headers must have a corresponding entry in the rule. Only the headers that were requested are sent back.

This element can contain only one wildcard character (*).



633
634
635
# File 'media_store/cfn_container.rb', line 633

def allowed_headers
  @allowed_headers
end

#allowed_methodsArray<String>? (readonly)

Identifies an HTTP method that the origin that is specified in the rule is allowed to execute.

Each CORS rule must contain at least one AllowedMethods and one AllowedOrigins element.



640
641
642
# File 'media_store/cfn_container.rb', line 640

def allowed_methods
  @allowed_methods
end

#allowed_originsArray<String>? (readonly)

One or more response headers that you want users to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).

Each CORS rule must have at least one AllowedOrigins element. The string value can include only one wildcard character (), for example, http://.example.com. Additionally, you can specify only one wildcard character to allow cross-origin access for all origins.



647
648
649
# File 'media_store/cfn_container.rb', line 647

def allowed_origins
  @allowed_origins
end

#expose_headersArray<String>? (readonly)

One or more headers in the response that you want users to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).

This element is optional for each rule.



654
655
656
# File 'media_store/cfn_container.rb', line 654

def expose_headers
  @expose_headers
end

#max_age_secondsNumeric? (readonly)

The time in seconds that your browser caches the preflight response for the specified resource.

A CORS rule can have only one MaxAgeSeconds element.



661
662
663
# File 'media_store/cfn_container.rb', line 661

def max_age_seconds
  @max_age_seconds
end

Class Method Details

.jsii_propertiesObject



663
664
665
666
667
668
669
670
671
# File 'media_store/cfn_container.rb', line 663

def self.jsii_properties
  {
    :allowed_headers => "allowedHeaders",
    :allowed_methods => "allowedMethods",
    :allowed_origins => "allowedOrigins",
    :expose_headers => "exposeHeaders",
    :max_age_seconds => "maxAgeSeconds",
  }
end

Instance Method Details

#to_jsiiObject



673
674
675
676
677
678
679
680
681
682
683
# File 'media_store/cfn_container.rb', line 673

def to_jsii
  result = {}
  result.merge!({
    "allowedHeaders" => @allowed_headers,
    "allowedMethods" => @allowed_methods,
    "allowedOrigins" => @allowed_origins,
    "exposeHeaders" => @expose_headers,
    "maxAgeSeconds" => @max_age_seconds,
  })
  result.compact
end