-
Notifications
You must be signed in to change notification settings - Fork 585
/
ExecuteStatementCommand.ts
83 lines (75 loc) · 2.32 KB
/
ExecuteStatementCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Command } from "@aws-sdk/smithy-client";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import {
HttpOptions,
Handler,
HandlerExecutionContext,
FinalizeHandlerArguments,
MiddlewareStack,
SerdeContext
} from "@aws-sdk/types";
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import {
executeStatementAwsRestJson1_1Serialize,
executeStatementAwsRestJson1_1Deserialize
} from "../protocol/AwsRestJson1_1";
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";
import {
ServiceInputTypes,
ServiceOutputTypes,
RdsDataServiceResolvedConfig
} from "../RdsDataServiceClient";
export class ExecuteStatementCommand extends Command<
ServiceInputTypes,
ExecuteStatementRequest,
ServiceOutputTypes,
ExecuteStatementResponse,
RdsDataServiceResolvedConfig
> {
constructor(readonly input: ExecuteStatementRequest) {
super();
}
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: RdsDataServiceResolvedConfig,
options?: HttpOptions
): Handler<ExecuteStatementRequest, ExecuteStatementResponse> {
const { requestHandler } = configuration;
this.middlewareStack.use(
getSerdePlugin(configuration, this.serialize, this.deserialize)
);
const stack = clientStack.concat(this.middlewareStack);
const handlerExecutionContext: HandlerExecutionContext = {
logger: {} as any
};
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(
input: ExecuteStatementRequest,
protocol: string,
context: SerdeContext
): HttpRequest {
switch (protocol) {
case "aws.rest-json-1.1":
return executeStatementAwsRestJson1_1Serialize(input, context);
default:
throw new Error("Unknown protocol, use aws.rest-json-1.1");
}
}
private async deserialize(
output: HttpResponse,
protocol: string,
context: SerdeContext
): Promise<ExecuteStatementResponse> {
switch (protocol) {
case "aws.rest-json-1.1":
return executeStatementAwsRestJson1_1Deserialize(output, context);
default:
throw new Error("Unknown protocol, use aws.rest-json-1.1");
}
}
}