adding a real test Method for API gateway

This commit is contained in:
Zakaria
2026-09-27 20:14:59 -04:00
parent e8843a462b
commit ce8400757c
10 changed files with 321 additions and 23 deletions
+10 -1
View File
@@ -33,7 +33,8 @@ export const apiEndpointKeys = {
listApiGatewayRoutes: "clouds.services.resources.apigateway.routes.list",
deleteApiGatewayRoute: "clouds.services.resources.apigateway.route.delete",
enableApiGatewayCors: "clouds.services.resources.apigateway.cors.enable",
testApiGatewayRoute: "clouds.services.resources.apigateway.route.test",
testApiGatewayRoute: "clouds.services.resources.apigateway.route.test",
testApiGatewayMethod: "clouds.services.resources.apigateway.method.test",
createS3LambdaTrigger: "clouds.services.resources.storage.lambda-trigger.create",
listS3LambdaTriggers: "clouds.services.resources.storage.lambda-triggers.list",
deleteS3LambdaTrigger: "clouds.services.resources.storage.lambda-trigger.delete",
@@ -393,6 +394,14 @@ export const endpointRegistry: EndpointRegistry = new Map([
telemetry: { service: "apigateway" },
},
],
[
apiEndpointKeys.clouds.resources.testApiGatewayMethod,
{
path: "/clouds/:cloud/services/apigateway/resources/:id/methods/test",
method: "POST",
telemetry: { service: "apigateway" },
},
],
[
apiEndpointKeys.clouds.resources.enableApiGatewayCors,
{
@@ -263,6 +263,25 @@ export interface ApiGatewayTestRouteResult {
durationMs: number;
}
export interface TestApiGatewayMethodInput {
resourceId: string;
httpMethod: string;
pathWithQueryString: string;
body: string;
headers: Record<string, string>;
multiValueHeaders: Record<string, string[]>;
stageVariables: Record<string, string>;
}
export interface ApiGatewayMethodTestResult {
statusCode: number;
body: string;
headers: Record<string, string>;
multiValueHeaders: Record<string, string[]>;
log: string | null;
latency: number | null;
}
export interface ApiGatewayRouteOverview {
resourceId: string;
path: string;
@@ -445,6 +464,20 @@ export async function testApiGatewayRoute(
return res.data;
}
export async function testApiGatewayMethod(
cloud: CloudProvider,
apiId: string,
input: TestApiGatewayMethodInput,
signal?: AbortSignal,
): Promise<ApiGatewayMethodTestResult> {
const res = await apiClient.call<ApiGatewayMethodTestResult, TestApiGatewayMethodInput>(
apiEndpointKeys.clouds.resources.testApiGatewayMethod,
requestOptions(cloud, "apigateway", { signal, body: input, timeout: INVOKE_TIMEOUT_MS }),
{ cloud, id: apiId },
);
return res.data;
}
export async function createS3LambdaTrigger(
cloud: CloudProvider,
bucketName: string,