Skip to content

Commit 92f290b

Browse files
Chase Coalwelltrivikr
Chase Coalwell
authored andcommitted
feat: move top-level serde functions into command file (#419)
* feat: move serde into command
1 parent 9c61c4a commit 92f290b

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed

Diff for: clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts

+33-12
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {
55
Handler,
66
HandlerExecutionContext,
77
FinalizeHandlerArguments,
8-
MiddlewareStack
8+
MiddlewareStack,
9+
SerdeContext
910
} from "@aws-sdk/types";
1011
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
11-
import { HttpRequest } from "@aws-sdk/protocol-http";
12+
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
1213
import {
13-
executeStatementSerializer,
14-
executeStatementDeserializer
15-
} from "../protocol/ExecuteStatement";
14+
executeStatementAwsRestJson1_1Serialize,
15+
executeStatementAwsRestJson1_1Deserialize
16+
} from "../protocol/AwsRestJson1_1";
1617
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";
1718

1819
type InputTypesUnion = any;
@@ -35,13 +36,7 @@ export class ExecuteStatementCommand extends Command<
3536
protocol: { handler }
3637
} = configuration;
3738

38-
this.use(
39-
serdePlugin(
40-
configuration,
41-
executeStatementSerializer,
42-
executeStatementDeserializer
43-
)
44-
);
39+
this.use(serdePlugin(configuration, this.serialize, this.deserialize));
4540

4641
const stack = clientStack.concat(this.middlewareStack);
4742

@@ -55,4 +50,30 @@ export class ExecuteStatementCommand extends Command<
5550
handlerExecutionContext
5651
);
5752
}
53+
54+
private serialize(
55+
input: ExecuteStatementRequest,
56+
protocol: string,
57+
context: SerdeContext
58+
): HttpRequest {
59+
switch (protocol) {
60+
case "aws.rest-json-1.1":
61+
return executeStatementAwsRestJson1_1Serialize(input, context);
62+
default:
63+
throw new Error("Unknown protocol, use aws.rest-json-1.1");
64+
}
65+
}
66+
67+
private async deserialize(
68+
output: HttpResponse,
69+
protocol: string,
70+
context: SerdeContext
71+
): Promise<ExecuteStatementResponse> {
72+
switch (protocol) {
73+
case "aws.rest-json-1.1":
74+
return executeStatementAwsRestJson1_1Deserialize(output, context);
75+
default:
76+
throw new Error("Unknown protocol, use aws.rest-json-1.1");
77+
}
78+
}
5879
}

Diff for: clients/node/client-rds-data-node/protocol/ExecuteStatement.ts

-33
This file was deleted.

0 commit comments

Comments
 (0)