feat(api): add HTTP and WebSocket APIs (API Gateway v2) to the API Gateway page
CI / checks (pull_request) Successful in 26m49s
CI / checks (pull_request) Successful in 26m49s
API Gateway v2 is a separate AWS API from REST APIs, so HTTP and WebSocket APIs made with the SDK, SAM, CDK or Terraform never showed up. The API Gateway page now lists all three kinds with a Type column, creates each from the same form, and opens HTTP and WebSocket APIs in their own panel: - Quick create: an HTTP API with a Lambda gets a catch-all route on an auto-deployed $default stage, plus the Lambda permission. - Routes to Lambda (payload 2.0) or HTTP backends; deleting a route removes the integration and Lambda permission only it used. - Stages with or without automatic deployment, and deploy on demand. - JWT authorizers filled in from a Cognito pool's OpenID Connect discovery document and an app client, or from any issuer; protect routes with them. - CORS configuration. - A tester that sends a real request to a stage, and for WebSocket APIs one that connects, sends a message and collects the replies. Capabilities are advertised under a new httpApiActions group, covered by the cloudProxy guard test. Verified end to end against TheCloud's runtime.
This commit is contained in:
@@ -1546,6 +1546,139 @@ export async function setAlarmActionsEnabled(
|
||||
);
|
||||
}
|
||||
|
||||
export type HttpApiProtocol = "HTTP" | "WEBSOCKET";
|
||||
|
||||
export interface HttpApiIntegrationOverview {
|
||||
integrationId: string;
|
||||
type: string;
|
||||
uri: string | null;
|
||||
functionName: string | null;
|
||||
payloadFormatVersion: string | null;
|
||||
}
|
||||
|
||||
export interface HttpApiRouteOverview {
|
||||
routeId: string;
|
||||
routeKey: string;
|
||||
integration: HttpApiIntegrationOverview | null;
|
||||
authorizationType: string;
|
||||
authorizerId: string | null;
|
||||
authorizationScopes: string[];
|
||||
returnsResponse: boolean;
|
||||
}
|
||||
|
||||
export interface HttpApiStageOverview {
|
||||
stageName: string;
|
||||
autoDeploy: boolean;
|
||||
deploymentId: string | null;
|
||||
lastUpdatedAt: string | null;
|
||||
invokePath: string;
|
||||
}
|
||||
|
||||
export interface HttpApiAuthorizerOverview {
|
||||
authorizerId: string;
|
||||
name: string;
|
||||
type: string;
|
||||
identitySource: string[];
|
||||
issuer: string | null;
|
||||
audience: string[];
|
||||
}
|
||||
|
||||
export interface HttpApiCors {
|
||||
allowOrigins: string[];
|
||||
allowMethods: string[];
|
||||
allowHeaders: string[];
|
||||
exposeHeaders: string[];
|
||||
maxAgeSeconds: number | null;
|
||||
allowCredentials: boolean;
|
||||
}
|
||||
|
||||
export interface HttpApiOverview {
|
||||
apiId: string;
|
||||
protocol: HttpApiProtocol;
|
||||
apiEndpoint: string | null;
|
||||
routeSelectionExpression: string | null;
|
||||
routes: HttpApiRouteOverview[];
|
||||
stages: HttpApiStageOverview[];
|
||||
authorizers: HttpApiAuthorizerOverview[];
|
||||
cors: HttpApiCors | null;
|
||||
}
|
||||
|
||||
export interface HttpApiRouteInput {
|
||||
routeKey: string;
|
||||
functionName?: string;
|
||||
httpUrl?: string;
|
||||
authorizerId?: string;
|
||||
returnsResponse?: boolean;
|
||||
}
|
||||
|
||||
export interface HttpApiAuthorizerInput {
|
||||
name: string;
|
||||
userPoolId?: string;
|
||||
userPoolClientId?: string;
|
||||
issuer?: string;
|
||||
audience?: string[];
|
||||
}
|
||||
|
||||
export interface HttpApiWebSocketTestResult {
|
||||
connected: boolean;
|
||||
messages: string[];
|
||||
closeCode: number | null;
|
||||
error: string | null;
|
||||
durationMs: number;
|
||||
}
|
||||
|
||||
export async function describeHttpApi(cloud: CloudProvider, apiId: string, signal?: AbortSignal): Promise<HttpApiOverview> {
|
||||
const res = await apiClient.call<HttpApiOverview>(apiEndpointKeys.clouds.httpApi.describe, requestOptions(cloud, "apigateway", { signal }), { cloud, id: apiId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function createHttpApiRoute(cloud: CloudProvider, apiId: string, input: HttpApiRouteInput): Promise<HttpApiRouteOverview> {
|
||||
const res = await apiClient.call<HttpApiRouteOverview, HttpApiRouteInput>(apiEndpointKeys.clouds.httpApi.createRoute, requestOptions(cloud, "apigateway", { body: input }), { cloud, id: apiId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function deleteHttpApiRoute(cloud: CloudProvider, apiId: string, routeId: string): Promise<void> {
|
||||
await apiClient.call<void>(apiEndpointKeys.clouds.httpApi.deleteRoute, requestOptions(cloud, "apigateway"), { cloud, id: apiId, routeId });
|
||||
}
|
||||
|
||||
export async function setHttpApiRouteAuthorizer(cloud: CloudProvider, apiId: string, routeId: string, authorizerId: string | null): Promise<HttpApiRouteOverview> {
|
||||
const res = await apiClient.call<HttpApiRouteOverview, { authorizerId: string | null }>(apiEndpointKeys.clouds.httpApi.setRouteAuthorizer, requestOptions(cloud, "apigateway", { body: { authorizerId } }), { cloud, id: apiId, routeId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function createHttpApiStage(cloud: CloudProvider, apiId: string, input: { stageName: string; autoDeploy: boolean }): Promise<HttpApiStageOverview> {
|
||||
const res = await apiClient.call<HttpApiStageOverview, typeof input>(apiEndpointKeys.clouds.httpApi.createStage, requestOptions(cloud, "apigateway", { body: input }), { cloud, id: apiId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function deleteHttpApiStage(cloud: CloudProvider, apiId: string, stageName: string): Promise<void> {
|
||||
await apiClient.call<void>(apiEndpointKeys.clouds.httpApi.deleteStage, requestOptions(cloud, "apigateway"), { cloud, id: apiId, stageName });
|
||||
}
|
||||
|
||||
export async function deployHttpApi(cloud: CloudProvider, apiId: string, stageName: string): Promise<HttpApiStageOverview> {
|
||||
const res = await apiClient.call<HttpApiStageOverview>(apiEndpointKeys.clouds.httpApi.deploy, requestOptions(cloud, "apigateway"), { cloud, id: apiId, stageName });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function createHttpApiAuthorizer(cloud: CloudProvider, apiId: string, input: HttpApiAuthorizerInput): Promise<HttpApiAuthorizerOverview> {
|
||||
const res = await apiClient.call<HttpApiAuthorizerOverview, HttpApiAuthorizerInput>(apiEndpointKeys.clouds.httpApi.createAuthorizer, requestOptions(cloud, "apigateway", { body: input }), { cloud, id: apiId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function deleteHttpApiAuthorizer(cloud: CloudProvider, apiId: string, authorizerId: string): Promise<void> {
|
||||
await apiClient.call<void>(apiEndpointKeys.clouds.httpApi.deleteAuthorizer, requestOptions(cloud, "apigateway"), { cloud, id: apiId, authorizerId });
|
||||
}
|
||||
|
||||
export async function updateHttpApiCors(cloud: CloudProvider, apiId: string, cors: HttpApiCors | null): Promise<HttpApiCors | null> {
|
||||
const res = await apiClient.call<{ cors: HttpApiCors | null }, { cors: HttpApiCors | null }>(apiEndpointKeys.clouds.httpApi.cors, requestOptions(cloud, "apigateway", { body: { cors } }), { cloud, id: apiId });
|
||||
return res.data.cors;
|
||||
}
|
||||
|
||||
export async function testWebSocketApi(cloud: CloudProvider, apiId: string, input: { stage: string; message: string; query?: string }): Promise<HttpApiWebSocketTestResult> {
|
||||
const res = await apiClient.call<HttpApiWebSocketTestResult, typeof input>(apiEndpointKeys.clouds.httpApi.webSocketTest, requestOptions(cloud, "apigateway", { body: input }), { cloud, id: apiId });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function setDistributionEnabled(
|
||||
cloud: CloudProvider,
|
||||
distributionId: string,
|
||||
|
||||
Reference in New Issue
Block a user