": "DOCUMENT_VALUE",
+ * // },
+ * // };
+ *
+ * ```
+ *
+ * @param DocumentTypeAsMapValueCommandInput - {@link DocumentTypeAsMapValueCommandInput}
+ * @returns {@link DocumentTypeAsMapValueCommandOutput}
+ * @see {@link DocumentTypeAsMapValueCommandInput} for command's `input` shape.
+ * @see {@link DocumentTypeAsMapValueCommandOutput} for command's `response` shape.
+ * @see {@link RestJsonProtocolClientResolvedConfig | config} for RestJsonProtocolClient's `config` shape.
+ *
+ * @throws {@link RestJsonProtocolServiceException}
+ * Base exception class for all service exceptions from RestJsonProtocol service.
+ *
+ */
+export class DocumentTypeAsMapValueCommand extends $Command
+ .classBuilder<
+ DocumentTypeAsMapValueCommandInput,
+ DocumentTypeAsMapValueCommandOutput,
+ RestJsonProtocolClientResolvedConfig,
+ ServiceInputTypes,
+ ServiceOutputTypes
+ >()
+ .m(function (this: any, Command: any, cs: any, config: RestJsonProtocolClientResolvedConfig, o: any) {
+ return [getSerdePlugin(config, this.serialize, this.deserialize)];
+ })
+ .s("RestJson", "DocumentTypeAsMapValue", {})
+ .n("RestJsonProtocolClient", "DocumentTypeAsMapValueCommand")
+ .f(void 0, void 0)
+ .ser(se_DocumentTypeAsMapValueCommand)
+ .de(de_DocumentTypeAsMapValueCommand)
+ .build() {}
diff --git a/private/aws-protocoltests-restjson/src/commands/index.ts b/private/aws-protocoltests-restjson/src/commands/index.ts
index 24a9d0e68bf1..3a55df08e052 100644
--- a/private/aws-protocoltests-restjson/src/commands/index.ts
+++ b/private/aws-protocoltests-restjson/src/commands/index.ts
@@ -3,6 +3,7 @@ export * from "./AllQueryStringTypesCommand";
export * from "./ConstantAndVariableQueryStringCommand";
export * from "./ConstantQueryStringCommand";
export * from "./DatetimeOffsetsCommand";
+export * from "./DocumentTypeAsMapValueCommand";
export * from "./DocumentTypeAsPayloadCommand";
export * from "./DocumentTypeCommand";
export * from "./EmptyInputAndEmptyOutputCommand";
diff --git a/private/aws-protocoltests-restjson/src/extensionConfiguration.ts b/private/aws-protocoltests-restjson/src/extensionConfiguration.ts
index ec5becc26b8b..c6f06b73c692 100644
--- a/private/aws-protocoltests-restjson/src/extensionConfiguration.ts
+++ b/private/aws-protocoltests-restjson/src/extensionConfiguration.ts
@@ -3,10 +3,13 @@ import { AwsRegionExtensionConfiguration } from "@aws-sdk/types";
import { HttpHandlerExtensionConfiguration } from "@smithy/protocol-http";
import { DefaultExtensionConfiguration } from "@smithy/types";
+import { HttpAuthExtensionConfiguration } from "./auth/httpAuthExtensionConfiguration";
+
/**
* @internal
*/
export interface RestJsonProtocolExtensionConfiguration
extends HttpHandlerExtensionConfiguration,
DefaultExtensionConfiguration,
- AwsRegionExtensionConfiguration {}
+ AwsRegionExtensionConfiguration,
+ HttpAuthExtensionConfiguration {}
diff --git a/private/aws-protocoltests-restjson/src/models/models_0.ts b/private/aws-protocoltests-restjson/src/models/models_0.ts
index 9252bb3db789..24b54683521f 100644
--- a/private/aws-protocoltests-restjson/src/models/models_0.ts
+++ b/private/aws-protocoltests-restjson/src/models/models_0.ts
@@ -126,6 +126,13 @@ export interface DocumentTypeInputOutput {
documentValue?: __DocumentType;
}
+/**
+ * @public
+ */
+export interface DocumentTypeAsMapValueInputOutput {
+ docValuedMap?: Record;
+}
+
/**
* @public
*/
diff --git a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts
index edc1fe6d309e..34b5e5405699 100644
--- a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts
+++ b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts
@@ -64,6 +64,10 @@ import {
ConstantQueryStringCommandOutput,
} from "../commands/ConstantQueryStringCommand";
import { DatetimeOffsetsCommandInput, DatetimeOffsetsCommandOutput } from "../commands/DatetimeOffsetsCommand";
+import {
+ DocumentTypeAsMapValueCommandInput,
+ DocumentTypeAsMapValueCommandOutput,
+} from "../commands/DocumentTypeAsMapValueCommand";
import {
DocumentTypeAsPayloadCommandInput,
DocumentTypeAsPayloadCommandOutput,
@@ -466,6 +470,28 @@ export const se_DocumentTypeCommand = async (
return b.build();
};
+/**
+ * serializeAws_restJson1DocumentTypeAsMapValueCommand
+ */
+export const se_DocumentTypeAsMapValueCommand = async (
+ input: DocumentTypeAsMapValueCommandInput,
+ context: __SerdeContext
+): Promise<__HttpRequest> => {
+ const b = rb(input, context);
+ const headers: any = {
+ "content-type": "application/json",
+ };
+ b.bp("/DocumentTypeAsMapValue");
+ let body: any;
+ body = JSON.stringify(
+ take(input, {
+ docValuedMap: (_) => se_DocumentValuedMap(_, context),
+ })
+ );
+ b.m("PUT").h(headers).b(body);
+ return b.build();
+};
+
/**
* serializeAws_restJson1DocumentTypeAsPayloadCommand
*/
@@ -2546,6 +2572,27 @@ export const de_DocumentTypeCommand = async (
return contents;
};
+/**
+ * deserializeAws_restJson1DocumentTypeAsMapValueCommand
+ */
+export const de_DocumentTypeAsMapValueCommand = 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, {
+ docValuedMap: (_) => de_DocumentValuedMap(_, context),
+ });
+ Object.assign(contents, doc);
+ return contents;
+};
+
/**
* deserializeAws_restJson1DocumentTypeAsPayloadCommand
*/
@@ -4355,6 +4402,19 @@ const se_Document = (input: __DocumentType, context: __SerdeContext): any => {
return input;
};
+/**
+ * serializeAws_restJson1DocumentValuedMap
+ */
+const se_DocumentValuedMap = (input: Record, context: __SerdeContext): any => {
+ return Object.entries(input).reduce((acc: Record, [key, value]: [string, any]) => {
+ if (value === null) {
+ return acc;
+ }
+ acc[key] = se_Document(value, context);
+ return acc;
+ }, {});
+};
+
/**
* serializeAws_restJson1MyUnion
*/
@@ -4593,6 +4653,19 @@ const de_Document = (output: any, context: __SerdeContext): __DocumentType => {
return output;
};
+/**
+ * deserializeAws_restJson1DocumentValuedMap
+ */
+const de_DocumentValuedMap = (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] = de_Document(value, context);
+ return acc;
+ }, {} as Record);
+};
+
/**
* deserializeAws_restJson1MyUnion
*/
diff --git a/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts b/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts
index 79d7d04c9dd4..bf065edd6ece 100644
--- a/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts
+++ b/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts
@@ -7,6 +7,7 @@ import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import { blobHasher as streamHasher } from "@smithy/hash-blob-browser";
+import { invalidProvider } from "@smithy/invalid-dependency";
import { Md5 } from "@smithy/md5-js";
import {
DEFAULT_DISABLE_REQUEST_COMPRESSION,
@@ -32,12 +33,15 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => {
runtime: "browser",
defaultsMode,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
+ credentialDefaultProvider:
+ config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression: config?.disableRequestCompression ?? DEFAULT_DISABLE_REQUEST_COMPRESSION,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
md5: config?.md5 ?? Md5,
+ region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
diff --git a/private/aws-protocoltests-restjson/src/runtimeConfig.shared.ts b/private/aws-protocoltests-restjson/src/runtimeConfig.shared.ts
index bb5525960c79..5b4afad04c50 100644
--- a/private/aws-protocoltests-restjson/src/runtimeConfig.shared.ts
+++ b/private/aws-protocoltests-restjson/src/runtimeConfig.shared.ts
@@ -1,10 +1,13 @@
// smithy-typescript generated code
+import { AwsSdkSigV4Signer } from "@aws-sdk/core";
import { NoOpLogger } from "@smithy/smithy-client";
+import { IdentityProviderConfig } from "@smithy/types";
import { parseUrl } from "@smithy/url-parser";
import { fromBase64, toBase64 } from "@smithy/util-base64";
import { sdkStreamMixin } from "@smithy/util-stream";
import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
+import { defaultRestJsonProtocolHttpAuthSchemeProvider } from "./auth/httpAuthSchemeProvider";
import { defaultRegionInfoProvider } from "./endpoints";
import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient";
@@ -18,6 +21,14 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => {
base64Encoder: config?.base64Encoder ?? toBase64,
disableHostPrefix: config?.disableHostPrefix ?? false,
extensions: config?.extensions ?? [],
+ httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? defaultRestJsonProtocolHttpAuthSchemeProvider,
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
+ {
+ schemeId: "aws.auth#sigv4",
+ identityProvider: (ipc: IdentityProviderConfig) => ipc.getIdentityProvider("aws.auth#sigv4"),
+ signer: new AwsSdkSigV4Signer(),
+ },
+ ],
logger: config?.logger ?? new NoOpLogger(),
regionInfoProvider: config?.regionInfoProvider ?? defaultRegionInfoProvider,
sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin,
diff --git a/private/aws-protocoltests-restjson/src/runtimeConfig.ts b/private/aws-protocoltests-restjson/src/runtimeConfig.ts
index 7778de85a67a..70af9e84c410 100644
--- a/private/aws-protocoltests-restjson/src/runtimeConfig.ts
+++ b/private/aws-protocoltests-restjson/src/runtimeConfig.ts
@@ -3,8 +3,11 @@
import packageInfo from "../package.json"; // eslint-disable-line
import { emitWarningIfUnsupportedVersion as awsCheckVersion } from "@aws-sdk/core";
+import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
import {
+ NODE_REGION_CONFIG_FILE_OPTIONS,
+ NODE_REGION_CONFIG_OPTIONS,
NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
} from "@smithy/config-resolver";
@@ -40,6 +43,7 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => {
runtime: "node",
defaultsMode,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
+ credentialDefaultProvider: config?.credentialDefaultProvider ?? credentialDefaultProvider,
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
@@ -47,6 +51,7 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => {
config?.disableRequestCompression ?? loadNodeConfig(NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
md5: config?.md5 ?? Hash.bind(null, "md5"),
+ region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? loadNodeConfig(NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS),
diff --git a/private/aws-protocoltests-restjson/src/runtimeExtensions.ts b/private/aws-protocoltests-restjson/src/runtimeExtensions.ts
index be1bca829e19..cd43be135f33 100644
--- a/private/aws-protocoltests-restjson/src/runtimeExtensions.ts
+++ b/private/aws-protocoltests-restjson/src/runtimeExtensions.ts
@@ -6,6 +6,7 @@ import {
import { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig } from "@smithy/protocol-http";
import { getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig } from "@smithy/smithy-client";
+import { getHttpAuthExtensionConfiguration, resolveHttpAuthRuntimeConfig } from "./auth/httpAuthExtensionConfiguration";
import { RestJsonProtocolExtensionConfiguration } from "./extensionConfiguration";
/**
@@ -32,6 +33,7 @@ export const resolveRuntimeExtensions = (runtimeConfig: any, extensions: Runtime
...asPartial(getAwsRegionExtensionConfiguration(runtimeConfig)),
...asPartial(getDefaultExtensionConfiguration(runtimeConfig)),
...asPartial(getHttpHandlerExtensionConfiguration(runtimeConfig)),
+ ...asPartial(getHttpAuthExtensionConfiguration(runtimeConfig)),
};
extensions.forEach((extension) => extension.configure(extensionConfiguration));
@@ -41,5 +43,6 @@ export const resolveRuntimeExtensions = (runtimeConfig: any, extensions: Runtime
...resolveAwsRegionExtensionConfiguration(extensionConfiguration),
...resolveDefaultRuntimeConfig(extensionConfiguration),
...resolveHttpHandlerRuntimeConfig(extensionConfiguration),
+ ...resolveHttpAuthRuntimeConfig(extensionConfiguration),
};
};
diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts
index dc95c5d9999a..84a876e071ef 100644
--- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts
+++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts
@@ -9,6 +9,7 @@ import { AllQueryStringTypesCommand } from "../../src/commands/AllQueryStringTyp
import { ConstantAndVariableQueryStringCommand } from "../../src/commands/ConstantAndVariableQueryStringCommand";
import { ConstantQueryStringCommand } from "../../src/commands/ConstantQueryStringCommand";
import { DatetimeOffsetsCommand } from "../../src/commands/DatetimeOffsetsCommand";
+import { DocumentTypeAsMapValueCommand } from "../../src/commands/DocumentTypeAsMapValueCommand";
import { DocumentTypeAsPayloadCommand } from "../../src/commands/DocumentTypeAsPayloadCommand";
import { DocumentTypeCommand } from "../../src/commands/DocumentTypeCommand";
import { EmptyInputAndEmptyOutputCommand } from "../../src/commands/EmptyInputAndEmptyOutputCommand";
@@ -578,6 +579,47 @@ it("RestJsonSupportsNegativeInfinityFloatQueryValues:Request", async () => {
}
});
+/**
+ * Query values of 0 and false are serialized
+ */
+it("RestJsonZeroAndFalseQueryValues:Request", async () => {
+ const client = new RestJsonProtocolClient({
+ ...clientParams,
+ requestHandler: new RequestSerializationTestHandler(),
+ });
+
+ const command = new AllQueryStringTypesCommand({
+ queryInteger: 0,
+
+ queryBoolean: false,
+
+ queryParamsMapOfStringList: {
+ queryInteger: ["0"],
+
+ queryBoolean: ["false"],
+ } as any,
+ } as any);
+ try {
+ await client.send(command);
+ fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
+ return;
+ } catch (err) {
+ if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
+ fail(err);
+ return;
+ }
+ const r = err.request;
+ expect(r.method).toBe("GET");
+ expect(r.path).toBe("/AllQueryStringTypesInput");
+
+ const queryString = buildQueryString(r.query);
+ expect(queryString).toContain("Integer=0");
+ expect(queryString).toContain("Boolean=false");
+
+ expect(r.body).toBeFalsy();
+ }
+});
+
/**
* Mixes constant and variable query string parameters
*/
@@ -1222,6 +1264,110 @@ it("DocumentOutputArray:Response", async () => {
});
});
+/**
+ * Serializes a map that uses documents as the value.
+ */
+it("DocumentTypeAsMapValueInput:Request", async () => {
+ const client = new RestJsonProtocolClient({
+ ...clientParams,
+ requestHandler: new RequestSerializationTestHandler(),
+ });
+
+ const command = new DocumentTypeAsMapValueCommand({
+ docValuedMap: {
+ foo: {
+ f: 1,
+ o: 2,
+ },
+
+ bar: ["b", "a", "r"],
+
+ baz: "BAZ",
+ } as any,
+ } as any);
+ try {
+ await client.send(command);
+ fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
+ return;
+ } catch (err) {
+ if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
+ fail(err);
+ return;
+ }
+ const r = err.request;
+ expect(r.method).toBe("PUT");
+ expect(r.path).toBe("/DocumentTypeAsMapValue");
+
+ expect(r.headers["content-type"]).toBeDefined();
+ expect(r.headers["content-type"]).toBe("application/json");
+
+ expect(r.body).toBeDefined();
+ const utf8Encoder = client.config.utf8Encoder;
+ const bodyString = `{
+ \"docValuedMap\": {
+ \"foo\": { \"f\": 1, \"o\": 2 },
+ \"bar\": [ \"b\", \"a\", \"r\" ],
+ \"baz\": \"BAZ\"
+ }
+ }`;
+ const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString());
+ expect(unequalParts).toBeUndefined();
+ }
+});
+
+/**
+ * Serializes a map that uses documents as the value.
+ */
+it("DocumentTypeAsMapValueOutput:Response", async () => {
+ const client = new RestJsonProtocolClient({
+ ...clientParams,
+ requestHandler: new ResponseDeserializationTestHandler(
+ true,
+ 200,
+ {
+ "content-type": "application/json",
+ },
+ `{
+ "docValuedMap": {
+ "foo": { "f": 1, "o": 2 },
+ "bar": [ "b", "a", "r" ],
+ "baz": "BAZ"
+ }
+ }`
+ ),
+ });
+
+ const params: any = {};
+ const command = new DocumentTypeAsMapValueCommand(params);
+
+ let r: any;
+ try {
+ r = await client.send(command);
+ } catch (err) {
+ fail("Expected a valid response to be returned, got " + err);
+ return;
+ }
+ expect(r["$metadata"].httpStatusCode).toBe(200);
+ const paramsToValidate: any = [
+ {
+ docValuedMap: {
+ foo: {
+ f: 1,
+ o: 2,
+ },
+
+ bar: ["b", "a", "r"],
+
+ baz: "BAZ",
+ },
+ },
+ ][0];
+ Object.keys(paramsToValidate).forEach((param) => {
+ expect(r[param]).toBeDefined();
+ expect(equivalentContents(r[param], paramsToValidate[param])).toBe(true);
+ });
+});
+
/**
* Serializes a document as the target of the httpPayload trait.
*/
diff --git a/private/aws-protocoltests-restxml/README.md b/private/aws-protocoltests-restxml/README.md
index 2fa60bce6554..cd413c194755 100644
--- a/private/aws-protocoltests-restxml/README.md
+++ b/private/aws-protocoltests-restxml/README.md
@@ -954,6 +954,14 @@ DocumentType
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/rest-xml-protocol/command/DocumentTypeCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/DocumentTypeCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-rest-xml-protocol/Interface/DocumentTypeCommandOutput/)
+