Class WebSocketApi

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.apigatewayv2.WebSocketApi
All Implemented Interfaces:
IConstruct, IDependable, IResource, IApi, IWebSocketApi, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:43.338Z") @Stability(Experimental) public class WebSocketApi extends Resource implements IWebSocketApi, IApi
(experimental) Create a new API Gateway WebSocket API endpoint.

Example:

 import software.amazon.awscdk.services.apigatewayv2.integrations.WebSocketLambdaIntegration;
 Function messageHandler;
 WebSocketApi webSocketApi = new WebSocketApi(this, "mywsapi");
 webSocketApi.addRoute("sendmessage", WebSocketRouteOptions.builder()
         .integration(new WebSocketLambdaIntegration("SendMessageIntegration", messageHandler))
         .build());
 
  • Constructor Details

    • WebSocketApi

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

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

      @Stability(Experimental) public WebSocketApi(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable WebSocketApiProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • WebSocketApi

      @Stability(Experimental) public WebSocketApi(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • fromWebSocketApiAttributes

      @Stability(Experimental) @NotNull public static IWebSocketApi fromWebSocketApiAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull WebSocketApiAttributes attrs)
      (experimental) Import an existing WebSocket API into this CDK app.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addRoute

      @Stability(Experimental) @NotNull public WebSocketRoute addRoute(@NotNull String routeKey, @NotNull WebSocketRouteOptions options)
      (experimental) Add a new route.

      Parameters:
      routeKey - This parameter is required.
      options - This parameter is required.
    • grantManageConnections

      @Stability(Experimental) @NotNull public Grant grantManageConnections(@NotNull IGrantable identity)
      (experimental) Grant access to the API Gateway management API for this WebSocket API to an IAM principal (Role/Group/User).

      Parameters:
      identity - The principal. This parameter is required.
    • metric

      @Stability(Experimental) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      (experimental) Return the given named metric for this Api Gateway.

      Specified by:
      metric in interface IApi
      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Experimental) @NotNull public Metric metric(@NotNull String metricName)
      (experimental) Return the given named metric for this Api Gateway.

      Specified by:
      metric in interface IApi
      Parameters:
      metricName - This parameter is required.
    • getApiEndpoint

      @Stability(Experimental) @NotNull public String getApiEndpoint()
      (experimental) The default endpoint for an API.
      Specified by:
      getApiEndpoint in interface IApi
    • getApiId

      @Stability(Experimental) @NotNull public String getApiId()
      (experimental) The identifier of this API Gateway API.
      Specified by:
      getApiId in interface IApi
    • getWebSocketApiName

      @Stability(Experimental) @Nullable public String getWebSocketApiName()
      (experimental) A human friendly name for this WebSocket API.

      Note that this is different from webSocketApiId.