Skip to content

Commit

Permalink
feat: move top-level serde functions into command file (#419)
Browse files Browse the repository at this point in the history
* feat: move serde into command
  • Loading branch information
Chase Coalwell authored Oct 24, 2019
1 parent 29c76a1 commit dc95c81
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 45 deletions.
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.

0 comments on commit dc95c81

Please sign in to comment.