Table of Contents

Class Resource

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll
public class Resource : ResourceBase, IResource, IResource, IConstruct, IConstruct, IDependable
Inheritance
Resource
Implements
IResource
IConstruct
IConstruct
IDependable
Derived
Inherited Members

Examples

LambdaIntegration booksBackend;

            var api = new RestApi(this, "books", new RestApiProps {
                DefaultIntegration = booksBackend
            });

            var books = api.Root.AddResource("books");
            books.AddMethod("GET"); // integrated with `booksBackend`
            books.AddMethod("POST"); // integrated with `booksBackend`

            var book = books.AddResource("{book_id}");
            book.AddMethod("GET");

Remarks

ExampleMetadata: infused

Constructors

Resource(Construct, string, IResourceProps)

public Resource(Construct scope, string id, IResourceProps props)

Parameters

scope Construct
id string
props IResourceProps

Properties

Api

The rest API that this resource is part of.

public override 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.

public override 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.

public override 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.

public override IMethodOptions? DefaultMethodOptions { get; }

Property Value

IMethodOptions

ParentResource

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

public override IResource? ParentResource { get; }

Property Value

IResource

Path

The full path of this resource.

public override string Path { get; }

Property Value

string

ResourceId

The ID of the resource.

public override string ResourceId { get; }

Property Value

string

RestApi

(deprecated) The RestApi associated with this Resource.

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

Property Value

RestApi

Remarks

Stability: Deprecated

Methods

FromResourceAttributes(Construct, string, IResourceAttributes)

Import an existing resource.

public static IResource FromResourceAttributes(Construct scope, string id, IResourceAttributes attrs)

Parameters

scope Construct
id string
attrs IResourceAttributes

Returns

IResource