From bdd705447aa53ea28dd882caa79da7ae5779495e Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 26 Jun 2025 14:49:09 -0400 Subject: [PATCH 1/2] chore(codegen): sync codegen version, no AWS changes --- scripts/generate-clients/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-clients/config.js b/scripts/generate-clients/config.js index 2f4ddcfdf7b5..1abada02751f 100644 --- a/scripts/generate-clients/config.js +++ b/scripts/generate-clients/config.js @@ -1,7 +1,7 @@ // Update this commit when taking up new changes from smithy-typescript. module.exports = { // Use full commit hash as we explicitly fetch it. - SMITHY_TS_COMMIT: "1308a1e047fffd2cfd99bcdf72c9cc2f4871ce1a", + SMITHY_TS_COMMIT: "c2a6b1b86ba92e467c517460fc84fe84ee72380b", }; if (module.exports.SMITHY_TS_COMMIT.length < 40) { From 2fdd3e1091c11003779dbcdb47b21485baae25c1 Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 26 Jun 2025 15:20:12 -0400 Subject: [PATCH 2/2] chore: codegen update --- .../src/EC2ProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/EC2ProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/JSONRPC10Client.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/JSONRPC10Client.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/MachineLearningClient.ts | 18 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/JsonProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/JsonProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/QueryProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/QueryProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/APIGatewayClient.ts | 18 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/GlacierClient.ts | 18 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/RestJsonProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/schemas/schemas.ts | 14 +- .../src/RestJsonProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/RestXmlProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/RestXmlProtocolClient.ts | 20 +- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- .../src/endpoint/EndpointParameters.ts | 15 +- .../src/endpoint/endpointResolver.ts | 2 +- .../src/endpoint/ruleset.ts | 324 +++++++++++++++++- 67 files changed, 5655 insertions(+), 450 deletions(-) diff --git a/private/aws-protocoltests-ec2-schema/src/EC2ProtocolClient.ts b/private/aws-protocoltests-ec2-schema/src/EC2ProtocolClient.ts index a99fc57373be..27fc0b507f4f 100644 --- a/private/aws-protocoltests-ec2-schema/src/EC2ProtocolClient.ts +++ b/private/aws-protocoltests-ec2-schema/src/EC2ProtocolClient.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -357,7 +350,6 @@ export type EC2ProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpHa RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -379,7 +371,6 @@ export type EC2ProtocolClientResolvedConfigType = __SmithyResolvedConfiguration< RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -415,11 +406,10 @@ export class EC2ProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-ec2-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-ec2-schema/src/endpoint/EndpointParameters.ts index fcbad95e0acf..2d1acfe92c2c 100644 --- a/private/aws-protocoltests-ec2-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-ec2-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "ec2query", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-ec2-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-ec2-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-ec2-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-ec2-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-ec2-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-ec2-schema/src/endpoint/ruleset.ts index 14416a50b269..6195aa19a36f 100644 --- a/private/aws-protocoltests-ec2-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-ec2-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsec2-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://awsec2.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://awsec2-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsec2.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://awsec2.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-ec2/src/EC2ProtocolClient.ts b/private/aws-protocoltests-ec2/src/EC2ProtocolClient.ts index 8307873cd5f6..b130debb5c9a 100644 --- a/private/aws-protocoltests-ec2/src/EC2ProtocolClient.ts +++ b/private/aws-protocoltests-ec2/src/EC2ProtocolClient.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -343,7 +336,6 @@ export type EC2ProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpHa RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -365,7 +357,6 @@ export type EC2ProtocolClientResolvedConfigType = __SmithyResolvedConfiguration< RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -401,11 +392,10 @@ export class EC2ProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-ec2/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-ec2/src/endpoint/EndpointParameters.ts index fcbad95e0acf..2d1acfe92c2c 100644 --- a/private/aws-protocoltests-ec2/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-ec2/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "ec2query", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-ec2/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-ec2/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-ec2/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-ec2/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-ec2/src/endpoint/ruleset.ts b/private/aws-protocoltests-ec2/src/endpoint/ruleset.ts index 14416a50b269..6195aa19a36f 100644 --- a/private/aws-protocoltests-ec2/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-ec2/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsec2-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://awsec2.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://awsec2-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsec2.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://awsec2.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-json-10-schema/src/JSONRPC10Client.ts b/private/aws-protocoltests-json-10-schema/src/JSONRPC10Client.ts index 68d28329bba9..1e3feada8820 100644 --- a/private/aws-protocoltests-json-10-schema/src/JSONRPC10Client.ts +++ b/private/aws-protocoltests-json-10-schema/src/JSONRPC10Client.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -336,7 +329,6 @@ export type JSONRPC10ClientConfigType = Partial<__SmithyConfiguration<__HttpHand RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -358,7 +350,6 @@ export type JSONRPC10ClientResolvedConfigType = __SmithyResolvedConfiguration<__ RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -393,11 +384,10 @@ export class JSONRPC10Client extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-json-10-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-json-10-schema/src/endpoint/EndpointParameters.ts index 87c48e9924a5..d091032ef4f6 100644 --- a/private/aws-protocoltests-json-10-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-json-10-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "jsonrpc10", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-json-10-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-json-10-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-json-10-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-json-10-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-json-10-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-json-10-schema/src/endpoint/ruleset.ts index 14416a50b269..f7069d02c93b 100644 --- a/private/aws-protocoltests-json-10-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-json-10-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonrpc10-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://jsonrpc10.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://jsonrpc10-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonrpc10.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://jsonrpc10.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-json-10/src/JSONRPC10Client.ts b/private/aws-protocoltests-json-10/src/JSONRPC10Client.ts index 5742781cf93b..630c81df0d47 100644 --- a/private/aws-protocoltests-json-10/src/JSONRPC10Client.ts +++ b/private/aws-protocoltests-json-10/src/JSONRPC10Client.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -322,7 +315,6 @@ export type JSONRPC10ClientConfigType = Partial<__SmithyConfiguration<__HttpHand RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -344,7 +336,6 @@ export type JSONRPC10ClientResolvedConfigType = __SmithyResolvedConfiguration<__ RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -379,11 +370,10 @@ export class JSONRPC10Client extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; 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-10/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-json-10/src/endpoint/EndpointParameters.ts index 87c48e9924a5..d091032ef4f6 100644 --- a/private/aws-protocoltests-json-10/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-json-10/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "jsonrpc10", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-json-10/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-json-10/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-json-10/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-json-10/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-json-10/src/endpoint/ruleset.ts b/private/aws-protocoltests-json-10/src/endpoint/ruleset.ts index 14416a50b269..f7069d02c93b 100644 --- a/private/aws-protocoltests-json-10/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-json-10/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonrpc10-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://jsonrpc10.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://jsonrpc10-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonrpc10.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://jsonrpc10.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-json-machinelearning/src/MachineLearningClient.ts b/private/aws-protocoltests-json-machinelearning/src/MachineLearningClient.ts index a5f6bb138992..f6581f857c35 100644 --- a/private/aws-protocoltests-json-machinelearning/src/MachineLearningClient.ts +++ b/private/aws-protocoltests-json-machinelearning/src/MachineLearningClient.ts @@ -20,14 +20,7 @@ import { getHttpSigningPlugin, } from "@smithy/core"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -243,7 +236,6 @@ export type MachineLearningClientConfigType = Partial<__SmithyConfiguration<__Ht RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & ClientInputEndpointParameters; /** @@ -264,7 +256,6 @@ export type MachineLearningClientResolvedConfigType = __SmithyResolvedConfigurat RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & ClientResolvedEndpointParameters; /** @@ -298,10 +289,9 @@ export class MachineLearningClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); - this.config = _config_9; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); + this.config = _config_8; 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-machinelearning/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-json-machinelearning/src/endpoint/EndpointParameters.ts index 8db411c2f0fa..554c886e8139 100644 --- a/private/aws-protocoltests-json-machinelearning/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-json-machinelearning/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "machinelearning", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-json-machinelearning/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-json-machinelearning/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-json-machinelearning/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-json-machinelearning/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-json-machinelearning/src/endpoint/ruleset.ts b/private/aws-protocoltests-json-machinelearning/src/endpoint/ruleset.ts index 14416a50b269..3ec18a2b5948 100644 --- a/private/aws-protocoltests-json-machinelearning/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-json-machinelearning/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://machinelearning-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://machinelearning.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://machinelearning-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://machinelearning.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://machinelearning.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-json-schema/src/JsonProtocolClient.ts b/private/aws-protocoltests-json-schema/src/JsonProtocolClient.ts index b739c85d4acf..9387bd19b73a 100644 --- a/private/aws-protocoltests-json-schema/src/JsonProtocolClient.ts +++ b/private/aws-protocoltests-json-schema/src/JsonProtocolClient.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -342,7 +335,6 @@ export type JsonProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpH RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -364,7 +356,6 @@ export type JsonProtocolClientResolvedConfigType = __SmithyResolvedConfiguration RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -399,11 +390,10 @@ export class JsonProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-json-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-json-schema/src/endpoint/EndpointParameters.ts index e84e5db28e2f..e715b3090f24 100644 --- a/private/aws-protocoltests-json-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-json-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "jsonprotocol", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-json-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-json-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-json-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-json-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-json-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-json-schema/src/endpoint/ruleset.ts index 14416a50b269..ef66cb0fe205 100644 --- a/private/aws-protocoltests-json-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-json-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonprotocol-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://jsonprotocol.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://jsonprotocol-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonprotocol.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://jsonprotocol.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-json/src/JsonProtocolClient.ts b/private/aws-protocoltests-json/src/JsonProtocolClient.ts index 44563f5d0a4d..630cc1d60a37 100644 --- a/private/aws-protocoltests-json/src/JsonProtocolClient.ts +++ b/private/aws-protocoltests-json/src/JsonProtocolClient.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -328,7 +321,6 @@ export type JsonProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpH RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -350,7 +342,6 @@ export type JsonProtocolClientResolvedConfigType = __SmithyResolvedConfiguration RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -385,11 +376,10 @@ export class JsonProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; 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/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-json/src/endpoint/EndpointParameters.ts index e84e5db28e2f..e715b3090f24 100644 --- a/private/aws-protocoltests-json/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-json/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "jsonprotocol", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-json/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-json/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-json/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-json/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-json/src/endpoint/ruleset.ts b/private/aws-protocoltests-json/src/endpoint/ruleset.ts index 14416a50b269..ef66cb0fe205 100644 --- a/private/aws-protocoltests-json/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-json/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonprotocol-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://jsonprotocol.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://jsonprotocol-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://jsonprotocol.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://jsonprotocol.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-query-schema/src/QueryProtocolClient.ts b/private/aws-protocoltests-query-schema/src/QueryProtocolClient.ts index 0f31d6c3c917..e6520331aa24 100644 --- a/private/aws-protocoltests-query-schema/src/QueryProtocolClient.ts +++ b/private/aws-protocoltests-query-schema/src/QueryProtocolClient.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -387,7 +380,6 @@ export type QueryProtocolClientConfigType = Partial<__SmithyConfiguration<__Http RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -409,7 +401,6 @@ export type QueryProtocolClientResolvedConfigType = __SmithyResolvedConfiguratio RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -445,11 +436,10 @@ export class QueryProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-query-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-query-schema/src/endpoint/EndpointParameters.ts index 68656ebde582..725e5e21eeaf 100644 --- a/private/aws-protocoltests-query-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-query-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "awsquery", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-query-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-query-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-query-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-query-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-query-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-query-schema/src/endpoint/ruleset.ts index 14416a50b269..5b164c083e95 100644 --- a/private/aws-protocoltests-query-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-query-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsquery-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://awsquery.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://awsquery-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsquery.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://awsquery.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-query/src/QueryProtocolClient.ts b/private/aws-protocoltests-query/src/QueryProtocolClient.ts index e58e2b939e3a..fedac2ca7d89 100644 --- a/private/aws-protocoltests-query/src/QueryProtocolClient.ts +++ b/private/aws-protocoltests-query/src/QueryProtocolClient.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -373,7 +366,6 @@ export type QueryProtocolClientConfigType = Partial<__SmithyConfiguration<__Http RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -395,7 +387,6 @@ export type QueryProtocolClientResolvedConfigType = __SmithyResolvedConfiguratio RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -431,11 +422,10 @@ export class QueryProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-query/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-query/src/endpoint/EndpointParameters.ts index 68656ebde582..725e5e21eeaf 100644 --- a/private/aws-protocoltests-query/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-query/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "awsquery", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-query/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-query/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-query/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-query/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-query/src/endpoint/ruleset.ts b/private/aws-protocoltests-query/src/endpoint/ruleset.ts index 14416a50b269..5b164c083e95 100644 --- a/private/aws-protocoltests-query/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-query/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsquery-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://awsquery.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://awsquery-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://awsquery.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://awsquery.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restjson-apigateway/src/APIGatewayClient.ts b/private/aws-protocoltests-restjson-apigateway/src/APIGatewayClient.ts index 94ec7e24584e..8cfa0496fed1 100644 --- a/private/aws-protocoltests-restjson-apigateway/src/APIGatewayClient.ts +++ b/private/aws-protocoltests-restjson-apigateway/src/APIGatewayClient.ts @@ -21,14 +21,7 @@ import { getHttpSigningPlugin, } from "@smithy/core"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -244,7 +237,6 @@ export type APIGatewayClientConfigType = Partial<__SmithyConfiguration<__HttpHan RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & ClientInputEndpointParameters; /** @@ -265,7 +257,6 @@ export type APIGatewayClientResolvedConfigType = __SmithyResolvedConfiguration<_ RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & ClientResolvedEndpointParameters; /** @@ -299,10 +290,9 @@ export class APIGatewayClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); - this.config = _config_9; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); + this.config = _config_8; 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-apigateway/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restjson-apigateway/src/endpoint/EndpointParameters.ts index 87a189946351..4e94fa0b616a 100644 --- a/private/aws-protocoltests-restjson-apigateway/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restjson-apigateway/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "apigateway", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restjson-apigateway/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restjson-apigateway/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restjson-apigateway/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restjson-apigateway/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restjson-apigateway/src/endpoint/ruleset.ts b/private/aws-protocoltests-restjson-apigateway/src/endpoint/ruleset.ts index 14416a50b269..9a60adc93d07 100644 --- a/private/aws-protocoltests-restjson-apigateway/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restjson-apigateway/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://apigateway-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://apigateway.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://apigateway-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://apigateway.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://apigateway.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restjson-glacier/src/GlacierClient.ts b/private/aws-protocoltests-restjson-glacier/src/GlacierClient.ts index 9bcf4ef8e3a0..96a6ac6c6e06 100644 --- a/private/aws-protocoltests-restjson-glacier/src/GlacierClient.ts +++ b/private/aws-protocoltests-restjson-glacier/src/GlacierClient.ts @@ -21,14 +21,7 @@ import { getHttpSigningPlugin, } from "@smithy/core"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -258,7 +251,6 @@ export type GlacierClientConfigType = Partial<__SmithyConfiguration<__HttpHandle RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & ClientInputEndpointParameters; /** @@ -279,7 +271,6 @@ export type GlacierClientResolvedConfigType = __SmithyResolvedConfiguration<__Ht RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & ClientResolvedEndpointParameters; /** @@ -313,10 +304,9 @@ export class GlacierClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); - this.config = _config_9; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); + this.config = _config_8; 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-glacier/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restjson-glacier/src/endpoint/EndpointParameters.ts index 02c5bad61d75..461c6bf68ed2 100644 --- a/private/aws-protocoltests-restjson-glacier/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restjson-glacier/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "glacier", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restjson-glacier/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restjson-glacier/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restjson-glacier/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restjson-glacier/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restjson-glacier/src/endpoint/ruleset.ts b/private/aws-protocoltests-restjson-glacier/src/endpoint/ruleset.ts index 14416a50b269..b75737825c9b 100644 --- a/private/aws-protocoltests-restjson-glacier/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restjson-glacier/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://glacier-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://glacier.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://glacier-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://glacier.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://glacier.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restjson-schema/src/RestJsonProtocolClient.ts b/private/aws-protocoltests-restjson-schema/src/RestJsonProtocolClient.ts index 94ab96467284..cc019186eac0 100644 --- a/private/aws-protocoltests-restjson-schema/src/RestJsonProtocolClient.ts +++ b/private/aws-protocoltests-restjson-schema/src/RestJsonProtocolClient.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -786,7 +779,6 @@ export type RestJsonProtocolClientConfigType = Partial<__SmithyConfiguration<__H RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -808,7 +800,6 @@ export type RestJsonProtocolClientResolvedConfigType = __SmithyResolvedConfigura RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -844,11 +835,10 @@ export class RestJsonProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-restjson-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restjson-schema/src/endpoint/EndpointParameters.ts index d5908d266eb3..4cd8f2aa562a 100644 --- a/private/aws-protocoltests-restjson-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restjson-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "restjson", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restjson-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restjson-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restjson-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restjson-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restjson-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-restjson-schema/src/endpoint/ruleset.ts index 14416a50b269..6eaa2aeabbdb 100644 --- a/private/aws-protocoltests-restjson-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restjson-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restjson.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restjson-schema/src/schemas/schemas.ts b/private/aws-protocoltests-restjson-schema/src/schemas/schemas.ts index 59b70b8f679b..a654ff45d27e 100644 --- a/private/aws-protocoltests-restjson-schema/src/schemas/schemas.ts +++ b/private/aws-protocoltests-restjson-schema/src/schemas/schemas.ts @@ -2046,8 +2046,8 @@ export var TimestampFormatHeadersIO = struct( ); export var TopLevel = struct(n0, _TLo, 0, [_di, _dLi, _dMi], [() => Dialog, () => DialogList, () => DialogMap]); export var UnionInputOutput = struct(n0, _UIO, 0, [_con], [() => MyUnion]); -export var GreetingStruct = struct(n2, _GS, 0, [_sa], [0]); -export var GreetingStruct_n1 = struct(n1, _GS, 0, [_hi], [0]); +export var GreetingStruct_n2 = struct(n2, _GS, 0, [_sa], [0]); +export var GreetingStruct = struct(n1, _GS, 0, [_hi], [0]); export var Unit = "unit" as const; export var RestJsonProtocolServiceException = error( @@ -2110,7 +2110,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 DialogMap = map(n0, _DM, 0, 0, () => Dialog); export var DocumentValuedMap = 128 | 15; @@ -2150,7 +2150,7 @@ export var SparseStructMap = map( [_sp]: 1, }, 0, - () => GreetingStruct_n1 + () => GreetingStruct ); export var TestStringMap = 128 | 0; @@ -2175,7 +2175,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 PlayerAction = uni(n0, _PA, 0, [_qu], [() => Unit]); export var SimpleUnion = uni(n0, _SU, 0, [_int, _st], [1, 0]); @@ -2570,7 +2570,7 @@ export var MalformedAcceptWithBody = op( [_ht]: ["POST", "/MalformedAcceptWithBody", 200], }, () => Unit, - () => GreetingStruct_n1 + () => GreetingStruct ); export var MalformedAcceptWithGenericString = op( n0, @@ -2623,7 +2623,7 @@ export var MalformedContentTypeWithBody = op( { [_ht]: ["POST", "/MalformedContentTypeWithBody", 200], }, - () => GreetingStruct_n1, + () => GreetingStruct, () => Unit ); export var MalformedContentTypeWithGenericString = op( diff --git a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts index b230354559dc..06d5fc0d6887 100644 --- a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts +++ b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -772,7 +765,6 @@ export type RestJsonProtocolClientConfigType = Partial<__SmithyConfiguration<__H RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -794,7 +786,6 @@ export type RestJsonProtocolClientResolvedConfigType = __SmithyResolvedConfigura RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -830,11 +821,10 @@ export class RestJsonProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; 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/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restjson/src/endpoint/EndpointParameters.ts index d5908d266eb3..4cd8f2aa562a 100644 --- a/private/aws-protocoltests-restjson/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restjson/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "restjson", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restjson/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restjson/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restjson/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restjson/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restjson/src/endpoint/ruleset.ts b/private/aws-protocoltests-restjson/src/endpoint/ruleset.ts index 14416a50b269..6eaa2aeabbdb 100644 --- a/private/aws-protocoltests-restjson/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restjson/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restjson.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restxml-schema/src/RestXmlProtocolClient.ts b/private/aws-protocoltests-restxml-schema/src/RestXmlProtocolClient.ts index 2fccf567f0ac..970dd768282f 100644 --- a/private/aws-protocoltests-restxml-schema/src/RestXmlProtocolClient.ts +++ b/private/aws-protocoltests-restxml-schema/src/RestXmlProtocolClient.ts @@ -26,14 +26,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -555,7 +548,6 @@ export type RestXmlProtocolClientConfigType = Partial<__SmithyConfiguration<__Ht RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -577,7 +569,6 @@ export type RestXmlProtocolClientResolvedConfigType = __SmithyResolvedConfigurat RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -613,11 +604,10 @@ export class RestXmlProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_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)); diff --git a/private/aws-protocoltests-restxml-schema/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restxml-schema/src/endpoint/EndpointParameters.ts index a044f11f9945..c67d03508b7c 100644 --- a/private/aws-protocoltests-restxml-schema/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restxml-schema/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "restxml", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restxml-schema/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restxml-schema/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restxml-schema/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restxml-schema/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restxml-schema/src/endpoint/ruleset.ts b/private/aws-protocoltests-restxml-schema/src/endpoint/ruleset.ts index 14416a50b269..ee363a0be8df 100644 --- a/private/aws-protocoltests-restxml-schema/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restxml-schema/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restxml-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restxml.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restxml-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restxml.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restxml.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts b/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts index 4af20a823526..3d6830100c1c 100644 --- a/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts +++ b/private/aws-protocoltests-restxml/src/RestXmlProtocolClient.ts @@ -25,14 +25,7 @@ import { resolveCompressionConfig, } from "@smithy/middleware-compression"; import { getContentLengthPlugin } from "@smithy/middleware-content-length"; -import { - EndpointInputConfig, - EndpointRequiredInputConfig, - EndpointRequiredResolvedConfig, - EndpointResolvedConfig, - resolveEndpointConfig, - resolveEndpointRequiredConfig, -} from "@smithy/middleware-endpoint"; +import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint"; import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry"; import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http"; import { @@ -541,7 +534,6 @@ export type RestXmlProtocolClientConfigType = Partial<__SmithyConfiguration<__Ht RegionInputConfig & HostHeaderInputConfig & EndpointInputConfig & - EndpointRequiredInputConfig & HttpAuthSchemeInputConfig & CompressionInputConfig & ClientInputEndpointParameters; @@ -563,7 +555,6 @@ export type RestXmlProtocolClientResolvedConfigType = __SmithyResolvedConfigurat RegionResolvedConfig & HostHeaderResolvedConfig & EndpointResolvedConfig & - EndpointRequiredResolvedConfig & HttpAuthSchemeResolvedConfig & CompressionResolvedConfig & ClientResolvedEndpointParameters; @@ -599,11 +590,10 @@ export class RestXmlProtocolClient extends __Client< const _config_4 = resolveRegionConfig(_config_3); const _config_5 = resolveHostHeaderConfig(_config_4); const _config_6 = resolveEndpointConfig(_config_5); - const _config_7 = resolveEndpointRequiredConfig(_config_6); - const _config_8 = resolveHttpAuthSchemeConfig(_config_7); - const _config_9 = resolveCompressionConfig(_config_8); - const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []); - this.config = _config_10; + const _config_7 = resolveHttpAuthSchemeConfig(_config_6); + const _config_8 = resolveCompressionConfig(_config_7); + const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []); + this.config = _config_9; this.middlewareStack.use(getUserAgentPlugin(this.config)); this.middlewareStack.use(getRetryPlugin(this.config)); this.middlewareStack.use(getContentLengthPlugin(this.config)); diff --git a/private/aws-protocoltests-restxml/src/endpoint/EndpointParameters.ts b/private/aws-protocoltests-restxml/src/endpoint/EndpointParameters.ts index a044f11f9945..c67d03508b7c 100644 --- a/private/aws-protocoltests-restxml/src/endpoint/EndpointParameters.ts +++ b/private/aws-protocoltests-restxml/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "restxml", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-protocoltests-restxml/src/endpoint/endpointResolver.ts b/private/aws-protocoltests-restxml/src/endpoint/endpointResolver.ts index 8bb222967df8..ccee107f30d6 100644 --- a/private/aws-protocoltests-restxml/src/endpoint/endpointResolver.ts +++ b/private/aws-protocoltests-restxml/src/endpoint/endpointResolver.ts @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-protocoltests-restxml/src/endpoint/ruleset.ts b/private/aws-protocoltests-restxml/src/endpoint/ruleset.ts index 14416a50b269..ee363a0be8df 100644 --- a/private/aws-protocoltests-restxml/src/endpoint/ruleset.ts +++ b/private/aws-protocoltests-restxml/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restxml-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restxml.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restxml-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restxml.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restxml.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-restjson-server/src/endpoint/EndpointParameters.ts b/private/aws-restjson-server/src/endpoint/EndpointParameters.ts index 65d71c47f97f..9491031e5dc7 100644 --- a/private/aws-restjson-server/src/endpoint/EndpointParameters.ts +++ b/private/aws-restjson-server/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-restjson-server/src/endpoint/endpointResolver.ts b/private/aws-restjson-server/src/endpoint/endpointResolver.ts index 92254ad194de..9b10bf5d6e7d 100644 --- a/private/aws-restjson-server/src/endpoint/endpointResolver.ts +++ b/private/aws-restjson-server/src/endpoint/endpointResolver.ts @@ -7,7 +7,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-restjson-server/src/endpoint/ruleset.ts b/private/aws-restjson-server/src/endpoint/ruleset.ts index 14416a50b269..6eaa2aeabbdb 100644 --- a/private/aws-restjson-server/src/endpoint/ruleset.ts +++ b/private/aws-restjson-server/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restjson.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restjson-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restjson.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ], diff --git a/private/aws-restjson-validation-server/src/endpoint/EndpointParameters.ts b/private/aws-restjson-validation-server/src/endpoint/EndpointParameters.ts index 65d71c47f97f..9491031e5dc7 100644 --- a/private/aws-restjson-validation-server/src/endpoint/EndpointParameters.ts +++ b/private/aws-restjson-validation-server/src/endpoint/EndpointParameters.ts @@ -5,6 +5,9 @@ import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provi * @public */ export interface ClientInputEndpointParameters { + region?: string | undefined | Provider; + useDualstackEndpoint?: boolean | undefined | Provider; + useFipsEndpoint?: boolean | undefined | Provider; endpoint?: string | Provider | Endpoint | Provider | EndpointV2 | Provider; } @@ -16,14 +19,22 @@ export const resolveClientEndpointParameters = ( options: T & ClientInputEndpointParameters ): T & ClientResolvedEndpointParameters => { return Object.assign(options, { + useDualstackEndpoint: options.useDualstackEndpoint ?? false, + useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "", }); }; export const commonParams = { - endpoint: { type: "builtInParams", name: "endpoint" }, + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, + Endpoint: { type: "builtInParams", name: "endpoint" }, + Region: { type: "builtInParams", name: "region" }, + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, } as const; export interface EndpointParameters extends __EndpointParameters { - endpoint?: string | undefined; + Region?: string | undefined; + UseDualStack?: boolean | undefined; + UseFIPS?: boolean | undefined; + Endpoint?: string | undefined; } diff --git a/private/aws-restjson-validation-server/src/endpoint/endpointResolver.ts b/private/aws-restjson-validation-server/src/endpoint/endpointResolver.ts index 92254ad194de..9b10bf5d6e7d 100644 --- a/private/aws-restjson-validation-server/src/endpoint/endpointResolver.ts +++ b/private/aws-restjson-validation-server/src/endpoint/endpointResolver.ts @@ -7,7 +7,7 @@ import { ruleSet } from "./ruleset"; const cache = new EndpointCache({ size: 50, - params: ["endpoint"], + params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"], }); export const defaultEndpointResolver = ( diff --git a/private/aws-restjson-validation-server/src/endpoint/ruleset.ts b/private/aws-restjson-validation-server/src/endpoint/ruleset.ts index 14416a50b269..fff4dffbfff5 100644 --- a/private/aws-restjson-validation-server/src/endpoint/ruleset.ts +++ b/private/aws-restjson-validation-server/src/endpoint/ruleset.ts @@ -4,10 +4,31 @@ import { RuleSetObject } from "@smithy/types"; export const ruleSet: RuleSetObject = { version: "1.0", parameters: { - endpoint: { - type: "string", + Region: { + builtIn: "AWS::Region", + required: false, + documentation: "The AWS Region. This is a default regional AWS endpointRuleSet.", + type: "String", + }, + UseDualStack: { + builtIn: "AWS::UseDualStack", + required: true, + default: false, + documentation: "Whether to use dual-stack.", + type: "Boolean", + }, + UseFIPS: { + builtIn: "AWS::UseFIPS", + required: true, + default: false, + documentation: "Whether to use FIPS-compliant regional endpoint.", + type: "Boolean", + }, + Endpoint: { builtIn: "SDK::Endpoint", - documentation: "Endpoint used for making requests. Should be formatted as a URI.", + required: false, + documentation: "Override the endpoint.", + type: "String", }, }, rules: [ @@ -17,21 +38,304 @@ export const ruleSet: RuleSetObject = { fn: "isSet", argv: [ { - ref: "endpoint", + ref: "Endpoint", + }, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + error: "Invalid Configuration: FIPS and custom endpoint are not supported", + type: "error", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + error: "Invalid Configuration: Dualstack and custom endpoint are not supported", + type: "error", + }, + { + conditions: [], + endpoint: { + url: { + ref: "Endpoint", + }, + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "isSet", + argv: [ + { + ref: "Region", }, ], }, ], - endpoint: { - url: { - ref: "endpoint", + rules: [ + { + conditions: [ + { + fn: "aws.partition", + argv: [ + { + ref: "Region", + }, + ], + assign: "PartitionResult", + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + ], + }, + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjsonvalidation-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS and DualStack are enabled, but this partition does not support one or both", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseFIPS", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsFIPS", + ], + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "stringEquals", + argv: [ + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "name", + ], + }, + "aws-us-gov", + ], + }, + ], + endpoint: { + url: "https://restjsonvalidation.{Region}.amazonaws.com", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + { + conditions: [], + endpoint: { + url: "https://restjsonvalidation-fips.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "FIPS is enabled but this partition does not support FIPS", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + { + ref: "UseDualStack", + }, + true, + ], + }, + ], + rules: [ + { + conditions: [ + { + fn: "booleanEquals", + argv: [ + true, + { + fn: "getAttr", + argv: [ + { + ref: "PartitionResult", + }, + "supportsDualStack", + ], + }, + ], + }, + ], + rules: [ + { + conditions: [], + endpoint: { + url: "https://restjsonvalidation.{Region}.{PartitionResult#dualStackDnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", + }, + { + conditions: [], + error: "DualStack is enabled but this partition does not support DualStack", + type: "error", + }, + ], + type: "tree", + }, + { + conditions: [], + endpoint: { + url: "https://restjsonvalidation.{Region}.{PartitionResult#dnsSuffix}", + properties: {}, + headers: {}, + }, + type: "endpoint", + }, + ], + type: "tree", }, - }, - type: "endpoint", + ], + type: "tree", }, { conditions: [], - error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.", + error: "Invalid Configuration: Missing Region", type: "error", }, ],