java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IResource, IResource, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable
Direct Known Subclasses:
ProxyResource

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:24.921Z") @Stability(Stable) public class Resource extends ResourceBase
Example:

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

    • Resource

      protected Resource(software.amazon.jsii.JsiiObjectRef objRef)
    • Resource

      protected Resource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Resource

      @Stability(Stable) public Resource(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ResourceProps props)
      Parameters:
      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.

      Parameters:
      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
    • 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