Skip to content

Commit 304ca3e

Browse files
authored
chore(codegen): use lib serde helpers instead of codegen (#5855)
* chore(codegen): use lib serde helpers instead of codegen * feat: write error.$responseBodyText if available * chore: codegen update to use imported serde helper functions * chore: unused imports
1 parent 6d98191 commit 304ca3e

File tree

419 files changed

+811
-19675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

419 files changed

+811
-19675
lines changed

clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// smithy-typescript generated code
2-
import { awsExpectUnion as __expectUnion } from "@aws-sdk/core";
2+
import {
3+
awsExpectUnion as __expectUnion,
4+
loadRestJsonErrorCode,
5+
parseJsonBody as parseBody,
6+
parseJsonErrorBody as parseErrorBody,
7+
} from "@aws-sdk/core";
38
import { requestBuilder as rb } from "@smithy/core";
49
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
510
import {
@@ -2452,54 +2457,3 @@ const _rAS = "retryAfterSeconds";
24522457
const _ra = "retry-after";
24532458
const _t = "type";
24542459
const _tK = "tagKeys";
2455-
2456-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
2457-
collectBodyString(streamBody, context).then((encoded) => {
2458-
if (encoded.length) {
2459-
return JSON.parse(encoded);
2460-
}
2461-
return {};
2462-
});
2463-
2464-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
2465-
const value = await parseBody(errorBody, context);
2466-
value.message = value.message ?? value.Message;
2467-
return value;
2468-
};
2469-
2470-
/**
2471-
* Load an error code for the aws.rest-json-1.1 protocol.
2472-
*/
2473-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
2474-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
2475-
2476-
const sanitizeErrorCode = (rawValue: string | number): string => {
2477-
let cleanValue = rawValue;
2478-
if (typeof cleanValue === "number") {
2479-
cleanValue = cleanValue.toString();
2480-
}
2481-
if (cleanValue.indexOf(",") >= 0) {
2482-
cleanValue = cleanValue.split(",")[0];
2483-
}
2484-
if (cleanValue.indexOf(":") >= 0) {
2485-
cleanValue = cleanValue.split(":")[0];
2486-
}
2487-
if (cleanValue.indexOf("#") >= 0) {
2488-
cleanValue = cleanValue.split("#")[1];
2489-
}
2490-
return cleanValue;
2491-
};
2492-
2493-
const headerKey = findKey(output.headers, "x-amzn-errortype");
2494-
if (headerKey !== undefined) {
2495-
return sanitizeErrorCode(output.headers[headerKey]);
2496-
}
2497-
2498-
if (data.code !== undefined) {
2499-
return sanitizeErrorCode(data.code);
2500-
}
2501-
2502-
if (data["__type"] !== undefined) {
2503-
return sanitizeErrorCode(data["__type"]);
2504-
}
2505-
};

clients/client-account/src/protocols/Aws_restJson1.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
23
import { requestBuilder as rb } from "@smithy/core";
34
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
45
import {
@@ -626,54 +627,3 @@ const isSerializableHeaderValue = (value: any): boolean =>
626627
value !== "" &&
627628
(!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
628629
(!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
629-
630-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
631-
collectBodyString(streamBody, context).then((encoded) => {
632-
if (encoded.length) {
633-
return JSON.parse(encoded);
634-
}
635-
return {};
636-
});
637-
638-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
639-
const value = await parseBody(errorBody, context);
640-
value.message = value.message ?? value.Message;
641-
return value;
642-
};
643-
644-
/**
645-
* Load an error code for the aws.rest-json-1.1 protocol.
646-
*/
647-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
648-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
649-
650-
const sanitizeErrorCode = (rawValue: string | number): string => {
651-
let cleanValue = rawValue;
652-
if (typeof cleanValue === "number") {
653-
cleanValue = cleanValue.toString();
654-
}
655-
if (cleanValue.indexOf(",") >= 0) {
656-
cleanValue = cleanValue.split(",")[0];
657-
}
658-
if (cleanValue.indexOf(":") >= 0) {
659-
cleanValue = cleanValue.split(":")[0];
660-
}
661-
if (cleanValue.indexOf("#") >= 0) {
662-
cleanValue = cleanValue.split("#")[1];
663-
}
664-
return cleanValue;
665-
};
666-
667-
const headerKey = findKey(output.headers, "x-amzn-errortype");
668-
if (headerKey !== undefined) {
669-
return sanitizeErrorCode(output.headers[headerKey]);
670-
}
671-
672-
if (data.code !== undefined) {
673-
return sanitizeErrorCode(data.code);
674-
}
675-
676-
if (data["__type"] !== undefined) {
677-
return sanitizeErrorCode(data["__type"]);
678-
}
679-
};

clients/client-acm-pca/src/protocols/Aws_json1_1.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
23
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
34
import {
45
_json,
@@ -1639,54 +1640,3 @@ function sharedHeaders(operation: string): __HeaderBag {
16391640
"x-amz-target": `ACMPrivateCA.${operation}`,
16401641
};
16411642
}
1642-
1643-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
1644-
collectBodyString(streamBody, context).then((encoded) => {
1645-
if (encoded.length) {
1646-
return JSON.parse(encoded);
1647-
}
1648-
return {};
1649-
});
1650-
1651-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
1652-
const value = await parseBody(errorBody, context);
1653-
value.message = value.message ?? value.Message;
1654-
return value;
1655-
};
1656-
1657-
/**
1658-
* Load an error code for the aws.rest-json-1.1 protocol.
1659-
*/
1660-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1661-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
1662-
1663-
const sanitizeErrorCode = (rawValue: string | number): string => {
1664-
let cleanValue = rawValue;
1665-
if (typeof cleanValue === "number") {
1666-
cleanValue = cleanValue.toString();
1667-
}
1668-
if (cleanValue.indexOf(",") >= 0) {
1669-
cleanValue = cleanValue.split(",")[0];
1670-
}
1671-
if (cleanValue.indexOf(":") >= 0) {
1672-
cleanValue = cleanValue.split(":")[0];
1673-
}
1674-
if (cleanValue.indexOf("#") >= 0) {
1675-
cleanValue = cleanValue.split("#")[1];
1676-
}
1677-
return cleanValue;
1678-
};
1679-
1680-
const headerKey = findKey(output.headers, "x-amzn-errortype");
1681-
if (headerKey !== undefined) {
1682-
return sanitizeErrorCode(output.headers[headerKey]);
1683-
}
1684-
1685-
if (data.code !== undefined) {
1686-
return sanitizeErrorCode(data.code);
1687-
}
1688-
1689-
if (data["__type"] !== undefined) {
1690-
return sanitizeErrorCode(data["__type"]);
1691-
}
1692-
};

clients/client-acm/src/protocols/Aws_json1_1.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
23
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
34
import {
45
_json,
@@ -1178,54 +1179,3 @@ function sharedHeaders(operation: string): __HeaderBag {
11781179
"x-amz-target": `CertificateManager.${operation}`,
11791180
};
11801181
}
1181-
1182-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
1183-
collectBodyString(streamBody, context).then((encoded) => {
1184-
if (encoded.length) {
1185-
return JSON.parse(encoded);
1186-
}
1187-
return {};
1188-
});
1189-
1190-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
1191-
const value = await parseBody(errorBody, context);
1192-
value.message = value.message ?? value.Message;
1193-
return value;
1194-
};
1195-
1196-
/**
1197-
* Load an error code for the aws.rest-json-1.1 protocol.
1198-
*/
1199-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1200-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
1201-
1202-
const sanitizeErrorCode = (rawValue: string | number): string => {
1203-
let cleanValue = rawValue;
1204-
if (typeof cleanValue === "number") {
1205-
cleanValue = cleanValue.toString();
1206-
}
1207-
if (cleanValue.indexOf(",") >= 0) {
1208-
cleanValue = cleanValue.split(",")[0];
1209-
}
1210-
if (cleanValue.indexOf(":") >= 0) {
1211-
cleanValue = cleanValue.split(":")[0];
1212-
}
1213-
if (cleanValue.indexOf("#") >= 0) {
1214-
cleanValue = cleanValue.split("#")[1];
1215-
}
1216-
return cleanValue;
1217-
};
1218-
1219-
const headerKey = findKey(output.headers, "x-amzn-errortype");
1220-
if (headerKey !== undefined) {
1221-
return sanitizeErrorCode(output.headers[headerKey]);
1222-
}
1223-
1224-
if (data.code !== undefined) {
1225-
return sanitizeErrorCode(data.code);
1226-
}
1227-
1228-
if (data["__type"] !== undefined) {
1229-
return sanitizeErrorCode(data["__type"]);
1230-
}
1231-
};

clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
23
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
34
import {
45
_json,
@@ -4730,54 +4731,3 @@ function sharedHeaders(operation: string): __HeaderBag {
47304731
"x-amz-target": `AlexaForBusiness.${operation}`,
47314732
};
47324733
}
4733-
4734-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
4735-
collectBodyString(streamBody, context).then((encoded) => {
4736-
if (encoded.length) {
4737-
return JSON.parse(encoded);
4738-
}
4739-
return {};
4740-
});
4741-
4742-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
4743-
const value = await parseBody(errorBody, context);
4744-
value.message = value.message ?? value.Message;
4745-
return value;
4746-
};
4747-
4748-
/**
4749-
* Load an error code for the aws.rest-json-1.1 protocol.
4750-
*/
4751-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
4752-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
4753-
4754-
const sanitizeErrorCode = (rawValue: string | number): string => {
4755-
let cleanValue = rawValue;
4756-
if (typeof cleanValue === "number") {
4757-
cleanValue = cleanValue.toString();
4758-
}
4759-
if (cleanValue.indexOf(",") >= 0) {
4760-
cleanValue = cleanValue.split(",")[0];
4761-
}
4762-
if (cleanValue.indexOf(":") >= 0) {
4763-
cleanValue = cleanValue.split(":")[0];
4764-
}
4765-
if (cleanValue.indexOf("#") >= 0) {
4766-
cleanValue = cleanValue.split("#")[1];
4767-
}
4768-
return cleanValue;
4769-
};
4770-
4771-
const headerKey = findKey(output.headers, "x-amzn-errortype");
4772-
if (headerKey !== undefined) {
4773-
return sanitizeErrorCode(output.headers[headerKey]);
4774-
}
4775-
4776-
if (data.code !== undefined) {
4777-
return sanitizeErrorCode(data.code);
4778-
}
4779-
4780-
if (data["__type"] !== undefined) {
4781-
return sanitizeErrorCode(data["__type"]);
4782-
}
4783-
};

clients/client-amp/src/protocols/Aws_restJson1.ts

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// smithy-typescript generated code
2-
import { awsExpectUnion as __expectUnion } from "@aws-sdk/core";
2+
import {
3+
awsExpectUnion as __expectUnion,
4+
loadRestJsonErrorCode,
5+
parseJsonBody as parseBody,
6+
parseJsonErrorBody as parseErrorBody,
7+
} from "@aws-sdk/core";
38
import { requestBuilder as rb } from "@smithy/core";
49
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
510
import {
@@ -1642,54 +1647,3 @@ const _nT = "nextToken";
16421647
const _rAS = "retryAfterSeconds";
16431648
const _ra = "retry-after";
16441649
const _tK = "tagKeys";
1645-
1646-
const parseBody = (streamBody: any, context: __SerdeContext): any =>
1647-
collectBodyString(streamBody, context).then((encoded) => {
1648-
if (encoded.length) {
1649-
return JSON.parse(encoded);
1650-
}
1651-
return {};
1652-
});
1653-
1654-
const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
1655-
const value = await parseBody(errorBody, context);
1656-
value.message = value.message ?? value.Message;
1657-
return value;
1658-
};
1659-
1660-
/**
1661-
* Load an error code for the aws.rest-json-1.1 protocol.
1662-
*/
1663-
const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1664-
const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
1665-
1666-
const sanitizeErrorCode = (rawValue: string | number): string => {
1667-
let cleanValue = rawValue;
1668-
if (typeof cleanValue === "number") {
1669-
cleanValue = cleanValue.toString();
1670-
}
1671-
if (cleanValue.indexOf(",") >= 0) {
1672-
cleanValue = cleanValue.split(",")[0];
1673-
}
1674-
if (cleanValue.indexOf(":") >= 0) {
1675-
cleanValue = cleanValue.split(":")[0];
1676-
}
1677-
if (cleanValue.indexOf("#") >= 0) {
1678-
cleanValue = cleanValue.split("#")[1];
1679-
}
1680-
return cleanValue;
1681-
};
1682-
1683-
const headerKey = findKey(output.headers, "x-amzn-errortype");
1684-
if (headerKey !== undefined) {
1685-
return sanitizeErrorCode(output.headers[headerKey]);
1686-
}
1687-
1688-
if (data.code !== undefined) {
1689-
return sanitizeErrorCode(data.code);
1690-
}
1691-
1692-
if (data["__type"] !== undefined) {
1693-
return sanitizeErrorCode(data["__type"]);
1694-
}
1695-
};

0 commit comments

Comments
 (0)