diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddProtocolConfig.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddProtocolConfig.java index a8b9bba8082c6..5e91c8b5c64a3 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddProtocolConfig.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddProtocolConfig.java @@ -46,7 +46,10 @@ public AddProtocolConfig() { // protocol tests SchemaGenerationAllowlist.allow("aws.protocoltests.json10#JsonRpc10"); SchemaGenerationAllowlist.allow("aws.protocoltests.json#JsonProtocol"); + SchemaGenerationAllowlist.allow("com.amazonaws.machinelearning#AmazonML_20141212"); SchemaGenerationAllowlist.allow("aws.protocoltests.restjson#RestJson"); + SchemaGenerationAllowlist.allow("com.amazonaws.glacier#Glacier"); + SchemaGenerationAllowlist.allow("com.amazonaws.apigateway#BackplaneControlService"); SchemaGenerationAllowlist.allow("aws.protocoltests.restxml#RestXml"); SchemaGenerationAllowlist.allow("aws.protocoltests.query#AwsQuery"); SchemaGenerationAllowlist.allow("aws.protocoltests.ec2#AwsEc2"); diff --git a/private/aws-protocoltests-json-schema-machinelearning/package.json b/private/aws-protocoltests-json-schema-machinelearning/package.json index a81f79498612f..0ac4ce9d3b7cf 100644 --- a/private/aws-protocoltests-json-schema-machinelearning/package.json +++ b/private/aws-protocoltests-json-schema-machinelearning/package.json @@ -56,9 +56,7 @@ "@smithy/util-middleware": "^4.0.5", "@smithy/util-retry": "^4.0.7", "@smithy/util-utf8": "^4.0.0", - "@types/uuid": "^9.0.1", - "tslib": "^2.6.2", - "uuid": "^9.0.1" + "tslib": "^2.6.2" }, "devDependencies": { "@tsconfig/node18": "18.2.4", diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/MachineLearningClient.ts b/private/aws-protocoltests-json-schema-machinelearning/src/MachineLearningClient.ts index 01bf7b223bac2..39e13545515d6 100644 --- a/private/aws-protocoltests-json-schema-machinelearning/src/MachineLearningClient.ts +++ b/private/aws-protocoltests-json-schema-machinelearning/src/MachineLearningClient.ts @@ -24,6 +24,7 @@ import { getHttpAuthSchemeEndpointRuleSetPlugin, getHttpSigningPlugin, } from "@smithy/core"; +import { getSchemaSerdePlugin } from "@smithy/core/schema"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; @@ -39,11 +40,14 @@ import { BodyLengthCalculator as __BodyLengthCalculator, CheckOptionalClientConfig as __CheckOptionalClientConfig, ChecksumConstructor as __ChecksumConstructor, + ClientProtocol, Decoder as __Decoder, Encoder as __Encoder, EndpointV2 as __EndpointV2, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, + HttpRequest, + HttpResponse, Logger as __Logger, Provider as __Provider, Provider, @@ -225,6 +229,16 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand */ extensions?: RuntimeExtension[]; + /** + * The protocol controlling the message type (e.g. HTTP) and format (e.g. JSON) + * may be overridden. A default will always be set by the client. + * Available options depend on the service's supported protocols and will not be validated by + * the client. + * @alpha + * + */ + protocol?: ClientProtocol; + /** * The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ @@ -300,6 +314,7 @@ export class MachineLearningClient extends __Client< const _config_8 = resolveHttpAuthSchemeConfig(_config_7); const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); this.config = _config_9; + this.middlewareStack.use(getSchemaSerdePlugin(this.config)); this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/commands/PredictCommand.ts b/private/aws-protocoltests-json-schema-machinelearning/src/commands/PredictCommand.ts index ab6ce352e47b5..3a3a32a5768d4 100644 --- a/private/aws-protocoltests-json-schema-machinelearning/src/commands/PredictCommand.ts +++ b/private/aws-protocoltests-json-schema-machinelearning/src/commands/PredictCommand.ts @@ -1,14 +1,13 @@ // smithy-typescript generated code import { getPredictEndpointPlugin } from "@aws-sdk/middleware-sdk-machinelearning"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; -import { getSerdePlugin } from "@smithy/middleware-serde"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; import { commonParams } from "../endpoint/EndpointParameters"; import { MachineLearningClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../MachineLearningClient"; import { PredictInput, PredictOutput } from "../models/models_0"; -import { de_PredictCommand, se_PredictCommand } from "../protocols/Aws_json1_1"; +import { Predict } from "../schemas/schemas_1_Predict"; /** * @public @@ -92,17 +91,11 @@ export class PredictCommand extends $Command >() .ep(commonParams) .m(function (this: any, Command: any, cs: any, config: MachineLearningClientResolvedConfig, o: any) { - return [ - getSerdePlugin(config, this.serialize, this.deserialize), - getEndpointPlugin(config, Command.getEndpointParameterInstructions()), - getPredictEndpointPlugin(config), - ]; + return [getEndpointPlugin(config, Command.getEndpointParameterInstructions()), getPredictEndpointPlugin(config)]; }) .s("AmazonML_20141212", "Predict", {}) .n("MachineLearningClient", "PredictCommand") - .f(void 0, void 0) - .ser(se_PredictCommand) - .de(de_PredictCommand) + .sc(Predict) .build() { /** @internal type navigation helper, not in runtime. */ protected declare static __types: { diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/protocols/Aws_json1_1.ts b/private/aws-protocoltests-json-schema-machinelearning/src/protocols/Aws_json1_1.ts deleted file mode 100644 index 6ba79e00e2ff5..0000000000000 --- a/private/aws-protocoltests-json-schema-machinelearning/src/protocols/Aws_json1_1.ts +++ /dev/null @@ -1,274 +0,0 @@ -// smithy-typescript generated code -import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core"; -import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; -import { - _json, - collectBody, - decorateServiceException as __decorateServiceException, - expectString as __expectString, - limitedParseFloat32 as __limitedParseFloat32, - take, - withBaseException, -} from "@smithy/smithy-client"; -import { - Endpoint as __Endpoint, - HeaderBag as __HeaderBag, - ResponseMetadata as __ResponseMetadata, - SerdeContext as __SerdeContext, -} from "@smithy/types"; -import { v4 as generateIdempotencyToken } from "uuid"; - -import { PredictCommandInput, PredictCommandOutput } from "../commands/PredictCommand"; -import { MachineLearningServiceException as __BaseException } from "../models/MachineLearningServiceException"; -import { - InternalServerException, - InvalidInputException, - LimitExceededException, - PredictInput, - Prediction, - PredictorNotMountedException, - PredictOutput, - ResourceNotFoundException, -} from "../models/models_0"; - -/** - * serializeAws_json1_1PredictCommand - */ -export const se_PredictCommand = async ( - input: PredictCommandInput, - context: __SerdeContext -): Promise<__HttpRequest> => { - const headers: __HeaderBag = sharedHeaders("Predict"); - let body: any; - body = JSON.stringify(_json(input)); - return buildHttpRpcRequest(context, headers, "/", undefined, body); -}; - -/** - * deserializeAws_json1_1PredictCommand - */ -export const de_PredictCommand = async ( - output: __HttpResponse, - context: __SerdeContext -): Promise => { - if (output.statusCode >= 300) { - return de_CommandError(output, context); - } - const data: any = await parseBody(output.body, context); - let contents: any = {}; - contents = de_PredictOutput(data, context); - const response: PredictCommandOutput = { - $metadata: deserializeMetadata(output), - ...contents, - }; - return response; -}; - -/** - * deserialize_Aws_json1_1CommandError - */ -const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): Promise => { - const parsedOutput: any = { - ...output, - body: await parseErrorBody(output.body, context), - }; - const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); - switch (errorCode) { - case "InternalServerException": - case "com.amazonaws.machinelearning#InternalServerException": - throw await de_InternalServerExceptionRes(parsedOutput, context); - case "InvalidInputException": - case "com.amazonaws.machinelearning#InvalidInputException": - throw await de_InvalidInputExceptionRes(parsedOutput, context); - case "LimitExceededException": - case "com.amazonaws.machinelearning#LimitExceededException": - throw await de_LimitExceededExceptionRes(parsedOutput, context); - case "PredictorNotMountedException": - case "com.amazonaws.machinelearning#PredictorNotMountedException": - throw await de_PredictorNotMountedExceptionRes(parsedOutput, context); - case "ResourceNotFoundException": - case "com.amazonaws.machinelearning#ResourceNotFoundException": - throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); - default: - const parsedBody = parsedOutput.body; - return throwDefaultError({ - output, - parsedBody, - errorCode, - }) as never; - } -}; - -/** - * deserializeAws_json1_1InternalServerExceptionRes - */ -const de_InternalServerExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const body = parsedOutput.body; - const deserialized: any = _json(body); - const exception = new InternalServerException({ - $metadata: deserializeMetadata(parsedOutput), - ...deserialized, - }); - return __decorateServiceException(exception, body); -}; - -/** - * deserializeAws_json1_1InvalidInputExceptionRes - */ -const de_InvalidInputExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const body = parsedOutput.body; - const deserialized: any = _json(body); - const exception = new InvalidInputException({ - $metadata: deserializeMetadata(parsedOutput), - ...deserialized, - }); - return __decorateServiceException(exception, body); -}; - -/** - * deserializeAws_json1_1LimitExceededExceptionRes - */ -const de_LimitExceededExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const body = parsedOutput.body; - const deserialized: any = _json(body); - const exception = new LimitExceededException({ - $metadata: deserializeMetadata(parsedOutput), - ...deserialized, - }); - return __decorateServiceException(exception, body); -}; - -/** - * deserializeAws_json1_1PredictorNotMountedExceptionRes - */ -const de_PredictorNotMountedExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const body = parsedOutput.body; - const deserialized: any = _json(body); - const exception = new PredictorNotMountedException({ - $metadata: deserializeMetadata(parsedOutput), - ...deserialized, - }); - return __decorateServiceException(exception, body); -}; - -/** - * deserializeAws_json1_1ResourceNotFoundExceptionRes - */ -const de_ResourceNotFoundExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const body = parsedOutput.body; - const deserialized: any = _json(body); - const exception = new ResourceNotFoundException({ - $metadata: deserializeMetadata(parsedOutput), - ...deserialized, - }); - return __decorateServiceException(exception, body); -}; - -// se_PredictInput omitted. - -// se_Record omitted. - -// de_DetailsMap omitted. - -// de_InternalServerException omitted. - -// de_InvalidInputException omitted. - -// de_LimitExceededException omitted. - -/** - * deserializeAws_json1_1Prediction - */ -const de_Prediction = (output: any, context: __SerdeContext): Prediction => { - return take(output, { - details: _json, - predictedLabel: __expectString, - predictedScores: (_: any) => de_ScoreValuePerLabelMap(_, context), - predictedValue: __limitedParseFloat32, - }) as any; -}; - -// de_PredictorNotMountedException omitted. - -/** - * deserializeAws_json1_1PredictOutput - */ -const de_PredictOutput = (output: any, context: __SerdeContext): PredictOutput => { - return take(output, { - Prediction: (_: any) => de_Prediction(_, context), - }) as any; -}; - -// de_ResourceNotFoundException omitted. - -/** - * deserializeAws_json1_1ScoreValuePerLabelMap - */ -const de_ScoreValuePerLabelMap = (output: any, context: __SerdeContext): Record => { - return Object.entries(output).reduce((acc: Record, [key, value]: [string, any]) => { - if (value === null) { - return acc; - } - acc[key as string] = __limitedParseFloat32(value) as any; - return acc; - }, {} as Record); -}; - -const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ - httpStatusCode: output.statusCode, - requestId: - output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], - extendedRequestId: output.headers["x-amz-id-2"], - cfId: output.headers["x-amz-cf-id"], -}); - -// Encode Uint8Array data into string with utf-8. -const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => - collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); - -const throwDefaultError = withBaseException(__BaseException); -const buildHttpRpcRequest = async ( - context: __SerdeContext, - headers: __HeaderBag, - path: string, - resolvedHostname: string | undefined, - body: any -): Promise<__HttpRequest> => { - const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); - const contents: any = { - protocol, - hostname, - port, - method: "POST", - path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path, - headers, - }; - if (resolvedHostname !== undefined) { - contents.hostname = resolvedHostname; - } - if (body !== undefined) { - contents.body = body; - } - return new __HttpRequest(contents); -}; -function sharedHeaders(operation: string): __HeaderBag { - return { - "content-type": "application/x-amz-json-1.1", - "x-amz-target": `AmazonML_20141212.${operation}`, - }; -} diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/runtimeConfig.shared.ts b/private/aws-protocoltests-json-schema-machinelearning/src/runtimeConfig.shared.ts index eecd9ea147ed2..1d76e8bbde668 100644 --- a/private/aws-protocoltests-json-schema-machinelearning/src/runtimeConfig.shared.ts +++ b/private/aws-protocoltests-json-schema-machinelearning/src/runtimeConfig.shared.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { AwsSdkSigV4Signer } from "@aws-sdk/core"; +import { AwsJson1_1Protocol } from "@aws-sdk/core/protocols"; import { NoOpLogger } from "@smithy/smithy-client"; import { IdentityProviderConfig } from "@smithy/types"; import { parseUrl } from "@smithy/url-parser"; @@ -30,6 +31,13 @@ export const getRuntimeConfig = (config: MachineLearningClientConfig) => { }, ], logger: config?.logger ?? new NoOpLogger(), + protocol: + config?.protocol ?? + new AwsJson1_1Protocol({ + defaultNamespace: "com.amazonaws.machinelearning", + serviceTarget: "AmazonML_20141212", + awsQueryCompatible: false, + }), serviceId: config?.serviceId ?? "Machine Learning", urlParser: config?.urlParser ?? parseUrl, utf8Decoder: config?.utf8Decoder ?? fromUtf8, diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_0.ts b/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_0.ts new file mode 100644 index 0000000000000..03ced1ba32b33 --- /dev/null +++ b/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_0.ts @@ -0,0 +1,39 @@ +export const _IIE = "InvalidInputException"; +export const _ISE = "InternalServerException"; +export const _LEE = "LimitExceededException"; +export const _MLMI = "MLModelId"; +export const _P = "Prediction"; +export const _PE = "PredictEndpoint"; +export const _PI = "PredictInput"; +export const _PNME = "PredictorNotMountedException"; +export const _PO = "PredictOutput"; +export const _Pr = "Predict"; +export const _R = "Record"; +export const _RNFE = "ResourceNotFoundException"; +export const _c = "code"; +export const _cl = "client"; +export const _d = "details"; +export const _e = "error"; +export const _hE = "httpError"; +export const _m = "message"; +export const _pL = "predictedLabel"; +export const _pS = "predictedScores"; +export const _pV = "predictedValue"; +export const _s = "server"; +export const n0 = "com.amazonaws.machinelearning"; + +// smithy-typescript generated code +import { error } from "@smithy/core/schema"; + +import { MachineLearningServiceException as __MachineLearningServiceException } from "../models/MachineLearningServiceException"; + +/* eslint no-var: 0 */ + +export var MachineLearningServiceException = error( + "smithy.ts.sdk.synthetic.com.amazonaws.machinelearning", + "MachineLearningServiceException", + 0, + [], + [], + __MachineLearningServiceException +); diff --git a/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_1_Predict.ts b/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_1_Predict.ts new file mode 100644 index 0000000000000..863c6d217585f --- /dev/null +++ b/private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_1_Predict.ts @@ -0,0 +1,116 @@ +// smithy-typescript generated code +import { error, op, struct } from "@smithy/core/schema"; + +import { + InternalServerException as __InternalServerException, + InvalidInputException as __InvalidInputException, + LimitExceededException as __LimitExceededException, + PredictorNotMountedException as __PredictorNotMountedException, + ResourceNotFoundException as __ResourceNotFoundException, +} from "../models/index"; +import { + _c, + _cl, + _d, + _e, + _hE, + _IIE, + _ISE, + _LEE, + _m, + _MLMI, + _P, + _PE, + _PI, + _pL, + _PNME, + _PO, + _Pr, + _pS, + _pV, + _R, + _RNFE, + _s, + n0, +} from "./schemas_0"; + +/* eslint no-var: 0 */ + +export var InternalServerException = error( + n0, + _ISE, + { + [_e]: _s, + [_hE]: 500, + }, + [_m, _c], + [0, 1], + + __InternalServerException +); +export var InvalidInputException = error( + n0, + _IIE, + { + [_e]: _cl, + [_hE]: 400, + }, + [_m, _c], + [0, 1], + + __InvalidInputException +); +export var LimitExceededException = error( + n0, + _LEE, + { + [_e]: _cl, + [_hE]: 417, + }, + [_m, _c], + [0, 1], + + __LimitExceededException +); +export var PredictInput = struct(n0, _PI, 0, [_MLMI, _R, _PE], [0, 128 | 0, 0]); +export var Prediction = struct(n0, _P, 0, [_pL, _pV, _pS, _d], [0, 1, 128 | 1, 128 | 0]); +export var PredictorNotMountedException = error( + n0, + _PNME, + { + [_e]: _cl, + [_hE]: 400, + }, + [_m], + [0], + + __PredictorNotMountedException +); +export var PredictOutput = struct(n0, _PO, 0, [_P], [() => Prediction]); +export var ResourceNotFoundException = error( + n0, + _RNFE, + { + [_e]: _cl, + [_hE]: 404, + }, + [_m, _c], + [0, 1], + + __ResourceNotFoundException +); +export var Unit = "unit" as const; + +export var DetailsMap = 128 | 0; + +export var _Record = 128 | 0; + +export var ScoreValuePerLabelMap = 128 | 1; + +export var Predict = op( + n0, + _Pr, + 0, + () => PredictInput, + () => PredictOutput +); diff --git a/private/aws-protocoltests-restjson-schema-apigateway/package.json b/private/aws-protocoltests-restjson-schema-apigateway/package.json index 38ebd2455b71f..41a1adac0cad7 100644 --- a/private/aws-protocoltests-restjson-schema-apigateway/package.json +++ b/private/aws-protocoltests-restjson-schema-apigateway/package.json @@ -56,9 +56,7 @@ "@smithy/util-middleware": "^4.0.5", "@smithy/util-retry": "^4.0.7", "@smithy/util-utf8": "^4.0.0", - "@types/uuid": "^9.0.1", - "tslib": "^2.6.2", - "uuid": "^9.0.1" + "tslib": "^2.6.2" }, "devDependencies": { "@tsconfig/node18": "18.2.4", diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/APIGatewayClient.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/APIGatewayClient.ts index aee2fc1958a73..036b0fc505a3a 100644 --- a/private/aws-protocoltests-restjson-schema-apigateway/src/APIGatewayClient.ts +++ b/private/aws-protocoltests-restjson-schema-apigateway/src/APIGatewayClient.ts @@ -25,6 +25,7 @@ import { getHttpAuthSchemeEndpointRuleSetPlugin, getHttpSigningPlugin, } from "@smithy/core"; +import { getSchemaSerdePlugin } from "@smithy/core/schema"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; @@ -40,11 +41,14 @@ import { BodyLengthCalculator as __BodyLengthCalculator, CheckOptionalClientConfig as __CheckOptionalClientConfig, ChecksumConstructor as __ChecksumConstructor, + ClientProtocol, Decoder as __Decoder, Encoder as __Encoder, EndpointV2 as __EndpointV2, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, + HttpRequest, + HttpResponse, Logger as __Logger, Provider as __Provider, Provider, @@ -226,6 +230,16 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand */ extensions?: RuntimeExtension[]; + /** + * The protocol controlling the message type (e.g. HTTP) and format (e.g. JSON) + * may be overridden. A default will always be set by the client. + * Available options depend on the service's supported protocols and will not be validated by + * the client. + * @alpha + * + */ + protocol?: ClientProtocol; + /** * The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ @@ -301,6 +315,7 @@ export class APIGatewayClient extends __Client< const _config_8 = resolveHttpAuthSchemeConfig(_config_7); const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); this.config = _config_9; + this.middlewareStack.use(getSchemaSerdePlugin(this.config)); this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/commands/GetRestApisCommand.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/commands/GetRestApisCommand.ts index c07e9f6343e88..c3e5667ace7e6 100644 --- a/private/aws-protocoltests-restjson-schema-apigateway/src/commands/GetRestApisCommand.ts +++ b/private/aws-protocoltests-restjson-schema-apigateway/src/commands/GetRestApisCommand.ts @@ -1,13 +1,12 @@ // smithy-typescript generated code import { getEndpointPlugin } from "@smithy/middleware-endpoint"; -import { getSerdePlugin } from "@smithy/middleware-serde"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; import { APIGatewayClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../APIGatewayClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { GetRestApisRequest, RestApis } from "../models/models_0"; -import { de_GetRestApisCommand, se_GetRestApisCommand } from "../protocols/Aws_restJson1"; +import { GetRestApis } from "../schemas/schemas_1_GetRestApis"; /** * @public @@ -105,16 +104,11 @@ export class GetRestApisCommand extends $Command >() .ep(commonParams) .m(function (this: any, Command: any, cs: any, config: APIGatewayClientResolvedConfig, o: any) { - return [ - getSerdePlugin(config, this.serialize, this.deserialize), - getEndpointPlugin(config, Command.getEndpointParameterInstructions()), - ]; + return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("BackplaneControlService", "GetRestApis", {}) .n("APIGatewayClient", "GetRestApisCommand") - .f(void 0, void 0) - .ser(se_GetRestApisCommand) - .de(de_GetRestApisCommand) + .sc(GetRestApis) .build() { /** @internal type navigation helper, not in runtime. */ protected declare static __types: { diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/protocols/Aws_restJson1.ts deleted file mode 100644 index 5555aa136e836..0000000000000 --- a/private/aws-protocoltests-restjson-schema-apigateway/src/protocols/Aws_restJson1.ts +++ /dev/null @@ -1,218 +0,0 @@ -// smithy-typescript generated code -import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core"; -import { requestBuilder as rb } from "@smithy/core"; -import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; -import { - _json, - collectBody, - decorateServiceException as __decorateServiceException, - expectBoolean as __expectBoolean, - expectInt32 as __expectInt32, - expectNonNull as __expectNonNull, - expectNumber as __expectNumber, - expectObject as __expectObject, - expectString as __expectString, - extendedEncodeURIComponent as __extendedEncodeURIComponent, - map, - parseEpochTimestamp as __parseEpochTimestamp, - take, - withBaseException, -} from "@smithy/smithy-client"; -import { - Endpoint as __Endpoint, - ResponseMetadata as __ResponseMetadata, - SerdeContext as __SerdeContext, -} from "@smithy/types"; -import { v4 as generateIdempotencyToken } from "uuid"; - -import { GetRestApisCommandInput, GetRestApisCommandOutput } from "../commands/GetRestApisCommand"; -import { APIGatewayServiceException as __BaseException } from "../models/APIGatewayServiceException"; -import { BadRequestException, RestApi, TooManyRequestsException, UnauthorizedException } from "../models/models_0"; - -/** - * serializeAws_restJson1GetRestApisCommand - */ -export const se_GetRestApisCommand = async ( - input: GetRestApisCommandInput, - context: __SerdeContext -): Promise<__HttpRequest> => { - const b = rb(input, context); - const headers: any = {}; - b.bp("/restapis"); - const query: any = map({ - [_p]: [, input[_p]!], - [_l]: [() => input.limit !== void 0, () => input[_l]!.toString()], - }); - let body: any; - b.m("GET").h(headers).q(query).b(body); - return b.build(); -}; - -/** - * deserializeAws_restJson1GetRestApisCommand - */ -export const de_GetRestApisCommand = async ( - output: __HttpResponse, - context: __SerdeContext -): Promise => { - if (output.statusCode !== 200 && output.statusCode >= 300) { - return de_CommandError(output, context); - } - const contents: any = map({ - $metadata: deserializeMetadata(output), - }); - const data: Record = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); - const doc = take(data, { - items: [, (_) => de_ListOfRestApi(_, context), `item`], - position: __expectString, - }); - Object.assign(contents, doc); - return contents; -}; - -/** - * deserialize_Aws_restJson1CommandError - */ -const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): Promise => { - const parsedOutput: any = { - ...output, - body: await parseErrorBody(output.body, context), - }; - const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); - switch (errorCode) { - case "BadRequestException": - case "com.amazonaws.apigateway#BadRequestException": - throw await de_BadRequestExceptionRes(parsedOutput, context); - case "TooManyRequestsException": - case "com.amazonaws.apigateway#TooManyRequestsException": - throw await de_TooManyRequestsExceptionRes(parsedOutput, context); - case "UnauthorizedException": - case "com.amazonaws.apigateway#UnauthorizedException": - throw await de_UnauthorizedExceptionRes(parsedOutput, context); - default: - const parsedBody = parsedOutput.body; - return throwDefaultError({ - output, - parsedBody, - errorCode, - }) as never; - } -}; - -const throwDefaultError = withBaseException(__BaseException); -/** - * deserializeAws_restJson1BadRequestExceptionRes - */ -const de_BadRequestExceptionRes = async (parsedOutput: any, context: __SerdeContext): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - message: __expectString, - }); - Object.assign(contents, doc); - const exception = new BadRequestException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1TooManyRequestsExceptionRes - */ -const de_TooManyRequestsExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({ - [_rAS]: [, parsedOutput.headers[_ra]], - }); - const data: any = parsedOutput.body; - const doc = take(data, { - message: __expectString, - }); - Object.assign(contents, doc); - const exception = new TooManyRequestsException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1UnauthorizedExceptionRes - */ -const de_UnauthorizedExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - message: __expectString, - }); - Object.assign(contents, doc); - const exception = new UnauthorizedException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -// de_EndpointConfiguration omitted. - -// de_ListOfEndpointType omitted. - -/** - * deserializeAws_restJson1ListOfRestApi - */ -const de_ListOfRestApi = (output: any, context: __SerdeContext): RestApi[] => { - const retVal = (output || []) - .filter((e: any) => e != null) - .map((entry: any) => { - return de_RestApi(entry, context); - }); - return retVal; -}; - -// de_ListOfString omitted. - -// de_MapOfStringToString omitted. - -/** - * deserializeAws_restJson1RestApi - */ -const de_RestApi = (output: any, context: __SerdeContext): RestApi => { - return take(output, { - apiKeySource: __expectString, - binaryMediaTypes: _json, - createdDate: (_: any) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))), - description: __expectString, - disableExecuteApiEndpoint: __expectBoolean, - endpointConfiguration: _json, - id: __expectString, - minimumCompressionSize: __expectInt32, - name: __expectString, - policy: __expectString, - tags: _json, - version: __expectString, - warnings: _json, - }) as any; -}; - -const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ - httpStatusCode: output.statusCode, - requestId: - output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], - extendedRequestId: output.headers["x-amz-id-2"], - cfId: output.headers["x-amz-cf-id"], -}); - -// Encode Uint8Array data into string with utf-8. -const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => - collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); - -const _l = "limit"; -const _p = "position"; -const _rAS = "retryAfterSeconds"; -const _ra = "retry-after"; diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/runtimeConfig.shared.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/runtimeConfig.shared.ts index 94da1ccbbb7b5..9afd43aed87fc 100644 --- a/private/aws-protocoltests-restjson-schema-apigateway/src/runtimeConfig.shared.ts +++ b/private/aws-protocoltests-restjson-schema-apigateway/src/runtimeConfig.shared.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { AwsSdkSigV4Signer } from "@aws-sdk/core"; +import { AwsRestJsonProtocol } from "@aws-sdk/core/protocols"; import { NoOpLogger } from "@smithy/smithy-client"; import { IdentityProviderConfig } from "@smithy/types"; import { parseUrl } from "@smithy/url-parser"; @@ -30,6 +31,7 @@ export const getRuntimeConfig = (config: APIGatewayClientConfig) => { }, ], logger: config?.logger ?? new NoOpLogger(), + protocol: config?.protocol ?? new AwsRestJsonProtocol({ defaultNamespace: "com.amazonaws.apigateway" }), serviceId: config?.serviceId ?? "API Gateway", urlParser: config?.urlParser ?? parseUrl, utf8Decoder: config?.utf8Decoder ?? fromUtf8, diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_0.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_0.ts new file mode 100644 index 0000000000000..343d938a4743e --- /dev/null +++ b/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_0.ts @@ -0,0 +1,55 @@ +export const _BRE = "BadRequestException"; +export const _EC = "EndpointConfiguration"; +export const _GRA = "GetRestApis"; +export const _GRAR = "GetRestApisRequest"; +export const _LORA = "ListOfRestApi"; +export const _RA = "RestApi"; +export const _RA_ = "Retry-After"; +export const _RAe = "RestApis"; +export const _TMRE = "TooManyRequestsException"; +export const _UE = "UnauthorizedException"; +export const _aKS = "apiKeySource"; +export const _bMT = "binaryMediaTypes"; +export const _c = "client"; +export const _cD = "createdDate"; +export const _d = "description"; +export const _dEAE = "disableExecuteApiEndpoint"; +export const _e = "error"; +export const _eC = "endpointConfiguration"; +export const _h = "http"; +export const _hE = "httpError"; +export const _hH = "httpHeader"; +export const _hQ = "httpQuery"; +export const _i = "id"; +export const _it = "items"; +export const _ite = "item"; +export const _jN = "jsonName"; +export const _l = "limit"; +export const _m = "message"; +export const _mCS = "minimumCompressionSize"; +export const _n = "name"; +export const _p = "position"; +export const _po = "policy"; +export const _rAS = "retryAfterSeconds"; +export const _t = "types"; +export const _ta = "tags"; +export const _v = "version"; +export const _vEI = "vpcEndpointIds"; +export const _w = "warnings"; +export const n0 = "com.amazonaws.apigateway"; + +// smithy-typescript generated code +import { error } from "@smithy/core/schema"; + +import { APIGatewayServiceException as __APIGatewayServiceException } from "../models/APIGatewayServiceException"; + +/* eslint no-var: 0 */ + +export var APIGatewayServiceException = error( + "smithy.ts.sdk.synthetic.com.amazonaws.apigateway", + "APIGatewayServiceException", + 0, + [], + [], + __APIGatewayServiceException +); diff --git a/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_1_GetRestApis.ts b/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_1_GetRestApis.ts new file mode 100644 index 0000000000000..610a40ff1a538 --- /dev/null +++ b/private/aws-protocoltests-restjson-schema-apigateway/src/schemas/schemas_1_GetRestApis.ts @@ -0,0 +1,157 @@ +// smithy-typescript generated code +import { error, list, op, struct } from "@smithy/core/schema"; + +import { + BadRequestException as __BadRequestException, + TooManyRequestsException as __TooManyRequestsException, + UnauthorizedException as __UnauthorizedException, +} from "../models/index"; +import { + _aKS, + _bMT, + _BRE, + _c, + _cD, + _d, + _dEAE, + _e, + _EC, + _eC, + _GRA, + _GRAR, + _h, + _hE, + _hH, + _hQ, + _i, + _it, + _ite, + _jN, + _l, + _LORA, + _m, + _mCS, + _n, + _p, + _po, + _RA, + _RA_, + _RAe, + _rAS, + _t, + _ta, + _TMRE, + _UE, + _v, + _vEI, + _w, + n0, +} from "./schemas_0"; + +/* eslint no-var: 0 */ + +export var BadRequestException = error( + n0, + _BRE, + { + [_e]: _c, + [_hE]: 400, + }, + [_m], + [0], + + __BadRequestException +); +export var EndpointConfiguration = struct(n0, _EC, 0, [_t, _vEI], [64 | 0, 64 | 0]); +export var GetRestApisRequest = struct( + n0, + _GRAR, + 0, + [_p, _l], + [ + [ + 0, + { + [_hQ]: _p, + }, + ], + [ + 1, + { + [_hQ]: _l, + }, + ], + ] +); +export var RestApi = struct( + n0, + _RA, + 0, + [_i, _n, _d, _cD, _v, _w, _bMT, _mCS, _aKS, _eC, _po, _ta, _dEAE], + [0, 0, 0, 4, 0, 64 | 0, 64 | 0, 1, 0, () => EndpointConfiguration, 0, 128 | 0, 2] +); +export var RestApis = struct( + n0, + _RAe, + 0, + [_it, _p], + [ + [ + () => ListOfRestApi, + { + [_jN]: _ite, + }, + ], + 0, + ] +); +export var TooManyRequestsException = error( + n0, + _TMRE, + { + [_e]: _c, + [_hE]: 429, + }, + [_rAS, _m], + [ + [ + 0, + { + [_hH]: _RA_, + }, + ], + 0, + ], + + __TooManyRequestsException +); +export var UnauthorizedException = error( + n0, + _UE, + { + [_e]: _c, + [_hE]: 401, + }, + [_m], + [0], + + __UnauthorizedException +); +export var Unit = "unit" as const; + +export var ListOfEndpointType = 64 | 0; + +export var ListOfRestApi = list(n0, _LORA, 0, () => RestApi); +export var ListOfString = 64 | 0; + +export var MapOfStringToString = 128 | 0; + +export var GetRestApis = op( + n0, + _GRA, + { + [_h]: ["GET", "/restapis", 200], + }, + () => GetRestApisRequest, + () => RestApis +); diff --git a/private/aws-protocoltests-restjson-schema-glacier/package.json b/private/aws-protocoltests-restjson-schema-glacier/package.json index 51de099e97441..ed7d9b6ee4ba8 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/package.json +++ b/private/aws-protocoltests-restjson-schema-glacier/package.json @@ -58,9 +58,7 @@ "@smithy/util-middleware": "^4.0.5", "@smithy/util-retry": "^4.0.7", "@smithy/util-utf8": "^4.0.0", - "@types/uuid": "^9.0.1", - "tslib": "^2.6.2", - "uuid": "^9.0.1" + "tslib": "^2.6.2" }, "devDependencies": { "@tsconfig/node18": "18.2.4", diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/GlacierClient.ts b/private/aws-protocoltests-restjson-schema-glacier/src/GlacierClient.ts index 81a5b20aaf0d2..22855500503aa 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/src/GlacierClient.ts +++ b/private/aws-protocoltests-restjson-schema-glacier/src/GlacierClient.ts @@ -25,6 +25,7 @@ import { getHttpAuthSchemeEndpointRuleSetPlugin, getHttpSigningPlugin, } from "@smithy/core"; +import { getSchemaSerdePlugin } from "@smithy/core/schema"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; @@ -40,12 +41,15 @@ import { BodyLengthCalculator as __BodyLengthCalculator, CheckOptionalClientConfig as __CheckOptionalClientConfig, ChecksumConstructor as __ChecksumConstructor, + ClientProtocol, Decoder as __Decoder, Encoder as __Encoder, EndpointV2 as __EndpointV2, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, HttpRequest as __HttpRequest, + HttpRequest, + HttpResponse, Logger as __Logger, Provider as __Provider, Provider, @@ -240,6 +244,16 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand */ extensions?: RuntimeExtension[]; + /** + * The protocol controlling the message type (e.g. HTTP) and format (e.g. JSON) + * may be overridden. A default will always be set by the client. + * Available options depend on the service's supported protocols and will not be validated by + * the client. + * @alpha + * + */ + protocol?: ClientProtocol; + /** * The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ @@ -315,6 +329,7 @@ export class GlacierClient extends __Client< const _config_8 = resolveHttpAuthSchemeConfig(_config_7); const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); this.config = _config_9; + this.middlewareStack.use(getSchemaSerdePlugin(this.config)); this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadArchiveCommand.ts b/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadArchiveCommand.ts index dffb3c22039df..94fac2d32f0d3 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadArchiveCommand.ts +++ b/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadArchiveCommand.ts @@ -1,13 +1,12 @@ // smithy-typescript generated code import { getEndpointPlugin } from "@smithy/middleware-endpoint"; -import { getSerdePlugin } from "@smithy/middleware-serde"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer, StreamingBlobPayloadInputTypes } from "@smithy/types"; import { commonParams } from "../endpoint/EndpointParameters"; import { GlacierClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GlacierClient"; -import { ArchiveCreationOutput, UploadArchiveInput, UploadArchiveInputFilterSensitiveLog } from "../models/models_0"; -import { de_UploadArchiveCommand, se_UploadArchiveCommand } from "../protocols/Aws_restJson1"; +import { ArchiveCreationOutput, UploadArchiveInput } from "../models/models_0"; +import { UploadArchive } from "../schemas/schemas_1_Upload"; /** * @public @@ -87,16 +86,11 @@ export class UploadArchiveCommand extends $Command >() .ep(commonParams) .m(function (this: any, Command: any, cs: any, config: GlacierClientResolvedConfig, o: any) { - return [ - getSerdePlugin(config, this.serialize, this.deserialize), - getEndpointPlugin(config, Command.getEndpointParameterInstructions()), - ]; + return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("Glacier", "UploadArchive", {}) .n("GlacierClient", "UploadArchiveCommand") - .f(UploadArchiveInputFilterSensitiveLog, void 0) - .ser(se_UploadArchiveCommand) - .de(de_UploadArchiveCommand) + .sc(UploadArchive) .build() { /** @internal type navigation helper, not in runtime. */ protected declare static __types: { diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadMultipartPartCommand.ts b/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadMultipartPartCommand.ts index bcb33913acc17..41275a1889d9c 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadMultipartPartCommand.ts +++ b/private/aws-protocoltests-restjson-schema-glacier/src/commands/UploadMultipartPartCommand.ts @@ -1,17 +1,12 @@ // smithy-typescript generated code import { getEndpointPlugin } from "@smithy/middleware-endpoint"; -import { getSerdePlugin } from "@smithy/middleware-serde"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer, StreamingBlobPayloadInputTypes } from "@smithy/types"; import { commonParams } from "../endpoint/EndpointParameters"; import { GlacierClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GlacierClient"; -import { - UploadMultipartPartInput, - UploadMultipartPartInputFilterSensitiveLog, - UploadMultipartPartOutput, -} from "../models/models_0"; -import { de_UploadMultipartPartCommand, se_UploadMultipartPartCommand } from "../protocols/Aws_restJson1"; +import { UploadMultipartPartInput, UploadMultipartPartOutput } from "../models/models_0"; +import { UploadMultipartPart } from "../schemas/schemas_1_Upload"; /** * @public @@ -90,16 +85,11 @@ export class UploadMultipartPartCommand extends $Command >() .ep(commonParams) .m(function (this: any, Command: any, cs: any, config: GlacierClientResolvedConfig, o: any) { - return [ - getSerdePlugin(config, this.serialize, this.deserialize), - getEndpointPlugin(config, Command.getEndpointParameterInstructions()), - ]; + return [getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("Glacier", "UploadMultipartPart", {}) .n("GlacierClient", "UploadMultipartPartCommand") - .f(UploadMultipartPartInputFilterSensitiveLog, void 0) - .ser(se_UploadMultipartPartCommand) - .de(de_UploadMultipartPartCommand) + .sc(UploadMultipartPart) .build() { /** @internal type navigation helper, not in runtime. */ protected declare static __types: { diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/models/models_0.ts b/private/aws-protocoltests-restjson-schema-glacier/src/models/models_0.ts index 8d15785d5e91b..8872f0afe6c7c 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/src/models/models_0.ts +++ b/private/aws-protocoltests-restjson-schema-glacier/src/models/models_0.ts @@ -139,13 +139,6 @@ export interface UploadArchiveInput { body?: StreamingBlobTypes | undefined; } -/** - * @internal - */ -export const UploadArchiveInputFilterSensitiveLog = (obj: UploadArchiveInput): any => ({ - ...obj, -}); - /** * @public */ @@ -158,13 +151,6 @@ export interface UploadMultipartPartInput { body?: StreamingBlobTypes | undefined; } -/** - * @internal - */ -export const UploadMultipartPartInputFilterSensitiveLog = (obj: UploadMultipartPartInput): any => ({ - ...obj, -}); - /** * @public */ diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson-schema-glacier/src/protocols/Aws_restJson1.ts deleted file mode 100644 index 19ee59f85ebd6..0000000000000 --- a/private/aws-protocoltests-restjson-schema-glacier/src/protocols/Aws_restJson1.ts +++ /dev/null @@ -1,290 +0,0 @@ -// smithy-typescript generated code -import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core"; -import { requestBuilder as rb } from "@smithy/core"; -import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; -import { - _json, - collectBody, - decorateServiceException as __decorateServiceException, - expectString as __expectString, - isSerializableHeaderValue, - map, - resolvedPath as __resolvedPath, - take, - withBaseException, -} from "@smithy/smithy-client"; -import { - Endpoint as __Endpoint, - ResponseMetadata as __ResponseMetadata, - SerdeContext as __SerdeContext, -} from "@smithy/types"; -import { v4 as generateIdempotencyToken } from "uuid"; - -import { UploadArchiveCommandInput, UploadArchiveCommandOutput } from "../commands/UploadArchiveCommand"; -import { - UploadMultipartPartCommandInput, - UploadMultipartPartCommandOutput, -} from "../commands/UploadMultipartPartCommand"; -import { GlacierServiceException as __BaseException } from "../models/GlacierServiceException"; -import { - InvalidParameterValueException, - MissingParameterValueException, - RequestTimeoutException, - ResourceNotFoundException, - ServiceUnavailableException, -} from "../models/models_0"; - -/** - * serializeAws_restJson1UploadArchiveCommand - */ -export const se_UploadArchiveCommand = async ( - input: UploadArchiveCommandInput, - context: __SerdeContext -): Promise<__HttpRequest> => { - const b = rb(input, context); - const headers: any = map({}, isSerializableHeaderValue, { - "content-type": "application/octet-stream", - [_xaad]: input[_aD]!, - [_xasth]: input[_c]!, - }); - b.bp("/{accountId}/vaults/{vaultName}/archives"); - b.p("vaultName", () => input.vaultName!, "{vaultName}", false); - b.p("accountId", () => input.accountId!, "{accountId}", false); - let body: any; - if (input.body !== undefined) { - body = input.body; - } - b.m("POST").h(headers).b(body); - return b.build(); -}; - -/** - * serializeAws_restJson1UploadMultipartPartCommand - */ -export const se_UploadMultipartPartCommand = async ( - input: UploadMultipartPartCommandInput, - context: __SerdeContext -): Promise<__HttpRequest> => { - const b = rb(input, context); - const headers: any = map({}, isSerializableHeaderValue, { - "content-type": "application/octet-stream", - [_xasth]: input[_c]!, - [_cr]: input[_r]!, - }); - b.bp("/{accountId}/vaults/{vaultName}/multipart-uploads/{uploadId}"); - b.p("accountId", () => input.accountId!, "{accountId}", false); - b.p("vaultName", () => input.vaultName!, "{vaultName}", false); - b.p("uploadId", () => input.uploadId!, "{uploadId}", false); - let body: any; - if (input.body !== undefined) { - body = input.body; - } - b.m("PUT").h(headers).b(body); - return b.build(); -}; - -/** - * deserializeAws_restJson1UploadArchiveCommand - */ -export const de_UploadArchiveCommand = async ( - output: __HttpResponse, - context: __SerdeContext -): Promise => { - if (output.statusCode !== 201 && output.statusCode >= 300) { - return de_CommandError(output, context); - } - const contents: any = map({ - $metadata: deserializeMetadata(output), - [_l]: [, output.headers[_l]], - [_c]: [, output.headers[_xasth]], - [_aI]: [, output.headers[_xaai]], - }); - await collectBody(output.body, context); - return contents; -}; - -/** - * deserializeAws_restJson1UploadMultipartPartCommand - */ -export const de_UploadMultipartPartCommand = async ( - output: __HttpResponse, - context: __SerdeContext -): Promise => { - if (output.statusCode !== 204 && output.statusCode >= 300) { - return de_CommandError(output, context); - } - const contents: any = map({ - $metadata: deserializeMetadata(output), - [_c]: [, output.headers[_xasth]], - }); - await collectBody(output.body, context); - return contents; -}; - -/** - * deserialize_Aws_restJson1CommandError - */ -const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): Promise => { - const parsedOutput: any = { - ...output, - body: await parseErrorBody(output.body, context), - }; - const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); - switch (errorCode) { - case "InvalidParameterValueException": - case "com.amazonaws.glacier#InvalidParameterValueException": - throw await de_InvalidParameterValueExceptionRes(parsedOutput, context); - case "MissingParameterValueException": - case "com.amazonaws.glacier#MissingParameterValueException": - throw await de_MissingParameterValueExceptionRes(parsedOutput, context); - case "RequestTimeoutException": - case "com.amazonaws.glacier#RequestTimeoutException": - throw await de_RequestTimeoutExceptionRes(parsedOutput, context); - case "ResourceNotFoundException": - case "com.amazonaws.glacier#ResourceNotFoundException": - throw await de_ResourceNotFoundExceptionRes(parsedOutput, context); - case "ServiceUnavailableException": - case "com.amazonaws.glacier#ServiceUnavailableException": - throw await de_ServiceUnavailableExceptionRes(parsedOutput, context); - default: - const parsedBody = parsedOutput.body; - return throwDefaultError({ - output, - parsedBody, - errorCode, - }) as never; - } -}; - -const throwDefaultError = withBaseException(__BaseException); -/** - * deserializeAws_restJson1InvalidParameterValueExceptionRes - */ -const de_InvalidParameterValueExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - code: __expectString, - message: __expectString, - type: __expectString, - }); - Object.assign(contents, doc); - const exception = new InvalidParameterValueException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1MissingParameterValueExceptionRes - */ -const de_MissingParameterValueExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - code: __expectString, - message: __expectString, - type: __expectString, - }); - Object.assign(contents, doc); - const exception = new MissingParameterValueException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1RequestTimeoutExceptionRes - */ -const de_RequestTimeoutExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - code: __expectString, - message: __expectString, - type: __expectString, - }); - Object.assign(contents, doc); - const exception = new RequestTimeoutException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1ResourceNotFoundExceptionRes - */ -const de_ResourceNotFoundExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - code: __expectString, - message: __expectString, - type: __expectString, - }); - Object.assign(contents, doc); - const exception = new ResourceNotFoundException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -/** - * deserializeAws_restJson1ServiceUnavailableExceptionRes - */ -const de_ServiceUnavailableExceptionRes = async ( - parsedOutput: any, - context: __SerdeContext -): Promise => { - const contents: any = map({}); - const data: any = parsedOutput.body; - const doc = take(data, { - code: __expectString, - message: __expectString, - type: __expectString, - }); - Object.assign(contents, doc); - const exception = new ServiceUnavailableException({ - $metadata: deserializeMetadata(parsedOutput), - ...contents, - }); - return __decorateServiceException(exception, parsedOutput.body); -}; - -const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ - httpStatusCode: output.statusCode, - requestId: - output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"], - extendedRequestId: output.headers["x-amz-id-2"], - cfId: output.headers["x-amz-cf-id"], -}); - -// Encode Uint8Array data into string with utf-8. -const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => - collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); - -const _aD = "archiveDescription"; -const _aI = "archiveId"; -const _c = "checksum"; -const _cr = "content-range"; -const _l = "location"; -const _r = "range"; -const _xaad = "x-amz-archive-description"; -const _xaai = "x-amz-archive-id"; -const _xasth = "x-amz-sha256-tree-hash"; diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/runtimeConfig.shared.ts b/private/aws-protocoltests-restjson-schema-glacier/src/runtimeConfig.shared.ts index bcc35b5b08958..3c747f3828d6a 100644 --- a/private/aws-protocoltests-restjson-schema-glacier/src/runtimeConfig.shared.ts +++ b/private/aws-protocoltests-restjson-schema-glacier/src/runtimeConfig.shared.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { AwsSdkSigV4Signer } from "@aws-sdk/core"; +import { AwsRestJsonProtocol } from "@aws-sdk/core/protocols"; import { NoOpLogger } from "@smithy/smithy-client"; import { IdentityProviderConfig } from "@smithy/types"; import { parseUrl } from "@smithy/url-parser"; @@ -30,6 +31,7 @@ export const getRuntimeConfig = (config: GlacierClientConfig) => { }, ], logger: config?.logger ?? new NoOpLogger(), + protocol: config?.protocol ?? new AwsRestJsonProtocol({ defaultNamespace: "com.amazonaws.glacier" }), serviceId: config?.serviceId ?? "Glacier", urlParser: config?.urlParser ?? parseUrl, utf8Decoder: config?.utf8Decoder ?? fromUtf8, diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_0.ts b/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_0.ts new file mode 100644 index 0000000000000..fc22299d26e4d --- /dev/null +++ b/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_0.ts @@ -0,0 +1,53 @@ +export const _ACO = "ArchiveCreationOutput"; +export const _CR = "Content-Range"; +export const _IPVE = "InvalidParameterValueException"; +export const _L = "Location"; +export const _MPVE = "MissingParameterValueException"; +export const _RNFE = "ResourceNotFoundException"; +export const _RTE = "RequestTimeoutException"; +export const _S = "Stream"; +export const _SUE = "ServiceUnavailableException"; +export const _UA = "UploadArchive"; +export const _UAI = "UploadArchiveInput"; +export const _UMP = "UploadMultipartPart"; +export const _UMPI = "UploadMultipartPartInput"; +export const _UMPO = "UploadMultipartPartOutput"; +export const _aD = "archiveDescription"; +export const _aI = "archiveId"; +export const _aIc = "accountId"; +export const _b = "body"; +export const _c = "checksum"; +export const _cl = "client"; +export const _co = "code"; +export const _e = "error"; +export const _h = "http"; +export const _hE = "httpError"; +export const _hH = "httpHeader"; +export const _l = "location"; +export const _m = "message"; +export const _r = "range"; +export const _s = "streaming"; +export const _se = "server"; +export const _t = "type"; +export const _uI = "uploadId"; +export const _vN = "vaultName"; +export const _xaad = "x-amz-archive-description"; +export const _xaai = "x-amz-archive-id"; +export const _xasth = "x-amz-sha256-tree-hash"; +export const n0 = "com.amazonaws.glacier"; + +// smithy-typescript generated code +import { error } from "@smithy/core/schema"; + +import { GlacierServiceException as __GlacierServiceException } from "../models/GlacierServiceException"; + +/* eslint no-var: 0 */ + +export var GlacierServiceException = error( + "smithy.ts.sdk.synthetic.com.amazonaws.glacier", + "GlacierServiceException", + 0, + [], + [], + __GlacierServiceException +); diff --git a/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_1_Upload.ts b/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_1_Upload.ts new file mode 100644 index 0000000000000..68af7c199ed5b --- /dev/null +++ b/private/aws-protocoltests-restjson-schema-glacier/src/schemas/schemas_1_Upload.ts @@ -0,0 +1,220 @@ +// smithy-typescript generated code +import { error, op, sim, struct } from "@smithy/core/schema"; + +import { + InvalidParameterValueException as __InvalidParameterValueException, + MissingParameterValueException as __MissingParameterValueException, + RequestTimeoutException as __RequestTimeoutException, + ResourceNotFoundException as __ResourceNotFoundException, + ServiceUnavailableException as __ServiceUnavailableException, +} from "../models/index"; +import { + _ACO, + _aD, + _aI, + _aIc, + _b, + _c, + _cl, + _co, + _CR, + _e, + _h, + _hE, + _hH, + _IPVE, + _L, + _l, + _m, + _MPVE, + _r, + _RNFE, + _RTE, + _S, + _s, + _se, + _SUE, + _t, + _UA, + _UAI, + _uI, + _UMP, + _UMPI, + _UMPO, + _vN, + _xaad, + _xaai, + _xasth, + n0, +} from "./schemas_0"; + +/* eslint no-var: 0 */ + +export var _Stream = sim(n0, _S, 42, { + [_s]: 1, +}); +export var ArchiveCreationOutput = struct( + n0, + _ACO, + 0, + [_l, _c, _aI], + [ + [ + 0, + { + [_hH]: _L, + }, + ], + [ + 0, + { + [_hH]: _xasth, + }, + ], + [ + 0, + { + [_hH]: _xaai, + }, + ], + ] +); +export var InvalidParameterValueException = error( + n0, + _IPVE, + { + [_e]: _cl, + [_hE]: 400, + }, + [_t, _co, _m], + [0, 0, 0], + + __InvalidParameterValueException +); +export var MissingParameterValueException = error( + n0, + _MPVE, + { + [_e]: _cl, + [_hE]: 400, + }, + [_t, _co, _m], + [0, 0, 0], + + __MissingParameterValueException +); +export var RequestTimeoutException = error( + n0, + _RTE, + { + [_e]: _cl, + [_hE]: 408, + }, + [_t, _co, _m], + [0, 0, 0], + + __RequestTimeoutException +); +export var ResourceNotFoundException = error( + n0, + _RNFE, + { + [_e]: _cl, + [_hE]: 404, + }, + [_t, _co, _m], + [0, 0, 0], + + __ResourceNotFoundException +); +export var ServiceUnavailableException = error( + n0, + _SUE, + { + [_e]: _se, + [_hE]: 500, + }, + [_t, _co, _m], + [0, 0, 0], + + __ServiceUnavailableException +); +export var UploadArchiveInput = struct( + n0, + _UAI, + 0, + [_vN, _aIc, _aD, _c, _b], + [ + [0, 1], + [0, 1], + [ + 0, + { + [_hH]: _xaad, + }, + ], + [ + 0, + { + [_hH]: _xasth, + }, + ], + [() => _Stream, 16], + ] +); +export var UploadMultipartPartInput = struct( + n0, + _UMPI, + 0, + [_aIc, _vN, _uI, _c, _r, _b], + [ + [0, 1], + [0, 1], + [0, 1], + [ + 0, + { + [_hH]: _xasth, + }, + ], + [ + 0, + { + [_hH]: _CR, + }, + ], + [() => _Stream, 16], + ] +); +export var UploadMultipartPartOutput = struct( + n0, + _UMPO, + 0, + [_c], + [ + [ + 0, + { + [_hH]: _xasth, + }, + ], + ] +); +export var UploadArchive = op( + n0, + _UA, + { + [_h]: ["POST", "/{accountId}/vaults/{vaultName}/archives", 201], + }, + () => UploadArchiveInput, + () => ArchiveCreationOutput +); +export var UploadMultipartPart = op( + n0, + _UMP, + { + [_h]: ["PUT", "/{accountId}/vaults/{vaultName}/multipart-uploads/{uploadId}", 204], + }, + () => UploadMultipartPartInput, + () => UploadMultipartPartOutput +); diff --git a/private/aws-protocoltests-restjson-schema/src/schemas/schemas_2_Json.ts b/private/aws-protocoltests-restjson-schema/src/schemas/schemas_2_Json.ts index 5f7d47d45c102..e7366a247ec6b 100644 --- a/private/aws-protocoltests-restjson-schema/src/schemas/schemas_2_Json.ts +++ b/private/aws-protocoltests-restjson-schema/src/schemas/schemas_2_Json.ts @@ -219,7 +219,7 @@ import { n2, } from "./schemas_0"; import { Unit } from "./schemas_15_Json"; -import { GreetingStruct_n1 } from "./schemas_32_Json"; +import { GreetingStruct } from "./schemas_32_Json"; /* eslint no-var: 0 */ @@ -749,7 +749,7 @@ export var StructureListMember = struct( ] ); export var UnionInputOutput = struct(n0, _UIO, 0, [_con], [() => MyUnion]); -export var GreetingStruct = struct(n2, _GS, 0, [_sa], [0]); +export var GreetingStruct_n2 = struct(n2, _GS, 0, [_sa], [0]); export var StructureList = list(n0, _SLt, 0, [() => StructureListMember, 0]); export var TestStringList = 64 | 0; @@ -773,7 +773,7 @@ export var DenseNumberMap = 128 | 1; export var DenseSetMap = map(n0, _DSM, 0, 0, 64 | 0); export var DenseStringMap = 128 | 0; -export var DenseStructMap = map(n0, _DSMe, 0, 0, () => GreetingStruct_n1); +export var DenseStructMap = map(n0, _DSMe, 0, 0, () => GreetingStruct); export var SparseBooleanMap = map( n0, _SBM, @@ -808,7 +808,7 @@ export var SparseStructMap = map( [_sp]: 1, }, 0, - () => GreetingStruct_n1 + () => GreetingStruct ); export var TestStringMap = 128 | 0; @@ -826,7 +826,7 @@ export var MyUnion = uni( _MU, 0, [_sV, _bVo, _nVu, _bVl, _tV, _eV, _lVi, _mV, _sVt, _rSV], - [0, 2, 1, 21, 4, 0, 64 | 0, 128 | 0, () => GreetingStruct_n1, () => GreetingStruct] + [0, 2, 1, 21, 4, 0, 64 | 0, 128 | 0, () => GreetingStruct, () => GreetingStruct_n2] ); export var AllQueryStringTypes = op( n0, diff --git a/private/aws-protocoltests-restjson-schema/src/schemas/schemas_32_Json.ts b/private/aws-protocoltests-restjson-schema/src/schemas/schemas_32_Json.ts index c142a49cd0ec9..ee81be803c76c 100644 --- a/private/aws-protocoltests-restjson-schema/src/schemas/schemas_32_Json.ts +++ b/private/aws-protocoltests-restjson-schema/src/schemas/schemas_32_Json.ts @@ -6,7 +6,7 @@ import { Unit } from "./schemas_15_Json"; /* eslint no-var: 0 */ -export var GreetingStruct_n1 = struct(n1, _GS, 0, [_hi], [0]); +export var GreetingStruct = struct(n1, _GS, 0, [_hi], [0]); export var MalformedAcceptWithBody = op( n0, _MAWB, @@ -14,7 +14,7 @@ export var MalformedAcceptWithBody = op( [_ht]: ["POST", "/MalformedAcceptWithBody", 200], }, () => Unit, - () => GreetingStruct_n1 + () => GreetingStruct ); export var MalformedContentTypeWithBody = op( n0, @@ -22,6 +22,6 @@ export var MalformedContentTypeWithBody = op( { [_ht]: ["POST", "/MalformedContentTypeWithBody", 200], }, - () => GreetingStruct_n1, + () => GreetingStruct, () => Unit ); diff --git a/yarn.lock b/yarn.lock index 5df9cf45232ed..8ee2d1996cd14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -556,13 +556,11 @@ __metadata: "@smithy/util-utf8": "npm:^4.0.0" "@tsconfig/node18": "npm:18.2.4" "@types/node": "npm:^18.19.69" - "@types/uuid": "npm:^9.0.1" concurrently: "npm:7.0.0" downlevel-dts: "npm:0.10.1" rimraf: "npm:3.0.2" tslib: "npm:^2.6.2" typescript: "npm:~5.8.3" - uuid: "npm:^9.0.1" vitest: "npm:^3.2.4" languageName: unknown linkType: soft @@ -946,13 +944,11 @@ __metadata: "@smithy/util-utf8": "npm:^4.0.0" "@tsconfig/node18": "npm:18.2.4" "@types/node": "npm:^18.19.69" - "@types/uuid": "npm:^9.0.1" concurrently: "npm:7.0.0" downlevel-dts: "npm:0.10.1" rimraf: "npm:3.0.2" tslib: "npm:^2.6.2" typescript: "npm:~5.8.3" - uuid: "npm:^9.0.1" vitest: "npm:^3.2.4" languageName: unknown linkType: soft @@ -1004,13 +1000,11 @@ __metadata: "@smithy/util-utf8": "npm:^4.0.0" "@tsconfig/node18": "npm:18.2.4" "@types/node": "npm:^18.19.69" - "@types/uuid": "npm:^9.0.1" concurrently: "npm:7.0.0" downlevel-dts: "npm:0.10.1" rimraf: "npm:3.0.2" tslib: "npm:^2.6.2" typescript: "npm:~5.8.3" - uuid: "npm:^9.0.1" vitest: "npm:^3.2.4" languageName: unknown linkType: soft