Module: AWSCDK::APIGateway::IResource

Includes:
IResource, Interfaces::AWSApigateway::IResourceRef
Included in:
ResourceBase
Defined in:
api_gateway/i_resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



204
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/i_resource.rb', line 204

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :resource_ref => { kind: :property, name: "resourceRef", is_optional: false },
    :api => { kind: :property, name: "api", is_optional: false },
    :path => { kind: :property, name: "path", is_optional: false },
    :resource_id => { kind: :property, name: "resourceId", is_optional: false },
    :default_cors_preflight_options => { kind: :property, name: "defaultCorsPreflightOptions", is_optional: true },
    :default_integration => { kind: :property, name: "defaultIntegration", is_optional: true },
    :default_method_options => { kind: :property, name: "defaultMethodOptions", is_optional: true },
    :parent_resource => { kind: :property, name: "parentResource", is_optional: true },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :add_cors_preflight => { kind: :method, name: "addCorsPreflight", is_optional: false },
    :add_method => { kind: :method, name: "addMethod", is_optional: false },
    :add_proxy => { kind: :method, name: "addProxy", is_optional: false },
    :add_resource => { kind: :method, name: "addResource", is_optional: false },
    :get_resource => { kind: :method, name: "getResource", is_optional: false },
    :resource_for_path => { kind: :method, name: "resourceForPath", is_optional: false },
  }
end

Instance Method Details

#add_cors_preflight(options) ⇒ AWSCDK::APIGateway::Method

Adds an OPTIONS method to this resource which responds to Cross-Origin Resource Sharing (CORS) preflight requests.

Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own.

Parameters:

Returns:

See Also:



141
142
143
144
145
# File 'api_gateway/i_resource.rb', line 141

def add_cors_preflight(options)
  options = options.is_a?(Hash) ? ::AWSCDK::APIGateway::CorsOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5Db3JzT3B0aW9ucyJ9")), "options")
  jsii_call_method("addCorsPreflight", [options])
end

#add_method(http_method, target = nil, options = nil) ⇒ AWSCDK::APIGateway::Method

Defines a new method for this resource.

Parameters:

Returns:



153
154
155
156
157
158
159
# File 'api_gateway/i_resource.rb', line 153

def add_method(http_method, target = nil, options = nil)
  Jsii::Type.check_type(http_method, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "httpMethod")
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5JbnRlZ3JhdGlvbiJ9")), "target") unless target.nil?
  options = options.is_a?(Hash) ? ::AWSCDK::APIGateway::MethodOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5NZXRob2RPcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("addMethod", [http_method, target, options])
end

#add_proxy(options = nil) ⇒ AWSCDK::APIGateway::ProxyResource

Adds a greedy proxy resource ("proxy+") and an ANY method to this route.

Parameters:

Returns:



165
166
167
168
169
# File 'api_gateway/i_resource.rb', line 165

def add_proxy(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::APIGateway::ProxyResourceOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5Qcm94eVJlc291cmNlT3B0aW9ucyJ9")), "options") unless options.nil?
  jsii_call_method("addProxy", [options])
end

#add_resource(path_part, options = nil) ⇒ AWSCDK::APIGateway::Resource

Defines a new child resource where this resource is the parent.

Parameters:

Returns:



176
177
178
179
180
181
# File 'api_gateway/i_resource.rb', line 176

def add_resource(path_part, options = nil)
  Jsii::Type.check_type(path_part, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "pathPart")
  options = options.is_a?(Hash) ? ::AWSCDK::APIGateway::ResourceOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5SZXNvdXJjZU9wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("addResource", [path_part, options])
end

#apiAWSCDK::APIGateway::IRestAPI

The rest API that this resource is part of.

The reason we need the RestApi object itself and not just the ID is because the model is being tracked by the top-level RestApi object for the purpose of calculating its hash to determine the ID of the deployment. This allows us to automatically update the deployment when the model of the REST API changes.



52
53
54
# File 'api_gateway/i_resource.rb', line 52

def api()
  jsii_get_property("api")
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



124
125
126
127
# File 'api_gateway/i_resource.rb', line 124

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#default_cors_preflight_optionsAWSCDK::APIGateway::CorsOptions?

Default options for CORS preflight OPTIONS method.



73
74
75
# File 'api_gateway/i_resource.rb', line 73

def default_cors_preflight_options()
  jsii_get_property("defaultCorsPreflightOptions")
end

#default_integrationAWSCDK::APIGateway::Integration?

An integration to use as a default for all methods created within this API unless an integration is specified.



80
81
82
# File 'api_gateway/i_resource.rb', line 80

def default_integration()
  jsii_get_property("defaultIntegration")
end

#default_method_optionsAWSCDK::APIGateway::MethodOptions?

Method options to use as a default for all methods created within this API unless custom options are specified.



87
88
89
# File 'api_gateway/i_resource.rb', line 87

def default_method_options()
  jsii_get_property("defaultMethodOptions")
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



26
27
28
# File 'api_gateway/i_resource.rb', line 26

def env()
  jsii_get_property("env")
end

#get_resource(path_part) ⇒ AWSCDK::APIGateway::IResource?

Retrieves a child resource by path part.

Parameters:

  • path_part (String)

    The path part of the child resource.

Returns:

  • (AWSCDK::APIGateway::IResource, nil)

    the child resource or undefined if not found



187
188
189
190
# File 'api_gateway/i_resource.rb', line 187

def get_resource(path_part)
  Jsii::Type.check_type(path_part, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "pathPart")
  jsii_call_method("getResource", [path_part])
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


11
12
13
# File 'api_gateway/i_resource.rb', line 11

def node()
  jsii_get_property("node")
end

#parent_resourceAWSCDK::APIGateway::IResource?

The parent of this resource or undefined for the root resource.

Returns:

  • (AWSCDK::APIGateway::IResource, nil)


94
95
96
# File 'api_gateway/i_resource.rb', line 94

def parent_resource()
  jsii_get_property("parentResource")
end

#pathString

The full path of this resource.

Returns:

  • (String)


59
60
61
# File 'api_gateway/i_resource.rb', line 59

def path()
  jsii_get_property("path")
end

#resource_for_path(path) ⇒ AWSCDK::APIGateway::Resource

Gets or create all resources leading up to the specified path.

  • Path may only start with "/" if this method is called on the root resource.
  • All resources are created using default options.

Parameters:

  • path (String)

    The relative path.

Returns:



199
200
201
202
# File 'api_gateway/i_resource.rb', line 199

def resource_for_path(path)
  Jsii::Type.check_type(path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "path")
  jsii_call_method("resourceForPath", [path])
end

#resource_idString

The ID of the resource.

Returns:

  • (String)


66
67
68
# File 'api_gateway/i_resource.rb', line 66

def resource_id()
  jsii_get_property("resourceId")
end

#resource_refAWSCDK::Interfaces::AWSApigateway::ResourceReference

A reference to a Resource resource.



40
41
42
# File 'api_gateway/i_resource.rb', line 40

def resource_ref()
  jsii_get_property("resourceRef")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



33
34
35
# File 'api_gateway/i_resource.rb', line 33

def stack()
  jsii_get_property("stack")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



105
106
107
108
109
110
# File 'api_gateway/i_resource.rb', line 105

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end