Skip to content

Commit

Permalink
feat(codegen): use object mapper to assign fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jul 27, 2022
1 parent c5fe1fa commit 800e8e9
Show file tree
Hide file tree
Showing 332 changed files with 136,992 additions and 228,493 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -43,6 +43,7 @@ dist
dist-*

/verdaccio/*
/storage/.verdaccio-db.json
!/verdaccio/config.yaml

*.tsbuildinfo
Expand Down
1,144 changes: 469 additions & 675 deletions clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

144 changes: 65 additions & 79 deletions clients/client-account/src/protocols/Aws_restJson1.ts
Expand Up @@ -5,6 +5,8 @@ import {
expectNonNull as __expectNonNull,
expectObject as __expectObject,
expectString as __expectString,
map as __map,
throwDefaultError,
} from "@aws-sdk/smithy-client";
import {
Endpoint as __Endpoint,
Expand Down Expand Up @@ -48,9 +50,9 @@ export const serializeAws_restJson1DeleteAlternateContactCommand = async (
context: __SerdeContext
): Promise<__HttpRequest> => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const headers: any = {
const headers: any = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
};
});
const resolvedPath =
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/deleteAlternateContact";
let body: any;
Expand All @@ -74,9 +76,9 @@ export const serializeAws_restJson1GetAlternateContactCommand = async (
context: __SerdeContext
): Promise<__HttpRequest> => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const headers: any = {
const headers: any = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
};
});
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/getAlternateContact";
let body: any;
body = JSON.stringify({
Expand All @@ -99,9 +101,9 @@ export const serializeAws_restJson1GetContactInformationCommand = async (
context: __SerdeContext
): Promise<__HttpRequest> => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const headers: any = {
const headers: any = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
};
});
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/getContactInformation";
let body: any;
body = JSON.stringify({
Expand All @@ -123,9 +125,9 @@ export const serializeAws_restJson1PutAlternateContactCommand = async (
context: __SerdeContext
): Promise<__HttpRequest> => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const headers: any = {
const headers: any = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
};
});
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/putAlternateContact";
let body: any;
body = JSON.stringify({
Expand All @@ -152,9 +154,9 @@ export const serializeAws_restJson1PutContactInformationCommand = async (
context: __SerdeContext
): Promise<__HttpRequest> => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const headers: any = {
const headers: any = map({}, isSerializableHeaderValue, {
"content-type": "application/json",
};
});
const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/putContactInformation";
let body: any;
body = JSON.stringify({
Expand All @@ -181,11 +183,11 @@ export const deserializeAws_restJson1DeleteAlternateContactCommand = async (
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restJson1DeleteAlternateContactCommandError(output, context);
}
const contents: DeleteAlternateContactCommandOutput = {
const contents: any = map({
$metadata: deserializeMetadata(output),
};
});
await collectBody(output.body, context);
return Promise.resolve(contents);
return contents;
};

const deserializeAws_restJson1DeleteAlternateContactCommandError = async (
Expand All @@ -196,7 +198,6 @@ const deserializeAws_restJson1DeleteAlternateContactCommandError = async (
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
Expand All @@ -216,14 +217,12 @@ const deserializeAws_restJson1DeleteAlternateContactCommandError = async (
throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
throwDefaultError({
output,
parsedBody,
exceptionCtor: __BaseException,
errorCode,
});
throw __decorateServiceException(response, parsedBody);
}
};

Expand All @@ -234,15 +233,14 @@ export const deserializeAws_restJson1GetAlternateContactCommand = async (
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restJson1GetAlternateContactCommandError(output, context);
}
const contents: GetAlternateContactCommandOutput = {
const contents: any = map({
$metadata: deserializeMetadata(output),
AlternateContact: undefined,
};
});
const data: Record<string, any> = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
if (data.AlternateContact !== undefined && data.AlternateContact !== null) {
if (data.AlternateContact != null) {
contents.AlternateContact = deserializeAws_restJson1AlternateContact(data.AlternateContact, context);
}
return Promise.resolve(contents);
return contents;
};

const deserializeAws_restJson1GetAlternateContactCommandError = async (
Expand All @@ -253,7 +251,6 @@ const deserializeAws_restJson1GetAlternateContactCommandError = async (
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
Expand All @@ -273,14 +270,12 @@ const deserializeAws_restJson1GetAlternateContactCommandError = async (
throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
throwDefaultError({
output,
parsedBody,
exceptionCtor: __BaseException,
errorCode,
});
throw __decorateServiceException(response, parsedBody);
}
};

Expand All @@ -291,15 +286,14 @@ export const deserializeAws_restJson1GetContactInformationCommand = async (
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restJson1GetContactInformationCommandError(output, context);
}
const contents: GetContactInformationCommandOutput = {
const contents: any = map({
$metadata: deserializeMetadata(output),
ContactInformation: undefined,
};
});
const data: Record<string, any> = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
if (data.ContactInformation !== undefined && data.ContactInformation !== null) {
if (data.ContactInformation != null) {
contents.ContactInformation = deserializeAws_restJson1ContactInformation(data.ContactInformation, context);
}
return Promise.resolve(contents);
return contents;
};

const deserializeAws_restJson1GetContactInformationCommandError = async (
Expand All @@ -310,7 +304,6 @@ const deserializeAws_restJson1GetContactInformationCommandError = async (
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
Expand All @@ -330,14 +323,12 @@ const deserializeAws_restJson1GetContactInformationCommandError = async (
throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
throwDefaultError({
output,
parsedBody,
exceptionCtor: __BaseException,
errorCode,
});
throw __decorateServiceException(response, parsedBody);
}
};

Expand All @@ -348,11 +339,11 @@ export const deserializeAws_restJson1PutAlternateContactCommand = async (
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restJson1PutAlternateContactCommandError(output, context);
}
const contents: PutAlternateContactCommandOutput = {
const contents: any = map({
$metadata: deserializeMetadata(output),
};
});
await collectBody(output.body, context);
return Promise.resolve(contents);
return contents;
};

const deserializeAws_restJson1PutAlternateContactCommandError = async (
Expand All @@ -363,7 +354,6 @@ const deserializeAws_restJson1PutAlternateContactCommandError = async (
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
Expand All @@ -380,14 +370,12 @@ const deserializeAws_restJson1PutAlternateContactCommandError = async (
throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
throwDefaultError({
output,
parsedBody,
exceptionCtor: __BaseException,
errorCode,
});
throw __decorateServiceException(response, parsedBody);
}
};

Expand All @@ -398,11 +386,11 @@ export const deserializeAws_restJson1PutContactInformationCommand = async (
if (output.statusCode !== 200 && output.statusCode >= 300) {
return deserializeAws_restJson1PutContactInformationCommandError(output, context);
}
const contents: PutContactInformationCommandOutput = {
const contents: any = map({
$metadata: deserializeMetadata(output),
};
});
await collectBody(output.body, context);
return Promise.resolve(contents);
return contents;
};

const deserializeAws_restJson1PutContactInformationCommandError = async (
Expand All @@ -413,7 +401,6 @@ const deserializeAws_restJson1PutContactInformationCommandError = async (
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedException":
Expand All @@ -430,24 +417,23 @@ const deserializeAws_restJson1PutContactInformationCommandError = async (
throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
throwDefaultError({
output,
parsedBody,
exceptionCtor: __BaseException,
errorCode,
});
throw __decorateServiceException(response, parsedBody);
}
};

const map = __map;
const deserializeAws_restJson1AccessDeniedExceptionResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<AccessDeniedException> => {
const contents: any = {};
const contents: any = map({});
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
if (data.message != null) {
contents.message = __expectString(data.message);
}
const exception = new AccessDeniedException({
Expand All @@ -461,9 +447,9 @@ const deserializeAws_restJson1InternalServerExceptionResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<InternalServerException> => {
const contents: any = {};
const contents: any = map({});
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
if (data.message != null) {
contents.message = __expectString(data.message);
}
const exception = new InternalServerException({
Expand All @@ -477,9 +463,9 @@ const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<ResourceNotFoundException> => {
const contents: any = {};
const contents: any = map({});
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
if (data.message != null) {
contents.message = __expectString(data.message);
}
const exception = new ResourceNotFoundException({
Expand All @@ -493,9 +479,9 @@ const deserializeAws_restJson1TooManyRequestsExceptionResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<TooManyRequestsException> => {
const contents: any = {};
const contents: any = map({});
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
if (data.message != null) {
contents.message = __expectString(data.message);
}
const exception = new TooManyRequestsException({
Expand All @@ -509,9 +495,9 @@ const deserializeAws_restJson1ValidationExceptionResponse = async (
parsedOutput: any,
context: __SerdeContext
): Promise<ValidationException> => {
const contents: any = {};
const contents: any = map({});
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
if (data.message != null) {
contents.message = __expectString(data.message);
}
const exception = new ValidationException({
Expand Down

0 comments on commit 800e8e9

Please sign in to comment.