Skip to content

Commit

Permalink
feat: add serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Coalwell authored and trivikr committed Jan 3, 2020
1 parent 14728d2 commit e29478b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Field, SqlParameter } from "../models/com/amazon/rdsdataservice";

export function SqlParameterListAwsRestJson1_1Serialize(
input: Array<SqlParameter>
): Array<SqlParameter> {
let list: Array<SqlParameter> = [];
for (let SqlParameter of input) {
list.push(SqlParameterAwsRestJson1_1Serialize(SqlParameter));
}
return list;
}

export function SqlParameterAwsRestJson1_1Serialize(input: SqlParameter): any {
return {
name: input.name,
value: FieldAwsRestJson1_1Serialize(input.value)
};
}

export function FieldAwsRestJson1_1Serialize(input: Field): any {
return input.visit(input, {});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { HttpRequest } from "@aws-sdk/types";
import { ExecuteStatementRequest } from "../models/com/amazon/rdsdataservice";
import { SqlParameterListAwsRestJson1_1Serialize } from "./AwsRestJson1_1Serializers";

export function ExecuteStatementSerializer(
input: ExecuteStatementRequest,
protocol: string
): HttpRequest {
switch (protocol) {
case "aws.rest-json-1.1":
return ExecuteStatementAwsRestJson1_1Serialize(input);
default:
throw new Error("Unknown protocol, use aws.rest-json-1.1");
}
}

function ExecuteStatementAwsRestJson1_1Serialize(
input: ExecuteStatementRequest
): HttpRequest {
let body: any = {};
if (input.resourceArn) {
body.resourceArn = input.resourceArn;
}

if (input.secretArn) {
body.secretArn = input.secretArn;
}

if (input.sql) {
body.sql = input.sql;
}

if (input.database) {
body.database = input.database;
}

if (input.schema) {
body.schema = input.schema;
}

if (input.parameters) {
body.parameters = SqlParameterListAwsRestJson1_1Serialize(input.parameters);
}

if (input.transactionId) {
body.transactionId = input.transactionId;
}

if (input.includeResultMetadata) {
body.includeResultMetadata = input.includeResultMetadata;
}

if (input.continueAfterTimeout) {
body.continueAfterTimeout = input.continueAfterTimeout;
}

return {
method: "POST",
hostname: "rdsdataservice.us-east-1.amazonaws.com",
path: "/execute",
protocol: "https:",
body: JSON.stringify(body),
headers: {
"Content-Type": "application/json"
}
};
}

0 comments on commit e29478b

Please sign in to comment.