All Implemented Interfaces:
IConstruct, IDependable, IResource, IResource,, software.constructs.IConstruct
Direct Known Subclasses:

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:45.062Z") @Stability(Stable) public class Resource extends ResourceBase

 LambdaIntegration booksBackend;
 RestApi api = RestApi.Builder.create(this, "books")
 Resource books = api.root.addResource("books");
 books.addMethod("GET"); // integrated with `booksBackend`
 books.addMethod("POST"); // integrated with `booksBackend`
 Resource book = books.addResource("{book_id}");
  • Constructor Details

    • Resource

      protected Resource( objRef)
    • Resource

      protected Resource( initializationMode)
    • Resource

      @Stability(Stable) public Resource(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ResourceProps props)
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromResourceAttributes

      @Stability(Stable) @NotNull public static IResource fromResourceAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ResourceAttributes attrs)
      Import an existing resource.

      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • getApi

      @Stability(Stable) @NotNull public IRestApi getApi()
      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 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.

      Specified by:
      getApi in interface IResource
      Specified by:
      getApi in class ResourceBase
    • getPath

      @Stability(Stable) @NotNull public String getPath()
      The full path of this resource.
      Specified by:
      getPath in interface IResource
      Specified by:
      getPath in class ResourceBase
    • getResourceId

      @Stability(Stable) @NotNull public String getResourceId()
      The ID of the resource.
      Specified by:
      getResourceId in interface IResource
      Specified by:
      getResourceId in class ResourceBase
    • getRestApi

      @Stability(Deprecated) @Deprecated @NotNull public RestApi getRestApi()
      • Throws an error if this Resource is not associated with an instance of RestApi. Use api instead.
      (deprecated) The RestApi associated with this Resource.

      Specified by:
      getRestApi in interface IResource
      Specified by:
      getRestApi in class ResourceBase
    • getDefaultCorsPreflightOptions

      @Stability(Stable) @Nullable public CorsOptions getDefaultCorsPreflightOptions()
      Default options for CORS preflight OPTIONS method.
      Specified by:
      getDefaultCorsPreflightOptions in interface IResource
      Specified by:
      getDefaultCorsPreflightOptions in class ResourceBase
    • getDefaultIntegration

      @Stability(Stable) @Nullable public Integration getDefaultIntegration()
      An integration to use as a default for all methods created within this API unless an integration is specified.
      Specified by:
      getDefaultIntegration in interface IResource
      Specified by:
      getDefaultIntegration in class ResourceBase
    • getDefaultMethodOptions

      @Stability(Stable) @Nullable public MethodOptions getDefaultMethodOptions()
      Method options to use as a default for all methods created within this API unless custom options are specified.
      Specified by:
      getDefaultMethodOptions in interface IResource
      Specified by:
      getDefaultMethodOptions in class ResourceBase
    • getParentResource

      @Stability(Stable) @Nullable public IResource getParentResource()
      The parent of this resource or undefined for the root resource.
      Specified by:
      getParentResource in interface IResource
      Specified by:
      getParentResource in class ResourceBase