Skip to content

feat: move top-level serde functions into command file #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
Handler,
HandlerExecutionContext,
FinalizeHandlerArguments,
MiddlewareStack
MiddlewareStack,
SerdeContext
} from "@aws-sdk/types";
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import {
executeStatementSerializer,
executeStatementDeserializer
} from "../protocol/ExecuteStatement";
executeStatementAwsRestJson1_1Serialize,
executeStatementAwsRestJson1_1Deserialize
} from "../protocol/AwsRestJson1_1";
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";

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

this.use(
serdePlugin(
configuration,
executeStatementSerializer,
executeStatementDeserializer
)
);
this.use(serdePlugin(configuration, this.serialize, this.deserialize));

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

Expand All @@ -55,4 +50,30 @@ export class ExecuteStatementCommand extends Command<
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");
}
}
}
33 changes: 0 additions & 33 deletions clients/node/client-rds-data-node/protocol/ExecuteStatement.ts

This file was deleted.