feat: add API Gateway route testing and discovery

This commit is contained in:
Zakaria
2026-09-24 08:56:22 -04:00
parent 7e49be27f1
commit 9bbe80b5f2
10 changed files with 802 additions and 6 deletions
+19 -1
View File
@@ -24,7 +24,9 @@ export const apiEndpointKeys = {
invoke: "clouds.services.resources.invoke",
encrypt: "clouds.services.resources.encrypt",
decrypt: "clouds.services.resources.decrypt",
createApiGatewayRoute: "clouds.services.resources.apigateway.route.create",
createApiGatewayRoute: "clouds.services.resources.apigateway.route.create",
listApiGatewayRoutes: "clouds.services.resources.apigateway.routes.list",
testApiGatewayRoute: "clouds.services.resources.apigateway.route.test",
},
storage: {
objects: {
@@ -300,6 +302,22 @@ export const endpointRegistry: EndpointRegistry = new Map([
telemetry: { service: "apigateway" },
},
],
[
apiEndpointKeys.clouds.resources.listApiGatewayRoutes,
{
path: "/clouds/:cloud/services/apigateway/resources/:id/routes",
method: "GET",
telemetry: { service: "apigateway" },
},
],
[
apiEndpointKeys.clouds.resources.testApiGatewayRoute,
{
path: "/clouds/:cloud/services/apigateway/resources/:id/routes/test",
method: "POST",
telemetry: { service: "apigateway" },
},
],
[
apiEndpointKeys.clouds.resources.get,
{
@@ -217,6 +217,34 @@ export interface ApiGatewayLambdaRoute {
invokeUrl: string;
}
export interface TestApiGatewayRouteInput {
path: string;
method: string;
stage: string;
body: string;
headers: Record<string, string>;
query: string;
}
export interface ApiGatewayTestRouteResult {
statusCode: number;
headers: Record<string, string>;
body: string;
durationMs: number;
}
export interface ApiGatewayRouteOverview {
resourceId: string;
path: string;
method: string;
functionName: string | null;
}
export interface ApiGatewayRoutesResult {
routes: ApiGatewayRouteOverview[];
stages: string[];
}
export async function createApiGatewayLambdaRoute(
cloud: CloudProvider,
apiId: string,
@@ -231,6 +259,33 @@ export async function createApiGatewayLambdaRoute(
return res.data;
}
export async function listApiGatewayRoutes(
cloud: CloudProvider,
apiId: string,
signal?: AbortSignal,
): Promise<ApiGatewayRoutesResult> {
const res = await apiClient.call<ApiGatewayRoutesResult>(
apiEndpointKeys.clouds.resources.listApiGatewayRoutes,
requestOptions(cloud, "apigateway", { signal }),
{ cloud, id: apiId },
);
return res.data;
}
export async function testApiGatewayRoute(
cloud: CloudProvider,
apiId: string,
input: TestApiGatewayRouteInput,
signal?: AbortSignal,
): Promise<ApiGatewayTestRouteResult> {
const res = await apiClient.call<ApiGatewayTestRouteResult, TestApiGatewayRouteInput>(
apiEndpointKeys.clouds.resources.testApiGatewayRoute,
requestOptions(cloud, "apigateway", { signal, body: input, timeout: INVOKE_TIMEOUT_MS }),
{ cloud, id: apiId },
);
return res.data;
}
export type KmsEncryptionAlgorithm =
| "SYMMETRIC_DEFAULT"
| "RSAES_OAEP_SHA_1"