Table of Contents

Interface IResource

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll
public interface IResource : IResource, IConstruct, IConstruct, IDependable

Properties

Api

The rest API that this resource is part of.

IRestApi Api { get; }

Property Value

IRestApi

Remarks

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 it's hash to determine the ID of the deployment. This allows us to automatically update the deployment when the model of the REST API changes.

DefaultCorsPreflightOptions

Default options for CORS preflight OPTIONS method.

ICorsOptions? DefaultCorsPreflightOptions { get; }

Property Value

ICorsOptions

DefaultIntegration

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

Integration? DefaultIntegration { get; }

Property Value

Integration

DefaultMethodOptions

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

IMethodOptions? DefaultMethodOptions { get; }

Property Value

IMethodOptions

ParentResource

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

IResource? ParentResource { get; }

Property Value

IResource

Path

The full path of this resource.

string Path { get; }

Property Value

string

ResourceId

The ID of the resource.

string ResourceId { get; }

Property Value

string

Remarks

Attribute: true

RestApi

(deprecated) The rest API that this resource is part of.

[Obsolete("- Throws an error if this Resource is not associated with an instance of `RestApi`. Use `api` instead.")]
RestApi RestApi { get; }

Property Value

RestApi

Remarks

Stability: Deprecated

Methods

AddCorsPreflight(ICorsOptions)

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

Method AddCorsPreflight(ICorsOptions options)

Parameters

options ICorsOptions

CORS options.

Returns

Method

a Method object

Remarks

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.

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

AddMethod(string, Integration?, IMethodOptions?)

Defines a new method for this resource.

Method AddMethod(string httpMethod, Integration? target = null, IMethodOptions? options = null)

Parameters

httpMethod string

The HTTP method.

target Integration

The target backend integration for this method.

options IMethodOptions

Method options, such as authentication.

Returns

Method

The newly created Method object.

AddProxy(IProxyResourceOptions?)

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

ProxyResource AddProxy(IProxyResourceOptions? options = null)

Parameters

options IProxyResourceOptions

Default integration and method options.

Returns

ProxyResource

AddResource(string, IResourceOptions?)

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

Resource AddResource(string pathPart, IResourceOptions? options = null)

Parameters

pathPart string

The path part for the child resource.

options IResourceOptions

Resource options.

Returns

Resource

A Resource object

GetResource(string)

Retrieves a child resource by path part.

IResource? GetResource(string pathPart)

Parameters

pathPart string

The path part of the child resource.

Returns

IResource

the child resource or undefined if not found

ResourceForPath(string)

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

Resource ResourceForPath(string path)

Parameters

path string

The relative path.

Returns

Resource

a new or existing resource.

Remarks