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
-
IResourceIConstructIConstructIDependable
- 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
Constructid
stringprops
IResourceProps
Properties
Api
The rest API that this resource is part of.
public override IRestApi Api { get; }
Property Value
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
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
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
ParentResource
The parent of this resource or undefined for the root resource.
public override IResource? ParentResource { get; }
Property Value
Path
The full path of this resource.
public override string Path { get; }
Property Value
ResourceId
The ID of the resource.
public override string ResourceId { get; }
Property Value
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
Remarks
Stability: Deprecated
Methods
FromResourceAttributes(Construct, string, IResourceAttributes)
Import an existing resource.
public static IResource FromResourceAttributes(Construct scope, string id, IResourceAttributes attrs)
Parameters
scope
Constructid
stringattrs
IResourceAttributes