diff --git a/Package.swift b/Package.swift index 8587dbd8102..cc181860b54 100644 --- a/Package.swift +++ b/Package.swift @@ -184,7 +184,7 @@ func addProtocolTests() { // MARK: - Generated addDependencies( - clientRuntimeVersion: "0.33.0", + clientRuntimeVersion: "0.34.0", crtVersion: "0.17.0" ) diff --git a/Package.version b/Package.version index beb3a3f6f7a..065d469bdaa 100644 --- a/Package.version +++ b/Package.version @@ -1 +1 @@ -0.29.0 \ No newline at end of file +0.30.0 \ No newline at end of file diff --git a/Sources/Services/AWSAccessAnalyzer/AccessAnalyzerClient.swift b/Sources/Services/AWSAccessAnalyzer/AccessAnalyzerClient.swift index bb88b2e416d..39d37af3c94 100644 --- a/Sources/Services/AWSAccessAnalyzer/AccessAnalyzerClient.swift +++ b/Sources/Services/AWSAccessAnalyzer/AccessAnalyzerClient.swift @@ -98,14 +98,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "applyArchiveRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -200,14 +193,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessPreview") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -257,14 +243,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAnalyzer") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -315,14 +294,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createArchiveRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -371,14 +343,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAnalyzer") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -425,14 +390,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteArchiveRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1124,14 +1082,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startPolicyGeneration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1322,14 +1273,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateArchiveRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1378,14 +1322,7 @@ extension AccessAnalyzerClient: AccessAnalyzerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFindings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAlexaForBusiness/AlexaForBusinessClient.swift b/Sources/Services/AWSAlexaForBusiness/AlexaForBusinessClient.swift index 3dd4aafb906..f30373859c2 100644 --- a/Sources/Services/AWSAlexaForBusiness/AlexaForBusinessClient.swift +++ b/Sources/Services/AWSAlexaForBusiness/AlexaForBusinessClient.swift @@ -427,14 +427,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAddressBook") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -481,14 +474,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBusinessReportSchedule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -535,14 +521,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConferenceProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -590,14 +569,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -645,14 +617,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createGatewayGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -703,14 +668,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -759,14 +717,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -814,14 +765,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRoom") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -870,14 +814,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSkillGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -926,14 +863,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3639,14 +3569,7 @@ extension AlexaForBusinessClient: AlexaForBusinessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendAnnouncement") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAmp/AmpClient.swift b/Sources/Services/AWSAmp/AmpClient.swift index 684ca0b75dc..fa01333d605 100644 --- a/Sources/Services/AWSAmp/AmpClient.swift +++ b/Sources/Services/AWSAmp/AmpClient.swift @@ -100,14 +100,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAlertManagerDefinition") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -155,14 +148,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLoggingConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -213,14 +199,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRuleGroupsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -270,14 +249,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkspace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -327,14 +299,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAlertManagerDefinition") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -381,14 +346,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteLoggingConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -436,14 +394,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteRuleGroupsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -491,14 +442,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteWorkspace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -862,14 +806,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putAlertManagerDefinition") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -920,14 +857,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putRuleGroupsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1070,14 +1000,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateLoggingConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1128,14 +1051,7 @@ extension AmpClient: AmpClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateWorkspaceAlias") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAmplifyUIBuilder/AmplifyUIBuilderClient.swift b/Sources/Services/AWSAmplifyUIBuilder/AmplifyUIBuilderClient.swift index 2762e0c6a30..a1e4fd5de8f 100644 --- a/Sources/Services/AWSAmplifyUIBuilder/AmplifyUIBuilderClient.swift +++ b/Sources/Services/AWSAmplifyUIBuilder/AmplifyUIBuilderClient.swift @@ -97,14 +97,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -153,14 +146,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createForm") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -209,14 +195,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTheme") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1043,14 +1022,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startCodegenJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1098,14 +1070,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1153,14 +1118,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateForm") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1208,14 +1166,7 @@ extension AmplifyUIBuilderClient: AmplifyUIBuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateTheme") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAppFabric/AppFabricClient.swift b/Sources/Services/AWSAppFabric/AppFabricClient.swift index b8814a2edbe..1456ebe92b0 100644 --- a/Sources/Services/AWSAppFabric/AppFabricClient.swift +++ b/Sources/Services/AWSAppFabric/AppFabricClient.swift @@ -196,14 +196,7 @@ extension AppFabricClient: AppFabricClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppAuthorization") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -253,14 +246,7 @@ extension AppFabricClient: AppFabricClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppBundle") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -310,14 +296,7 @@ extension AppFabricClient: AppFabricClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIngestion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -367,14 +346,7 @@ extension AppFabricClient: AppFabricClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIngestionDestination") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAppIntegrations/AppIntegrationsClient.swift b/Sources/Services/AWSAppIntegrations/AppIntegrationsClient.swift index 74f32f87aa0..cb9b9b328f9 100644 --- a/Sources/Services/AWSAppIntegrations/AppIntegrationsClient.swift +++ b/Sources/Services/AWSAppIntegrations/AppIntegrationsClient.swift @@ -99,14 +99,7 @@ extension AppIntegrationsClient: AppIntegrationsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -156,14 +149,7 @@ extension AppIntegrationsClient: AppIntegrationsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataIntegration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -213,14 +199,7 @@ extension AppIntegrationsClient: AppIntegrationsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEventIntegration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAppMesh/AppMeshClient.swift b/Sources/Services/AWSAppMesh/AppMeshClient.swift index 6164b8d0385..3f198b0c48b 100644 --- a/Sources/Services/AWSAppMesh/AppMeshClient.swift +++ b/Sources/Services/AWSAppMesh/AppMeshClient.swift @@ -101,14 +101,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createGatewayRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -161,14 +154,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMesh") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -220,14 +206,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -280,14 +259,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVirtualGateway") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -340,14 +312,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVirtualNode") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -400,14 +365,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVirtualRouter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -460,14 +418,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVirtualService") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1661,14 +1612,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateGatewayRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1720,14 +1664,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateMesh") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1779,14 +1716,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1839,14 +1769,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVirtualGateway") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1899,14 +1822,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVirtualNode") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1959,14 +1875,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVirtualRouter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2019,14 +1928,7 @@ extension AppMeshClient: AppMeshClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVirtualService") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAppflow/AppflowClient.swift b/Sources/Services/AWSAppflow/AppflowClient.swift index 11f0328aa97..25f967b81a6 100644 --- a/Sources/Services/AWSAppflow/AppflowClient.swift +++ b/Sources/Services/AWSAppflow/AppflowClient.swift @@ -146,14 +146,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConnectorProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -205,14 +198,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFlow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -813,14 +799,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerConnector") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -915,14 +894,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startFlow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1154,14 +1126,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateConnectorProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1218,14 +1183,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateConnectorRegistration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1277,14 +1235,7 @@ extension AppflowClient: AppflowClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFlow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSApplicationDiscoveryService/ApplicationDiscoveryClient.swift b/Sources/Services/AWSApplicationDiscoveryService/ApplicationDiscoveryClient.swift index f4523b4aebe..b7da7ddbd64 100644 --- a/Sources/Services/AWSApplicationDiscoveryService/ApplicationDiscoveryClient.swift +++ b/Sources/Services/AWSApplicationDiscoveryService/ApplicationDiscoveryClient.swift @@ -1319,14 +1319,7 @@ extension ApplicationDiscoveryClient: ApplicationDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startImportTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSAthena/AthenaClient.swift b/Sources/Services/AWSAthena/AthenaClient.swift index f3bf37b38d6..d96be25de20 100644 --- a/Sources/Services/AWSAthena/AthenaClient.swift +++ b/Sources/Services/AWSAthena/AthenaClient.swift @@ -371,14 +371,7 @@ extension AthenaClient: AthenaClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNamedQuery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -703,14 +696,7 @@ extension AthenaClient: AthenaClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteNamedQuery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.namedQueryId == nil { - copiedInput.namedQueryId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.namedQueryId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2622,14 +2608,7 @@ extension AthenaClient: AthenaClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startQueryExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2772,14 +2751,7 @@ extension AthenaClient: AthenaClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "stopQueryExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.queryExecutionId == nil { - copiedInput.queryExecutionId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.queryExecutionId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSBackup/BackupClient.swift b/Sources/Services/AWSBackup/BackupClient.swift index 52eb72f6c1a..ef35a9df5e4 100644 --- a/Sources/Services/AWSBackup/BackupClient.swift +++ b/Sources/Services/AWSBackup/BackupClient.swift @@ -288,14 +288,7 @@ extension BackupClient: BackupClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFramework") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -440,14 +433,7 @@ extension BackupClient: BackupClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createReportPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2949,14 +2935,7 @@ extension BackupClient: BackupClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startReportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3242,14 +3221,7 @@ extension BackupClient: BackupClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFramework") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3439,14 +3411,7 @@ extension BackupClient: BackupClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateReportPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSBedrock/BedrockClient.swift b/Sources/Services/AWSBedrock/BedrockClient.swift index 5aa845b80db..88934dead8a 100644 --- a/Sources/Services/AWSBedrock/BedrockClient.swift +++ b/Sources/Services/AWSBedrock/BedrockClient.swift @@ -101,14 +101,7 @@ extension BedrockClient: BedrockClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createModelCustomizationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -159,14 +152,7 @@ extension BedrockClient: BedrockClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProvisionedModelThroughput") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSBillingconductor/BillingconductorClient.swift b/Sources/Services/AWSBillingconductor/BillingconductorClient.swift index 5018b8458e1..c39ecb149da 100644 --- a/Sources/Services/AWSBillingconductor/BillingconductorClient.swift +++ b/Sources/Services/AWSBillingconductor/BillingconductorClient.swift @@ -298,14 +298,7 @@ extension BillingconductorClient: BillingconductorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBillingGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -356,14 +349,7 @@ extension BillingconductorClient: BillingconductorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomLineItem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -415,14 +401,7 @@ extension BillingconductorClient: BillingconductorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPricingPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -473,14 +452,7 @@ extension BillingconductorClient: BillingconductorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPricingRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSBraket/BraketClient.swift b/Sources/Services/AWSBraket/BraketClient.swift index 173fdc0f9ca..05557c6075d 100644 --- a/Sources/Services/AWSBraket/BraketClient.swift +++ b/Sources/Services/AWSBraket/BraketClient.swift @@ -145,14 +145,7 @@ extension BraketClient: BraketClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "cancelQuantumTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -203,14 +196,7 @@ extension BraketClient: BraketClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -261,14 +247,7 @@ extension BraketClient: BraketClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createQuantumTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSChime/ChimeClient.swift b/Sources/Services/AWSChime/ChimeClient.swift index 4f92ac52ea2..f7c2b822dab 100644 --- a/Sources/Services/AWSChime/ChimeClient.swift +++ b/Sources/Services/AWSChime/ChimeClient.swift @@ -771,14 +771,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "identity-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -890,14 +883,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppInstanceUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "identity-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1053,14 +1039,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "messaging-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1305,14 +1284,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaCapturePipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1364,14 +1336,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMeeting") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1474,14 +1439,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMeetingWithAttendees") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1636,14 +1594,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRoom") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8079,14 +8030,7 @@ extension ChimeClient: ChimeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendChannelMessage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "messaging-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSChimeSDKIdentity/ChimeSDKIdentityClient.swift b/Sources/Services/AWSChimeSDKIdentity/ChimeSDKIdentityClient.swift index fc698cc28c7..97f6554beba 100644 --- a/Sources/Services/AWSChimeSDKIdentity/ChimeSDKIdentityClient.swift +++ b/Sources/Services/AWSChimeSDKIdentity/ChimeSDKIdentityClient.swift @@ -101,14 +101,7 @@ extension ChimeSDKIdentityClient: ChimeSDKIdentityClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -218,14 +211,7 @@ extension ChimeSDKIdentityClient: ChimeSDKIdentityClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppInstanceBot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -277,14 +263,7 @@ extension ChimeSDKIdentityClient: ChimeSDKIdentityClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppInstanceUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1233,14 +1212,7 @@ extension ChimeSDKIdentityClient: ChimeSDKIdentityClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerAppInstanceUserEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSChimeSDKMediaPipelines/ChimeSDKMediaPipelinesClient.swift b/Sources/Services/AWSChimeSDKMediaPipelines/ChimeSDKMediaPipelinesClient.swift index 85a493d3633..5f459fe84ad 100644 --- a/Sources/Services/AWSChimeSDKMediaPipelines/ChimeSDKMediaPipelinesClient.swift +++ b/Sources/Services/AWSChimeSDKMediaPipelines/ChimeSDKMediaPipelinesClient.swift @@ -100,14 +100,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaCapturePipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -158,14 +151,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaConcatenationPipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -217,14 +203,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaInsightsPipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -276,14 +255,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaInsightsPipelineConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -334,14 +306,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaLiveConnectorPipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -393,14 +358,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaPipelineKinesisVideoStreamPool") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -452,14 +410,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMediaStreamPipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1224,14 +1175,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSpeakerSearchTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1284,14 +1228,7 @@ extension ChimeSDKMediaPipelinesClient: ChimeSDKMediaPipelinesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startVoiceToneAnalysisTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSChimeSDKMeetings/ChimeSDKMeetingsClient.swift b/Sources/Services/AWSChimeSDKMeetings/ChimeSDKMeetingsClient.swift index 9567947fcff..152c00ae26a 100644 --- a/Sources/Services/AWSChimeSDKMeetings/ChimeSDKMeetingsClient.swift +++ b/Sources/Services/AWSChimeSDKMeetings/ChimeSDKMeetingsClient.swift @@ -264,14 +264,7 @@ extension ChimeSDKMeetingsClient: ChimeSDKMeetingsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMeeting") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -323,14 +316,7 @@ extension ChimeSDKMeetingsClient: ChimeSDKMeetingsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMeetingWithAttendees") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSChimeSDKMessaging/ChimeSDKMessagingClient.swift b/Sources/Services/AWSChimeSDKMessaging/ChimeSDKMessagingClient.swift index b3a4e9e8154..7cf6141b335 100644 --- a/Sources/Services/AWSChimeSDKMessaging/ChimeSDKMessagingClient.swift +++ b/Sources/Services/AWSChimeSDKMessaging/ChimeSDKMessagingClient.swift @@ -211,14 +211,7 @@ extension ChimeSDKMessagingClient: ChimeSDKMessagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "channelFlowCallback") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.callbackId == nil { - copiedInput.callbackId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.callbackId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -271,14 +264,7 @@ extension ChimeSDKMessagingClient: ChimeSDKMessagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -392,14 +378,7 @@ extension ChimeSDKMessagingClient: ChimeSDKMessagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannelFlow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2339,14 +2318,7 @@ extension ChimeSDKMessagingClient: ChimeSDKMessagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendChannelMessage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCloudControl/CloudControlClient.swift b/Sources/Services/AWSCloudControl/CloudControlClient.swift index 66b8eb7bb91..6e015d9f909 100644 --- a/Sources/Services/AWSCloudControl/CloudControlClient.swift +++ b/Sources/Services/AWSCloudControl/CloudControlClient.swift @@ -158,14 +158,7 @@ extension CloudControlClient: CloudControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -229,14 +222,7 @@ extension CloudControlClient: CloudControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -507,14 +493,7 @@ extension CloudControlClient: CloudControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCloudFormation/CloudFormationClient.swift b/Sources/Services/AWSCloudFormation/CloudFormationClient.swift index 12452925543..26efc75b614 100644 --- a/Sources/Services/AWSCloudFormation/CloudFormationClient.swift +++ b/Sources/Services/AWSCloudFormation/CloudFormationClient.swift @@ -411,14 +411,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStackInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -465,14 +458,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStackSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -699,14 +685,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStackInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1607,14 +1586,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "detectStackSetDrift") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1878,14 +1850,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importStacksToStackSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3038,14 +3003,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStackInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3095,14 +3053,7 @@ extension CloudFormationClient: CloudFormationClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStackSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.operationId == nil { - copiedInput.operationId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.operationId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCloudWatchLogs/CloudWatchLogsClient.swift b/Sources/Services/AWSCloudWatchLogs/CloudWatchLogsClient.swift index 2f6890ce42d..76fb2b905b2 100644 --- a/Sources/Services/AWSCloudWatchLogs/CloudWatchLogsClient.swift +++ b/Sources/Services/AWSCloudWatchLogs/CloudWatchLogsClient.swift @@ -2049,14 +2049,7 @@ extension CloudWatchLogsClient: CloudWatchLogsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putQueryDefinition") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodeCommit/CodeCommitClient.swift b/Sources/Services/AWSCodeCommit/CodeCommitClient.swift index af88f94d1b1..cf2d1ecc432 100644 --- a/Sources/Services/AWSCodeCommit/CodeCommitClient.swift +++ b/Sources/Services/AWSCodeCommit/CodeCommitClient.swift @@ -644,14 +644,7 @@ extension CodeCommitClient: CodeCommitClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPullRequest") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3462,14 +3455,7 @@ extension CodeCommitClient: CodeCommitClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "postCommentForComparedCommit") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3541,14 +3527,7 @@ extension CodeCommitClient: CodeCommitClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "postCommentForPullRequest") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3601,14 +3580,7 @@ extension CodeCommitClient: CodeCommitClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "postCommentReply") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodeGuruProfiler/CodeGuruProfilerClient.swift b/Sources/Services/AWSCodeGuruProfiler/CodeGuruProfilerClient.swift index e0f06d60f20..ac4bc116c7b 100644 --- a/Sources/Services/AWSCodeGuruProfiler/CodeGuruProfilerClient.swift +++ b/Sources/Services/AWSCodeGuruProfiler/CodeGuruProfilerClient.swift @@ -242,14 +242,7 @@ extension CodeGuruProfilerClient: CodeGuruProfilerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProfilingGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -801,14 +794,7 @@ extension CodeGuruProfilerClient: CodeGuruProfilerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "postAgentProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.profileToken == nil { - copiedInput.profileToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.profileToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodeGuruReviewer/CodeGuruReviewerClient.swift b/Sources/Services/AWSCodeGuruReviewer/CodeGuruReviewerClient.swift index 410a9a6f25c..b106053c8be 100644 --- a/Sources/Services/AWSCodeGuruReviewer/CodeGuruReviewerClient.swift +++ b/Sources/Services/AWSCodeGuruReviewer/CodeGuruReviewerClient.swift @@ -98,14 +98,7 @@ extension CodeGuruReviewerClient: CodeGuruReviewerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateRepository") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -155,14 +148,7 @@ extension CodeGuruReviewerClient: CodeGuruReviewerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCodeReview") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodeGuruSecurity/CodeGuruSecurityClient.swift b/Sources/Services/AWSCodeGuruSecurity/CodeGuruSecurityClient.swift index b30741001d9..4e930da867f 100644 --- a/Sources/Services/AWSCodeGuruSecurity/CodeGuruSecurityClient.swift +++ b/Sources/Services/AWSCodeGuruSecurity/CodeGuruSecurityClient.swift @@ -146,14 +146,7 @@ extension CodeGuruSecurityClient: CodeGuruSecurityClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createScan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodePipeline/CodePipelineClient.swift b/Sources/Services/AWSCodePipeline/CodePipelineClient.swift index aeacd042e67..d586223c249 100644 --- a/Sources/Services/AWSCodePipeline/CodePipelineClient.swift +++ b/Sources/Services/AWSCodePipeline/CodePipelineClient.swift @@ -1662,14 +1662,7 @@ extension CodePipelineClient: CodePipelineClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startPipelineExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSCodestarnotifications/CodestarnotificationsClient.swift b/Sources/Services/AWSCodestarnotifications/CodestarnotificationsClient.swift index 1da36a2d644..a08e9fa7de9 100644 --- a/Sources/Services/AWSCodestarnotifications/CodestarnotificationsClient.swift +++ b/Sources/Services/AWSCodestarnotifications/CodestarnotificationsClient.swift @@ -99,14 +99,7 @@ extension CodestarnotificationsClient: CodestarnotificationsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNotificationRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSComprehend/ComprehendClient.swift b/Sources/Services/AWSComprehend/ComprehendClient.swift index b411d7baceb..e3b8c62138c 100644 --- a/Sources/Services/AWSComprehend/ComprehendClient.swift +++ b/Sources/Services/AWSComprehend/ComprehendClient.swift @@ -489,14 +489,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -549,14 +542,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDocumentClassifier") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -609,14 +595,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -669,14 +648,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEntityRecognizer") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -731,14 +703,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFlywheel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3102,14 +3067,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDocumentClassificationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3160,14 +3118,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDominantLanguageDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3220,14 +3171,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startEntitiesDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3278,14 +3222,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startEventsDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3385,14 +3322,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startKeyPhrasesDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3443,14 +3373,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startPiiEntitiesDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3501,14 +3424,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSentimentDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3559,14 +3475,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startTargetedSentimentDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3617,14 +3526,7 @@ extension ComprehendClient: ComprehendClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startTopicsDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSComprehendMedical/ComprehendMedicalClient.swift b/Sources/Services/AWSComprehendMedical/ComprehendMedicalClient.swift index 726dcf4d8fc..e99fbd31096 100644 --- a/Sources/Services/AWSComprehendMedical/ComprehendMedicalClient.swift +++ b/Sources/Services/AWSComprehendMedical/ComprehendMedicalClient.swift @@ -878,14 +878,7 @@ extension ComprehendMedicalClient: ComprehendMedicalClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startEntitiesDetectionV2Job") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -934,14 +927,7 @@ extension ComprehendMedicalClient: ComprehendMedicalClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startICD10CMInferenceJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -990,14 +976,7 @@ extension ComprehendMedicalClient: ComprehendMedicalClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startPHIDetectionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1046,14 +1025,7 @@ extension ComprehendMedicalClient: ComprehendMedicalClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startRxNormInferenceJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1102,14 +1074,7 @@ extension ComprehendMedicalClient: ComprehendMedicalClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSNOMEDCTInferenceJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSConnect/ConnectClient.swift b/Sources/Services/AWSConnect/ConnectClient.swift index 2495c2c2807..57d69fe8bce 100644 --- a/Sources/Services/AWSConnect/ConnectClient.swift +++ b/Sources/Services/AWSConnect/ConnectClient.swift @@ -688,14 +688,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "claimPhoneNumber") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -850,14 +843,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContactFlowModule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -907,14 +893,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEvaluationForm") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1109,14 +1088,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createParticipant") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1372,14 +1344,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1479,14 +1444,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTaskTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1538,14 +1496,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrafficDistributionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1847,14 +1798,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVocabulary") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -6675,14 +6619,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "monitorContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -6782,14 +6719,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "releasePhoneNumber") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -6839,14 +6769,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "replicateInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -7427,14 +7350,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startChatContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -7484,14 +7400,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startContactEvaluation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -7594,14 +7503,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startContactStreaming") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -7652,14 +7554,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startOutboundVoiceContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -7732,14 +7627,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startTaskContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8092,14 +7980,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "transferContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8683,14 +8564,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateEvaluationForm") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8947,14 +8821,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePhoneNumber") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -9006,14 +8873,7 @@ extension ConnectClient: ConnectClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePhoneNumberMetadata") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSConnectCases/ConnectCasesClient.swift b/Sources/Services/AWSConnectCases/ConnectCasesClient.swift index cc6f18d4303..46db818b51b 100644 --- a/Sources/Services/AWSConnectCases/ConnectCasesClient.swift +++ b/Sources/Services/AWSConnectCases/ConnectCasesClient.swift @@ -200,14 +200,7 @@ extension ConnectCasesClient: ConnectCasesClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCase") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSConnectParticipant/ConnectParticipantClient.swift b/Sources/Services/AWSConnectParticipant/ConnectParticipantClient.swift index 4406495f39d..ac1014ea624 100644 --- a/Sources/Services/AWSConnectParticipant/ConnectParticipantClient.swift +++ b/Sources/Services/AWSConnectParticipant/ConnectParticipantClient.swift @@ -99,14 +99,7 @@ extension ConnectParticipantClient: ConnectParticipantClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "completeAttachmentUpload") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -249,14 +242,7 @@ extension ConnectParticipantClient: ConnectParticipantClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disconnectParticipant") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -401,14 +387,7 @@ extension ConnectParticipantClient: ConnectParticipantClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendEvent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -457,14 +436,7 @@ extension ConnectParticipantClient: ConnectParticipantClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendMessage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -514,14 +486,7 @@ extension ConnectParticipantClient: ConnectParticipantClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startAttachmentUpload") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSDataSync/DataSyncClient.swift b/Sources/Services/AWSDataSync/DataSyncClient.swift index 4f9e769aaaa..0fba863fdf1 100644 --- a/Sources/Services/AWSDataSync/DataSyncClient.swift +++ b/Sources/Services/AWSDataSync/DataSyncClient.swift @@ -95,14 +95,7 @@ extension DataSyncClient: DataSyncClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "addStorageSystem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "discovery-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2187,14 +2180,7 @@ extension DataSyncClient: DataSyncClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDiscoveryJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "discovery-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSDataZone/DataZoneClient.swift b/Sources/Services/AWSDataZone/DataZoneClient.swift index 91a45e9c721..cf3180db17b 100644 --- a/Sources/Services/AWSDataZone/DataZoneClient.swift +++ b/Sources/Services/AWSDataZone/DataZoneClient.swift @@ -100,14 +100,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "acceptPredictions") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -257,14 +250,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAsset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -315,14 +301,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAssetRevision") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -424,14 +403,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataSource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -483,14 +455,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDomain") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -692,14 +657,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createGlossary") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -751,14 +709,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createGlossaryTerm") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -808,14 +759,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createGroupProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -867,14 +811,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createListingChangeSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1025,14 +962,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSubscriptionGrant") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1083,14 +1013,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSubscriptionRequest") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1141,14 +1064,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSubscriptionTarget") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1198,14 +1114,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUserProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1350,14 +1259,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDataSource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -1406,14 +1308,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDomain") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -3853,14 +3748,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "rejectPredictions") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -4255,14 +4143,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDataSourceRun") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -4460,14 +4341,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDomain") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -4620,14 +4494,7 @@ extension DataZoneClient: DataZoneClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateGlossary") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSDevOpsGuru/DevOpsGuruClient.swift b/Sources/Services/AWSDevOpsGuru/DevOpsGuruClient.swift index 3f9691250de..629ae8d587a 100644 --- a/Sources/Services/AWSDevOpsGuru/DevOpsGuruClient.swift +++ b/Sources/Services/AWSDevOpsGuru/DevOpsGuruClient.swift @@ -1362,14 +1362,7 @@ extension DevOpsGuruClient: DevOpsGuruClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startCostEstimation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSDocDBElastic/DocDBElasticClient.swift b/Sources/Services/AWSDocDBElastic/DocDBElasticClient.swift index bc52c0f4aa1..fe4b978d47f 100644 --- a/Sources/Services/AWSDocDBElastic/DocDBElasticClient.swift +++ b/Sources/Services/AWSDocDBElastic/DocDBElasticClient.swift @@ -99,14 +99,7 @@ extension DocDBElasticClient: DocDBElasticClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -664,14 +657,7 @@ extension DocDBElasticClient: DocDBElasticClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSDynamoDB/DynamoDBClient.swift b/Sources/Services/AWSDynamoDB/DynamoDBClient.swift index 0b58ab98ada..fe26d7ed938 100644 --- a/Sources/Services/AWSDynamoDB/DynamoDBClient.swift +++ b/Sources/Services/AWSDynamoDB/DynamoDBClient.swift @@ -1514,14 +1514,7 @@ extension DynamoDBClient: DynamoDBClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "executeTransaction") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1572,14 +1565,7 @@ extension DynamoDBClient: DynamoDBClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "exportTableToPointInTime") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1676,14 +1662,7 @@ extension DynamoDBClient: DynamoDBClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importTable") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2753,14 +2732,7 @@ extension DynamoDBClient: DynamoDBClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "transactWriteItems") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEBS/EBSClient.swift b/Sources/Services/AWSEBS/EBSClient.swift index ef87b1620bd..e16ff724287 100644 --- a/Sources/Services/AWSEBS/EBSClient.swift +++ b/Sources/Services/AWSEBS/EBSClient.swift @@ -339,14 +339,7 @@ extension EBSClient: EBSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSnapshot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEC2/EC2Client.swift b/Sources/Services/AWSEC2/EC2Client.swift index 67e55d404f7..56203f31544 100644 --- a/Sources/Services/AWSEC2/EC2Client.swift +++ b/Sources/Services/AWSEC2/EC2Client.swift @@ -475,14 +475,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "allocateIpamPoolCidr") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -717,14 +710,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateClientVpnTargetNetwork") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -920,14 +906,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateIpamResourceDiscovery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1201,14 +1180,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateTrunkInterface") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1404,14 +1376,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "attachVerifiedAccessTrustProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1540,14 +1505,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "authorizeClientVpnIngress") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2295,14 +2253,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCapacityReservationFleet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2342,14 +2293,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCarrierGateway") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2389,14 +2333,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createClientVpnEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2436,14 +2373,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createClientVpnRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2925,14 +2855,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createInstanceConnectEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3096,14 +3019,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIpam") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3143,14 +3059,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIpamPool") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3190,14 +3099,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIpamResourceDiscovery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3237,14 +3139,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIpamScope") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3561,14 +3456,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createManagedPrefixList") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3608,14 +3496,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNatGateway") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3733,14 +3614,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkInsightsAccessScope") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3780,14 +3654,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkInsightsPath") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3827,14 +3694,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkInterface") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3991,14 +3851,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createReplaceRootVolumeTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4513,14 +4366,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrafficMirrorFilter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4560,14 +4406,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrafficMirrorFilterRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4607,14 +4446,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrafficMirrorSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4654,14 +4486,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrafficMirrorTarget") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5130,14 +4955,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVerifiedAccessEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5177,14 +4995,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVerifiedAccessGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5224,14 +5035,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVerifiedAccessInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5271,14 +5075,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVerifiedAccessTrustProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5318,14 +5115,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVolume") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8070,14 +7860,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVerifiedAccessEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8117,14 +7900,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVerifiedAccessGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8164,14 +7940,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVerifiedAccessInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -8211,14 +7980,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVerifiedAccessTrustProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -14681,14 +14443,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "detachVerifiedAccessTrustProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -15828,14 +15583,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateTrunkInterface") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -16616,14 +16364,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "exportImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20440,14 +20181,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20487,14 +20221,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessEndpointPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20534,14 +20261,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20581,14 +20301,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessGroupPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20628,14 +20341,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20675,14 +20381,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessInstanceLoggingConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -20722,14 +20421,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "modifyVerifiedAccessTrustProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -21482,14 +21174,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "provisionIpamPoolCidr") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -21646,14 +21331,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "purchaseScheduledInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -23197,14 +22875,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "runInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -23244,14 +22915,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "runScheduledInstances") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -23486,14 +23150,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startNetworkInsightsAccessScopeAnalysis") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -23533,14 +23190,7 @@ extension EC2Client: EC2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startNetworkInsightsAnalysis") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEFS/EFSClient.swift b/Sources/Services/AWSEFS/EFSClient.swift index debf8ba7317..991e03f4ba5 100644 --- a/Sources/Services/AWSEFS/EFSClient.swift +++ b/Sources/Services/AWSEFS/EFSClient.swift @@ -100,14 +100,7 @@ extension EFSClient: EFSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessPoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -165,14 +158,7 @@ extension EFSClient: EFSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFileSystem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creationToken == nil { - copiedInput.creationToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creationToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEKS/EKSClient.swift b/Sources/Services/AWSEKS/EKSClient.swift index 5bcf5dc33b1..801d03b555c 100644 --- a/Sources/Services/AWSEKS/EKSClient.swift +++ b/Sources/Services/AWSEKS/EKSClient.swift @@ -99,14 +99,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateEncryptionConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -156,14 +149,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateIdentityProviderConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -213,14 +199,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAddon") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -271,14 +250,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -328,14 +300,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFargateProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -386,14 +351,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNodegroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1029,14 +987,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateIdentityProviderConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1403,14 +1354,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1548,14 +1492,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAddon") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1605,14 +1542,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateClusterConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1662,14 +1592,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateClusterVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1719,14 +1642,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateNodegroupConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1776,14 +1692,7 @@ extension EKSClient: EKSClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateNodegroupVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEMRServerless/EMRServerlessClient.swift b/Sources/Services/AWSEMRServerless/EMRServerlessClient.swift index e8a247809e2..3727b3047fa 100644 --- a/Sources/Services/AWSEMRServerless/EMRServerlessClient.swift +++ b/Sources/Services/AWSEMRServerless/EMRServerlessClient.swift @@ -140,14 +140,7 @@ extension EMRServerlessClient: EMRServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -540,14 +533,7 @@ extension EMRServerlessClient: EMRServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startJobRun") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -727,14 +713,7 @@ extension EMRServerlessClient: EMRServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSEMRcontainers/EMRcontainersClient.swift b/Sources/Services/AWSEMRcontainers/EMRcontainersClient.swift index 93d5b985fc0..22fbfae43e1 100644 --- a/Sources/Services/AWSEMRcontainers/EMRcontainersClient.swift +++ b/Sources/Services/AWSEMRcontainers/EMRcontainersClient.swift @@ -138,14 +138,7 @@ extension EMRcontainersClient: EMRcontainersClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createJobTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -192,14 +185,7 @@ extension EMRcontainersClient: EMRcontainersClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createManagedEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -246,14 +232,7 @@ extension EMRcontainersClient: EMRcontainersClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVirtualCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -599,14 +578,7 @@ extension EMRcontainersClient: EMRcontainersClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "getManagedEndpointSessionCredentials") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -868,14 +840,7 @@ extension EMRcontainersClient: EMRcontainersClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startJobRun") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSFSx/FSxClient.swift b/Sources/Services/AWSFSx/FSxClient.swift index da7813ee06b..acb5e26e4a3 100644 --- a/Sources/Services/AWSFSx/FSxClient.swift +++ b/Sources/Services/AWSFSx/FSxClient.swift @@ -96,14 +96,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateFileSystemAliases") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -217,14 +210,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "copyBackup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -302,14 +288,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBackup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -360,14 +339,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataRepositoryAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -422,14 +394,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataRepositoryTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -488,14 +453,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFileCache") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -568,14 +526,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFileSystem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -636,14 +587,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFileSystemFromBackup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -699,14 +643,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSnapshot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -758,14 +695,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStorageVirtualMachine") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -818,14 +748,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVolume") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -878,14 +801,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVolumeFromBackup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -937,14 +853,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteBackup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -994,14 +903,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDataRepositoryAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1051,14 +953,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteFileCache") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1108,14 +1003,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteFileSystem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1163,14 +1051,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteSnapshot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1219,14 +1100,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStorageVirtualMachine") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1276,14 +1150,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVolume") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1532,14 +1399,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "describeFileSystemAliases") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1783,14 +1643,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateFileSystemAliases") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1893,14 +1746,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "releaseFileSystemNfsV3Locks") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1948,14 +1794,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "restoreVolumeFromSnapshot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2003,14 +1842,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startMisconfiguredStateRecovery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2158,14 +1990,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDataRepositoryAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2217,14 +2042,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFileCache") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2358,14 +2176,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFileSystem") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2413,14 +2224,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSnapshot") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2470,14 +2274,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStorageVirtualMachine") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2527,14 +2324,7 @@ extension FSxClient: FSxClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVolume") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSFinspace/FinspaceClient.swift b/Sources/Services/AWSFinspace/FinspaceClient.swift index 0f72d2781a3..b74435b9633 100644 --- a/Sources/Services/AWSFinspace/FinspaceClient.swift +++ b/Sources/Services/AWSFinspace/FinspaceClient.swift @@ -149,14 +149,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createKxChangeset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -207,14 +200,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createKxCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -266,14 +252,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createKxDatabase") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -470,14 +449,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteKxCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -525,14 +497,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteKxDatabase") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1487,14 +1452,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateKxClusterDatabases") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1544,14 +1502,7 @@ extension FinspaceClient: FinspaceClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateKxDatabase") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSFinspacedata/FinspacedataClient.swift b/Sources/Services/AWSFinspacedata/FinspacedataClient.swift index 4b4384d837b..7e9e1011cc8 100644 --- a/Sources/Services/AWSFinspacedata/FinspacedataClient.swift +++ b/Sources/Services/AWSFinspacedata/FinspacedataClient.swift @@ -99,14 +99,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateUserToPermissionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -157,14 +150,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChangeset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -214,14 +200,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataView") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -272,14 +251,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -329,14 +301,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPermissionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -386,14 +351,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -444,14 +402,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -500,14 +451,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deletePermissionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -555,14 +499,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disableUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -612,14 +549,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateUserFromPermissionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -668,14 +598,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "enableUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1414,14 +1337,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "resetUserPassword") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1471,14 +1387,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateChangeset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1528,14 +1437,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1585,14 +1487,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePermissionGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1642,14 +1537,7 @@ extension FinspacedataClient: FinspacedataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSFis/FisClient.swift b/Sources/Services/AWSFis/FisClient.swift index db9cbeb5bea..32663b40921 100644 --- a/Sources/Services/AWSFis/FisClient.swift +++ b/Sources/Services/AWSFis/FisClient.swift @@ -106,14 +106,7 @@ extension FisClient: FisClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createExperimentTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -575,14 +568,7 @@ extension FisClient: FisClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startExperiment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSGlobalAccelerator/GlobalAcceleratorClient.swift b/Sources/Services/AWSGlobalAccelerator/GlobalAcceleratorClient.swift index 3c2b05a7678..b18a441ad0e 100644 --- a/Sources/Services/AWSGlobalAccelerator/GlobalAcceleratorClient.swift +++ b/Sources/Services/AWSGlobalAccelerator/GlobalAcceleratorClient.swift @@ -300,14 +300,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccelerator") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -356,14 +349,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomRoutingAccelerator") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -416,14 +402,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomRoutingEndpointGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -473,14 +452,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomRoutingListener") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -532,14 +504,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEndpointGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -589,14 +554,7 @@ extension GlobalAcceleratorClient: GlobalAcceleratorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createListener") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSGrafana/GrafanaClient.swift b/Sources/Services/AWSGrafana/GrafanaClient.swift index d9e39432281..430c1a05b49 100644 --- a/Sources/Services/AWSGrafana/GrafanaClient.swift +++ b/Sources/Services/AWSGrafana/GrafanaClient.swift @@ -144,14 +144,7 @@ extension GrafanaClient: GrafanaClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkspace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSGreengrassV2/GreengrassV2Client.swift b/Sources/Services/AWSGreengrassV2/GreengrassV2Client.swift index 68570a30a98..26389029491 100644 --- a/Sources/Services/AWSGreengrassV2/GreengrassV2Client.swift +++ b/Sources/Services/AWSGreengrassV2/GreengrassV2Client.swift @@ -312,14 +312,7 @@ extension GreengrassV2Client: GreengrassV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createComponentVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -370,14 +363,7 @@ extension GreengrassV2Client: GreengrassV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDeployment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSGuardDuty/GuardDutyClient.swift b/Sources/Services/AWSGuardDuty/GuardDutyClient.swift index 426e27bee32..7112169f169 100644 --- a/Sources/Services/AWSGuardDuty/GuardDutyClient.swift +++ b/Sources/Services/AWSGuardDuty/GuardDutyClient.swift @@ -231,14 +231,7 @@ extension GuardDutyClient: GuardDutyClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDetector") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -284,14 +277,7 @@ extension GuardDutyClient: GuardDutyClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFilter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -337,14 +323,7 @@ extension GuardDutyClient: GuardDutyClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIPSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -435,14 +414,7 @@ extension GuardDutyClient: GuardDutyClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPublishingDestination") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -533,14 +505,7 @@ extension GuardDutyClient: GuardDutyClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createThreatIntelSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSHealthLake/HealthLakeClient.swift b/Sources/Services/AWSHealthLake/HealthLakeClient.swift index 760f4009fc1..f06348ac327 100644 --- a/Sources/Services/AWSHealthLake/HealthLakeClient.swift +++ b/Sources/Services/AWSHealthLake/HealthLakeClient.swift @@ -97,14 +97,7 @@ extension HealthLakeClient: HealthLakeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFHIRDatastore") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -539,14 +532,7 @@ extension HealthLakeClient: HealthLakeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startFHIRExportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -596,14 +582,7 @@ extension HealthLakeClient: HealthLakeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startFHIRImportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSImagebuilder/ImagebuilderClient.swift b/Sources/Services/AWSImagebuilder/ImagebuilderClient.swift index 9a754ed257d..aeb59fc1072 100644 --- a/Sources/Services/AWSImagebuilder/ImagebuilderClient.swift +++ b/Sources/Services/AWSImagebuilder/ImagebuilderClient.swift @@ -101,14 +101,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "cancelImageCreation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -167,14 +160,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -229,14 +215,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContainerRecipe") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -291,14 +270,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDistributionConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -351,14 +323,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -412,14 +377,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createImagePipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -474,14 +432,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createImageRecipe") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -535,14 +486,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createInfrastructureConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1549,14 +1493,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1603,14 +1540,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importVmImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2670,14 +2600,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startImagePipelineExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2820,14 +2743,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDistributionConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2879,14 +2795,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateImagePipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2938,14 +2847,7 @@ extension ImagebuilderClient: ImagebuilderClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateInfrastructureConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSInspector2/Inspector2Client.swift b/Sources/Services/AWSInspector2/Inspector2Client.swift index f63bd665d76..9f2ea42cf4d 100644 --- a/Sources/Services/AWSInspector2/Inspector2Client.swift +++ b/Sources/Services/AWSInspector2/Inspector2Client.swift @@ -905,14 +905,7 @@ extension Inspector2Client: Inspector2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "enable") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -962,14 +955,7 @@ extension Inspector2Client: Inspector2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "enableDelegatedAdminAccount") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSInternetMonitor/InternetMonitorClient.swift b/Sources/Services/AWSInternetMonitor/InternetMonitorClient.swift index 5fec39c292d..e460fa4791c 100644 --- a/Sources/Services/AWSInternetMonitor/InternetMonitorClient.swift +++ b/Sources/Services/AWSInternetMonitor/InternetMonitorClient.swift @@ -99,14 +99,7 @@ extension InternetMonitorClient: InternetMonitorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMonitor") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -517,14 +510,7 @@ extension InternetMonitorClient: InternetMonitorClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateMonitor") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSIoT/IoTClient.swift b/Sources/Services/AWSIoT/IoTClient.swift index 86a50cf700d..c921760adf7 100644 --- a/Sources/Services/AWSIoT/IoTClient.swift +++ b/Sources/Services/AWSIoT/IoTClient.swift @@ -860,14 +860,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAuditSuppression") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1062,14 +1055,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomMetric") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1118,14 +1104,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDimension") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1572,14 +1551,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPackage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1629,14 +1601,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPackageVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3103,14 +3068,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deletePackage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3155,14 +3113,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deletePackageVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -10018,14 +9969,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startAuditMitigationActionsTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -10074,14 +10018,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDetectMitigationActionsTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11240,14 +11177,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePackage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11295,14 +11225,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePackageConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11351,14 +11274,7 @@ extension IoTClient: IoTClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePackageVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSIoTFleetHub/IoTFleetHubClient.swift b/Sources/Services/AWSIoTFleetHub/IoTFleetHubClient.swift index 56ee30dee3c..ad02662ab6a 100644 --- a/Sources/Services/AWSIoTFleetHub/IoTFleetHubClient.swift +++ b/Sources/Services/AWSIoTFleetHub/IoTFleetHubClient.swift @@ -97,14 +97,7 @@ extension IoTFleetHubClient: IoTFleetHubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -152,14 +145,7 @@ extension IoTFleetHubClient: IoTFleetHubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -427,14 +413,7 @@ extension IoTFleetHubClient: IoTFleetHubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSIoTRoboRunner/IoTRoboRunnerClient.swift b/Sources/Services/AWSIoTRoboRunner/IoTRoboRunnerClient.swift index fa57cbe177f..a81d4b58a33 100644 --- a/Sources/Services/AWSIoTRoboRunner/IoTRoboRunnerClient.swift +++ b/Sources/Services/AWSIoTRoboRunner/IoTRoboRunnerClient.swift @@ -100,14 +100,7 @@ extension IoTRoboRunnerClient: IoTRoboRunnerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDestination") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -157,14 +150,7 @@ extension IoTRoboRunnerClient: IoTRoboRunnerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSite") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -215,14 +201,7 @@ extension IoTRoboRunnerClient: IoTRoboRunnerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorker") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -273,14 +252,7 @@ extension IoTRoboRunnerClient: IoTRoboRunnerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkerFleet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSIoTSiteWise/IoTSiteWiseClient.swift b/Sources/Services/AWSIoTSiteWise/IoTSiteWiseClient.swift index eb1a60e79ec..7374c058230 100644 --- a/Sources/Services/AWSIoTSiteWise/IoTSiteWiseClient.swift +++ b/Sources/Services/AWSIoTSiteWise/IoTSiteWiseClient.swift @@ -100,14 +100,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateAssets") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -156,14 +149,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateTimeSeriesToAssetProperty") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -213,14 +199,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "batchAssociateProjectAssets") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -268,14 +247,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "batchDisassociateProjectAssets") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -522,14 +494,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -580,14 +545,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAsset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -638,14 +596,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAssetModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -744,14 +695,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDashboard") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -848,14 +792,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPortal") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -904,14 +841,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProject") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -959,14 +889,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1013,14 +936,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAsset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1067,14 +983,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAssetModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1120,14 +1029,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDashboard") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1218,14 +1120,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deletePortal") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1271,14 +1166,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteProject") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1333,14 +1221,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteTimeSeries") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2018,14 +1899,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateAssets") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2074,14 +1948,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateTimeSeriesFromAssetProperty") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3258,14 +3125,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3315,14 +3175,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAsset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3373,14 +3226,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAssetModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3429,14 +3275,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAssetProperty") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "api.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3484,14 +3323,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDashboard") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3637,14 +3469,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePortal") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3692,14 +3517,7 @@ extension IoTSiteWiseClient: IoTSiteWiseClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateProject") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "monitor.")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSIoTWireless/IoTWirelessClient.swift b/Sources/Services/AWSIoTWireless/IoTWirelessClient.swift index ea3d11cd61c..ecf82e966a5 100644 --- a/Sources/Services/AWSIoTWireless/IoTWirelessClient.swift +++ b/Sources/Services/AWSIoTWireless/IoTWirelessClient.swift @@ -99,14 +99,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateAwsAccountWithPartnerAccount") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -496,14 +489,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDestination") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -552,14 +538,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDeviceProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -609,14 +588,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFuotaTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -666,14 +638,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMulticastGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -723,14 +688,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkAnalyzerConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -779,14 +737,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -836,14 +787,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWirelessDevice") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -892,14 +836,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWirelessGateway") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -998,14 +935,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWirelessGatewayTaskDefinition") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4399,14 +4329,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSingleWirelessDeviceImportTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4456,14 +4379,7 @@ extension IoTWirelessClient: IoTWirelessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startWirelessDeviceImportTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSKendra/KendraClient.swift b/Sources/Services/AWSKendra/KendraClient.swift index 6d2c8b72486..87a2ea21a9e 100644 --- a/Sources/Services/AWSKendra/KendraClient.swift +++ b/Sources/Services/AWSKendra/KendraClient.swift @@ -450,14 +450,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessControlConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -510,14 +503,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataSource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -569,14 +555,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createExperience") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -628,14 +607,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFaq") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -738,14 +710,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIndex") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -797,14 +762,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createQuerySuggestionsBlockList") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -856,14 +814,7 @@ extension KendraClient: KendraClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createThesaurus") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSKendraRanking/KendraRankingClient.swift b/Sources/Services/AWSKendraRanking/KendraRankingClient.swift index 5b2d14322a0..057f9b310c5 100644 --- a/Sources/Services/AWSKendraRanking/KendraRankingClient.swift +++ b/Sources/Services/AWSKendraRanking/KendraRankingClient.swift @@ -99,14 +99,7 @@ extension KendraRankingClient: KendraRankingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRescoreExecutionPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSLookoutEquipment/LookoutEquipmentClient.swift b/Sources/Services/AWSLookoutEquipment/LookoutEquipmentClient.swift index 495528a6b29..b1be1d59ded 100644 --- a/Sources/Services/AWSLookoutEquipment/LookoutEquipmentClient.swift +++ b/Sources/Services/AWSLookoutEquipment/LookoutEquipmentClient.swift @@ -99,14 +99,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -158,14 +151,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createInferenceScheduler") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -217,14 +203,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLabel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -275,14 +254,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLabelGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -334,14 +306,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -392,14 +357,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRetrainingScheduler") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1242,14 +1200,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1301,14 +1252,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importModelVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1941,14 +1885,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putResourcePolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2000,14 +1937,7 @@ extension LookoutEquipmentClient: LookoutEquipmentClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDataIngestionJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSLookoutVision/LookoutVisionClient.swift b/Sources/Services/AWSLookoutVision/LookoutVisionClient.swift index 28235f21730..80b1a48825d 100644 --- a/Sources/Services/AWSLookoutVision/LookoutVisionClient.swift +++ b/Sources/Services/AWSLookoutVision/LookoutVisionClient.swift @@ -100,14 +100,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -159,14 +152,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -218,14 +204,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProject") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -283,14 +262,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteDataset") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -338,14 +310,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -393,14 +358,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteProject") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -915,14 +873,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -991,14 +942,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startModelPackagingJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1049,14 +993,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "stopModel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1201,14 +1138,7 @@ extension LookoutVisionClient: LookoutVisionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDatasetEntries") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSM2/M2Client.swift b/Sources/Services/AWSM2/M2Client.swift index b55de281226..9b6eea1bc85 100644 --- a/Sources/Services/AWSM2/M2Client.swift +++ b/Sources/Services/AWSM2/M2Client.swift @@ -145,14 +145,7 @@ extension M2Client: M2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -203,14 +196,7 @@ extension M2Client: M2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDataSetImportTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -261,14 +247,7 @@ extension M2Client: M2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDeployment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -318,14 +297,7 @@ extension M2Client: M2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEnvironment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMacie2/Macie2Client.swift b/Sources/Services/AWSMacie2/Macie2Client.swift index ad3773ee02e..bdd0c1330b1 100644 --- a/Sources/Services/AWSMacie2/Macie2Client.swift +++ b/Sources/Services/AWSMacie2/Macie2Client.swift @@ -200,14 +200,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAllowList") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -258,14 +251,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createClassificationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -316,14 +302,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCustomDataIdentifier") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -374,14 +353,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFindingsFilter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1249,14 +1221,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "enableMacie") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1307,14 +1272,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "enableOrganizationAdminAccount") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3092,14 +3050,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putFindingsPublicationConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3519,14 +3470,7 @@ extension Macie2Client: Macie2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateFindingsFilter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSManagedBlockchain/ManagedBlockchainClient.swift b/Sources/Services/AWSManagedBlockchain/ManagedBlockchainClient.swift index e03e6520cad..f2db2a27e99 100644 --- a/Sources/Services/AWSManagedBlockchain/ManagedBlockchainClient.swift +++ b/Sources/Services/AWSManagedBlockchain/ManagedBlockchainClient.swift @@ -100,14 +100,7 @@ extension ManagedBlockchainClient: ManagedBlockchainClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessor") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -160,14 +153,7 @@ extension ManagedBlockchainClient: ManagedBlockchainClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMember") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -218,14 +204,7 @@ extension ManagedBlockchainClient: ManagedBlockchainClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetwork") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -278,14 +257,7 @@ extension ManagedBlockchainClient: ManagedBlockchainClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNode") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -336,14 +308,7 @@ extension ManagedBlockchainClient: ManagedBlockchainClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProposal") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMarketplaceCatalog/MarketplaceCatalogClient.swift b/Sources/Services/AWSMarketplaceCatalog/MarketplaceCatalogClient.swift index 73cdb87d713..2d58f8a2d9e 100644 --- a/Sources/Services/AWSMarketplaceCatalog/MarketplaceCatalogClient.swift +++ b/Sources/Services/AWSMarketplaceCatalog/MarketplaceCatalogClient.swift @@ -523,14 +523,7 @@ extension MarketplaceCatalogClient: MarketplaceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startChangeSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMediaConvert/MediaConvertClient.swift b/Sources/Services/AWSMediaConvert/MediaConvertClient.swift index d14c0d1fea8..39ab317e68c 100644 --- a/Sources/Services/AWSMediaConvert/MediaConvertClient.swift +++ b/Sources/Services/AWSMediaConvert/MediaConvertClient.swift @@ -194,14 +194,7 @@ extension MediaConvertClient: MediaConvertClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMediaLive/MediaLiveClient.swift b/Sources/Services/AWSMediaLive/MediaLiveClient.swift index 56b2533d92b..59ab77c40cf 100644 --- a/Sources/Services/AWSMediaLive/MediaLiveClient.swift +++ b/Sources/Services/AWSMediaLive/MediaLiveClient.swift @@ -454,14 +454,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -511,14 +504,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createInput") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -619,14 +605,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMultiplex") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -678,14 +657,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMultiplexProgram") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -735,14 +707,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPartnerInput") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2256,14 +2221,7 @@ extension MediaLiveClient: MediaLiveClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "purchaseOffering") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMediaPackageV2/MediaPackageV2Client.swift b/Sources/Services/AWSMediaPackageV2/MediaPackageV2Client.swift index 59cf49c4f99..2cc02aa5542 100644 --- a/Sources/Services/AWSMediaPackageV2/MediaPackageV2Client.swift +++ b/Sources/Services/AWSMediaPackageV2/MediaPackageV2Client.swift @@ -100,14 +100,7 @@ extension MediaPackageV2Client: MediaPackageV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -159,14 +152,7 @@ extension MediaPackageV2Client: MediaPackageV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createChannelGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -218,14 +204,7 @@ extension MediaPackageV2Client: MediaPackageV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createOriginEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMedicalImaging/MedicalImagingClient.swift b/Sources/Services/AWSMedicalImaging/MedicalImagingClient.swift index afd28b12417..a5fac3a1b42 100644 --- a/Sources/Services/AWSMedicalImaging/MedicalImagingClient.swift +++ b/Sources/Services/AWSMedicalImaging/MedicalImagingClient.swift @@ -149,14 +149,7 @@ extension MedicalImagingClient: MedicalImagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDatastore") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -767,14 +760,7 @@ extension MedicalImagingClient: MedicalImagingClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startDICOMImportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMgn/MgnClient.swift b/Sources/Services/AWSMgn/MgnClient.swift index d99b42c3ecf..fc74af3d0b4 100644 --- a/Sources/Services/AWSMgn/MgnClient.swift +++ b/Sources/Services/AWSMgn/MgnClient.swift @@ -2476,14 +2476,7 @@ extension MgnClient: MgnClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startImport") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMigrationHubRefactorSpaces/MigrationHubRefactorSpacesClient.swift b/Sources/Services/AWSMigrationHubRefactorSpaces/MigrationHubRefactorSpacesClient.swift index 3469d36e6c6..dc049d8698a 100644 --- a/Sources/Services/AWSMigrationHubRefactorSpaces/MigrationHubRefactorSpacesClient.swift +++ b/Sources/Services/AWSMigrationHubRefactorSpaces/MigrationHubRefactorSpacesClient.swift @@ -100,14 +100,7 @@ extension MigrationHubRefactorSpacesClient: MigrationHubRefactorSpacesClientProt .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -158,14 +151,7 @@ extension MigrationHubRefactorSpacesClient: MigrationHubRefactorSpacesClientProt .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEnvironment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -223,14 +209,7 @@ extension MigrationHubRefactorSpacesClient: MigrationHubRefactorSpacesClientProt .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRoute") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -281,14 +260,7 @@ extension MigrationHubRefactorSpacesClient: MigrationHubRefactorSpacesClientProt .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createService") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSMq/MqClient.swift b/Sources/Services/AWSMq/MqClient.swift index 0b67e1fda8b..7b6c8e011cc 100644 --- a/Sources/Services/AWSMq/MqClient.swift +++ b/Sources/Services/AWSMq/MqClient.swift @@ -125,14 +125,7 @@ extension MqClient: MqClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBroker") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSNetworkManager/NetworkManagerClient.swift b/Sources/Services/AWSNetworkManager/NetworkManagerClient.swift index a7a72b201cb..9a5576f3b27 100644 --- a/Sources/Services/AWSNetworkManager/NetworkManagerClient.swift +++ b/Sources/Services/AWSNetworkManager/NetworkManagerClient.swift @@ -345,14 +345,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConnectAttachment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -402,14 +395,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConnectPeer") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -509,14 +495,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCoreNetwork") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -765,14 +744,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSiteToSiteVpnAttachment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -822,14 +794,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTransitGatewayPeering") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -879,14 +844,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTransitGatewayRouteTableAttachment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -936,14 +894,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVpcAttachment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3320,14 +3271,7 @@ extension NetworkManagerClient: NetworkManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putCoreNetworkPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSNimble/NimbleClient.swift b/Sources/Services/AWSNimble/NimbleClient.swift index 9963c35365c..2891cab0d39 100644 --- a/Sources/Services/AWSNimble/NimbleClient.swift +++ b/Sources/Services/AWSNimble/NimbleClient.swift @@ -100,14 +100,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "acceptEulas") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -159,14 +152,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLaunchProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -218,14 +204,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStreamingImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -277,14 +256,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStreamingSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -336,14 +308,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStreamingSessionStream") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -395,14 +360,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStudio") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -454,14 +412,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createStudioComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -513,14 +464,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteLaunchProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -569,14 +513,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteLaunchProfileMember") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -625,14 +562,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStreamingImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -681,14 +611,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStreamingSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -737,14 +660,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStudio") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -793,14 +709,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStudioComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -849,14 +758,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteStudioMember") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1995,14 +1897,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putLaunchProfileMembers") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2054,14 +1949,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putStudioMembers") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2113,14 +2001,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startStreamingSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2172,14 +2053,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startStudioSSOConfigurationRepair") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2228,14 +2102,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "stopStreamingSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2385,14 +2252,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateLaunchProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2444,14 +2304,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateLaunchProfileMember") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2503,14 +2356,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStreamingImage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2562,14 +2408,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStudio") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2621,14 +2460,7 @@ extension NimbleClient: NimbleClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateStudioComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSOmics/OmicsClient.swift b/Sources/Services/AWSOmics/OmicsClient.swift index c009d920f78..2760324f2c4 100644 --- a/Sources/Services/AWSOmics/OmicsClient.swift +++ b/Sources/Services/AWSOmics/OmicsClient.swift @@ -634,14 +634,7 @@ extension OmicsClient: OmicsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRunGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "workflows-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -842,14 +835,7 @@ extension OmicsClient: OmicsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkflow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "workflows-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3597,14 +3583,7 @@ extension OmicsClient: OmicsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startRun") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.requestId == nil { - copiedInput.requestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.requestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware(hostPrefix: "workflows-")) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSOpenSearchServerless/OpenSearchServerlessClient.swift b/Sources/Services/AWSOpenSearchServerless/OpenSearchServerlessClient.swift index 53b9d41f191..0adb71f3fd3 100644 --- a/Sources/Services/AWSOpenSearchServerless/OpenSearchServerlessClient.swift +++ b/Sources/Services/AWSOpenSearchServerless/OpenSearchServerlessClient.swift @@ -189,14 +189,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -246,14 +239,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCollection") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -302,14 +288,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSecurityConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -358,14 +337,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSecurityPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -414,14 +386,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createVpcEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -470,14 +435,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -526,14 +484,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteCollection") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -582,14 +533,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteSecurityConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -638,14 +582,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteSecurityPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -694,14 +631,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteVpcEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1356,14 +1286,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateAccessPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1457,14 +1380,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateCollection") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1513,14 +1429,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSecurityConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1570,14 +1479,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSecurityPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1625,14 +1527,7 @@ extension OpenSearchServerlessClient: OpenSearchServerlessClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateVpcEndpoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSPcaConnectorAd/PcaConnectorAdClient.swift b/Sources/Services/AWSPcaConnectorAd/PcaConnectorAdClient.swift index 423070694ad..3338a13ca0f 100644 --- a/Sources/Services/AWSPcaConnectorAd/PcaConnectorAdClient.swift +++ b/Sources/Services/AWSPcaConnectorAd/PcaConnectorAdClient.swift @@ -100,14 +100,7 @@ extension PcaConnectorAdClient: PcaConnectorAdClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConnector") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -157,14 +150,7 @@ extension PcaConnectorAdClient: PcaConnectorAdClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDirectoryRegistration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -214,14 +200,7 @@ extension PcaConnectorAdClient: PcaConnectorAdClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServicePrincipalName") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -272,14 +251,7 @@ extension PcaConnectorAdClient: PcaConnectorAdClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -330,14 +302,7 @@ extension PcaConnectorAdClient: PcaConnectorAdClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTemplateGroupAccessControlEntry") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSPinpointSMSVoiceV2/PinpointSMSVoiceV2Client.swift b/Sources/Services/AWSPinpointSMSVoiceV2/PinpointSMSVoiceV2Client.swift index b58e10c0634..a38a6cdf3db 100644 --- a/Sources/Services/AWSPinpointSMSVoiceV2/PinpointSMSVoiceV2Client.swift +++ b/Sources/Services/AWSPinpointSMSVoiceV2/PinpointSMSVoiceV2Client.swift @@ -100,14 +100,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateOriginationIdentity") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -158,14 +151,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConfigurationSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -217,14 +203,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEventDestination") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -275,14 +254,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createOptOutList") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -334,14 +306,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPool") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1371,14 +1336,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateOriginationIdentity") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1678,14 +1636,7 @@ extension PinpointSMSVoiceV2Client: PinpointSMSVoiceV2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "requestPhoneNumber") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSProton/ProtonClient.swift b/Sources/Services/AWSProton/ProtonClient.swift index 300373d1c00..df0412744da 100644 --- a/Sources/Services/AWSProton/ProtonClient.swift +++ b/Sources/Services/AWSProton/ProtonClient.swift @@ -368,14 +368,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -484,14 +477,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEnvironmentAccountConnection") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -597,14 +583,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createEnvironmentTemplateVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -756,14 +735,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -915,14 +887,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceTemplateVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3826,14 +3791,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4135,14 +4093,7 @@ extension ProtonClient: ProtonClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateServiceInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSRedshiftData/RedshiftDataClient.swift b/Sources/Services/AWSRedshiftData/RedshiftDataClient.swift index d824f439c15..a8b0b26468d 100644 --- a/Sources/Services/AWSRedshiftData/RedshiftDataClient.swift +++ b/Sources/Services/AWSRedshiftData/RedshiftDataClient.swift @@ -112,14 +112,7 @@ extension RedshiftDataClient: RedshiftDataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "batchExecuteStatement") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -341,14 +334,7 @@ extension RedshiftDataClient: RedshiftDataClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "executeStatement") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSRekognition/RekognitionClient.swift b/Sources/Services/AWSRekognition/RekognitionClient.swift index ed3c8d8ae04..24ce3d6c422 100644 --- a/Sources/Services/AWSRekognition/RekognitionClient.swift +++ b/Sources/Services/AWSRekognition/RekognitionClient.swift @@ -108,14 +108,7 @@ extension RekognitionClient: RekognitionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateFaces") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -590,14 +583,7 @@ extension RekognitionClient: RekognitionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1006,14 +992,7 @@ extension RekognitionClient: RekognitionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteUser") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1691,14 +1670,7 @@ extension RekognitionClient: RekognitionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "disassociateFaces") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3511,14 +3483,7 @@ extension RekognitionClient: RekognitionClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startMediaAnalysisJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSResiliencehub/ResiliencehubClient.swift b/Sources/Services/AWSResiliencehub/ResiliencehubClient.swift index 61715c72096..9d1f56f0e7f 100644 --- a/Sources/Services/AWSResiliencehub/ResiliencehubClient.swift +++ b/Sources/Services/AWSResiliencehub/ResiliencehubClient.swift @@ -197,14 +197,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApp") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -255,14 +248,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppVersionAppComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -319,14 +305,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAppVersionResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -377,14 +356,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRecommendationTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -434,14 +406,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createResiliencyPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -490,14 +455,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteApp") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -547,14 +505,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAppAssessment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -604,14 +555,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAppInputSource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -665,14 +609,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAppVersionAppComponent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -728,14 +665,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteAppVersionResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -784,14 +714,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteRecommendationTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -841,14 +764,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteResiliencyPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2437,14 +2353,7 @@ extension ResiliencehubClient: ResiliencehubClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startAppAssessment") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSResourceExplorer2/ResourceExplorer2Client.swift b/Sources/Services/AWSResourceExplorer2/ResourceExplorer2Client.swift index c3d50907c0c..df8df101efd 100644 --- a/Sources/Services/AWSResourceExplorer2/ResourceExplorer2Client.swift +++ b/Sources/Services/AWSResourceExplorer2/ResourceExplorer2Client.swift @@ -198,14 +198,7 @@ extension ResourceExplorer2Client: ResourceExplorer2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIndex") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) @@ -256,14 +249,7 @@ extension ResourceExplorer2Client: ResourceExplorer2ClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createView") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSRoboMaker/RoboMakerClient.swift b/Sources/Services/AWSRoboMaker/RoboMakerClient.swift index 4d10a4ada8d..fb858b354ad 100644 --- a/Sources/Services/AWSRoboMaker/RoboMakerClient.swift +++ b/Sources/Services/AWSRoboMaker/RoboMakerClient.swift @@ -430,14 +430,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDeploymentJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -779,14 +772,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSimulationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -836,14 +822,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorldExportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -894,14 +873,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorldGenerationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2498,14 +2470,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSimulationJobBatch") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2557,14 +2522,7 @@ extension RoboMakerClient: RoboMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "syncDeploymentJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSRoute53RecoveryControlConfig/Route53RecoveryControlConfigClient.swift b/Sources/Services/AWSRoute53RecoveryControlConfig/Route53RecoveryControlConfigClient.swift index 96d10194281..5bf20bf8c95 100644 --- a/Sources/Services/AWSRoute53RecoveryControlConfig/Route53RecoveryControlConfigClient.swift +++ b/Sources/Services/AWSRoute53RecoveryControlConfig/Route53RecoveryControlConfigClient.swift @@ -100,14 +100,7 @@ extension Route53RecoveryControlConfigClient: Route53RecoveryControlConfigClient .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createCluster") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -158,14 +151,7 @@ extension Route53RecoveryControlConfigClient: Route53RecoveryControlConfigClient .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createControlPanel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -216,14 +202,7 @@ extension Route53RecoveryControlConfigClient: Route53RecoveryControlConfigClient .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRoutingControl") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -269,14 +248,7 @@ extension Route53RecoveryControlConfigClient: Route53RecoveryControlConfigClient .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSafetyRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSRoute53Resolver/Route53ResolverClient.swift b/Sources/Services/AWSRoute53Resolver/Route53ResolverClient.swift index 00627d0b026..0c8c4a05ae0 100644 --- a/Sources/Services/AWSRoute53Resolver/Route53ResolverClient.swift +++ b/Sources/Services/AWSRoute53Resolver/Route53ResolverClient.swift @@ -100,14 +100,7 @@ extension Route53ResolverClient: Route53ResolverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "associateFirewallRuleGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -312,14 +305,7 @@ extension Route53ResolverClient: Route53ResolverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFirewallDomainList") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -370,14 +356,7 @@ extension Route53ResolverClient: Route53ResolverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFirewallRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -427,14 +406,7 @@ extension Route53ResolverClient: Route53ResolverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createFirewallRuleGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -592,14 +564,7 @@ extension Route53ResolverClient: Route53ResolverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createResolverQueryLogConfig") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSS3Control/S3ControlClient.swift b/Sources/Services/AWSS3Control/S3ControlClient.swift index e27e7b41ee0..49f5076b420 100644 --- a/Sources/Services/AWSS3Control/S3ControlClient.swift +++ b/Sources/Services/AWSS3Control/S3ControlClient.swift @@ -266,14 +266,7 @@ extension S3ControlClient: S3ControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(accountId: input.accountId, endpoint: config.endpoint, region: config.region, requiresAccountId: true, useArnRegion: config.serviceSpecific.useArnRegion, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -322,14 +315,7 @@ extension S3ControlClient: S3ControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMultiRegionAccessPoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) operation.buildStep.intercept(position: .before, middleware: ClientRuntime.ContentMD5Middleware()) @@ -804,14 +790,7 @@ extension S3ControlClient: S3ControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteMultiRegionAccessPoint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) operation.buildStep.intercept(position: .before, middleware: ClientRuntime.ContentMD5Middleware()) @@ -2723,14 +2702,7 @@ extension S3ControlClient: S3ControlClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putMultiRegionAccessPointPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) operation.buildStep.intercept(position: .before, middleware: ClientRuntime.ContentMD5Middleware()) diff --git a/Sources/Services/AWSSSM/SSMClient.swift b/Sources/Services/AWSSSM/SSMClient.swift index b57823d0b5d..afb91ccff08 100644 --- a/Sources/Services/AWSSSM/SSMClient.swift +++ b/Sources/Services/AWSSSM/SSMClient.swift @@ -537,14 +537,7 @@ extension SSMClient: SSMClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMaintenanceWindow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -690,14 +683,7 @@ extension SSMClient: SSMClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPatchBaseline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -948,14 +934,7 @@ extension SSMClient: SSMClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteInventory") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5586,14 +5565,7 @@ extension SSMClient: SSMClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerTargetWithMaintenanceWindow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -5643,14 +5615,7 @@ extension SSMClient: SSMClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerTaskWithMaintenanceWindow") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSSMContacts/SSMContactsClient.swift b/Sources/Services/AWSSSMContacts/SSMContactsClient.swift index 1990fcd9a29..a43205fcee2 100644 --- a/Sources/Services/AWSSSMContacts/SSMContactsClient.swift +++ b/Sources/Services/AWSSSMContacts/SSMContactsClient.swift @@ -198,14 +198,7 @@ extension SSMContactsClient: SSMContactsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -256,14 +249,7 @@ extension SSMContactsClient: SSMContactsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContactChannel") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1696,14 +1682,7 @@ extension SSMContactsClient: SSMContactsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startEngagement") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSSMIncidents/SSMIncidentsClient.swift b/Sources/Services/AWSSSMIncidents/SSMIncidentsClient.swift index 908f194aa31..ee01a54c69b 100644 --- a/Sources/Services/AWSSSMIncidents/SSMIncidentsClient.swift +++ b/Sources/Services/AWSSSMIncidents/SSMIncidentsClient.swift @@ -99,14 +99,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createReplicationSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -156,14 +149,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createResponsePlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -213,14 +199,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTimelineEvent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1066,14 +1045,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startIncident") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1219,14 +1191,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateDeletionProtection") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1276,14 +1241,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateIncidentRecord") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1333,14 +1291,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateRelatedItems") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1390,14 +1341,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateReplicationSet") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1447,14 +1391,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateResponsePlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1504,14 +1441,7 @@ extension SSMIncidentsClient: SSMIncidentsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateTimelineEvent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSageMaker/SageMakerClient.swift b/Sources/Services/AWSSageMaker/SageMakerClient.swift index ed697dbddfa..a8017498c07 100644 --- a/Sources/Services/AWSSageMaker/SageMakerClient.swift +++ b/Sources/Services/AWSSageMaker/SageMakerClient.swift @@ -1418,14 +1418,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createImageVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1853,14 +1846,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createModelPackage") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2143,14 +2129,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4361,14 +4340,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deletePipeline") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -10987,14 +10959,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "retryPipelineExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11081,14 +11046,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendPipelineExecutionStepFailure") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11135,14 +11093,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "sendPipelineExecutionStepSuccess") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11365,14 +11316,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startPipelineExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -11854,14 +11798,7 @@ extension SageMakerClient: SageMakerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "stopPipelineExecution") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSageMakerGeospatial/SageMakerGeospatialClient.swift b/Sources/Services/AWSSageMakerGeospatial/SageMakerGeospatialClient.swift index 349e0b7165c..623a503e523 100644 --- a/Sources/Services/AWSSageMakerGeospatial/SageMakerGeospatialClient.swift +++ b/Sources/Services/AWSSageMakerGeospatial/SageMakerGeospatialClient.swift @@ -192,14 +192,7 @@ extension SageMakerGeospatialClient: SageMakerGeospatialClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "exportEarthObservationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -250,14 +243,7 @@ extension SageMakerGeospatialClient: SageMakerGeospatialClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "exportVectorEnrichmentJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -724,14 +710,7 @@ extension SageMakerGeospatialClient: SageMakerGeospatialClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startEarthObservationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -782,14 +761,7 @@ extension SageMakerGeospatialClient: SageMakerGeospatialClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startVectorEnrichmentJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSavingsplans/SavingsplansClient.swift b/Sources/Services/AWSSavingsplans/SavingsplansClient.swift index cb5dae90050..7060d343c71 100644 --- a/Sources/Services/AWSSavingsplans/SavingsplansClient.swift +++ b/Sources/Services/AWSSavingsplans/SavingsplansClient.swift @@ -97,14 +97,7 @@ extension SavingsplansClient: SavingsplansClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSavingsPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSScheduler/SchedulerClient.swift b/Sources/Services/AWSScheduler/SchedulerClient.swift index 1d863a27726..eb038a98213 100644 --- a/Sources/Services/AWSScheduler/SchedulerClient.swift +++ b/Sources/Services/AWSScheduler/SchedulerClient.swift @@ -99,14 +99,7 @@ extension SchedulerClient: SchedulerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSchedule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -155,14 +148,7 @@ extension SchedulerClient: SchedulerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createScheduleGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -211,14 +197,7 @@ extension SchedulerClient: SchedulerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteSchedule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -265,14 +244,7 @@ extension SchedulerClient: SchedulerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteScheduleGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -635,14 +607,7 @@ extension SchedulerClient: SchedulerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSchedule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSchemas/SchemasClient.swift b/Sources/Services/AWSSchemas/SchemasClient.swift index ee47d4bd2a0..f83f3acb771 100644 --- a/Sources/Services/AWSSchemas/SchemasClient.swift +++ b/Sources/Services/AWSSchemas/SchemasClient.swift @@ -1505,14 +1505,7 @@ extension SchemasClient: SchemasClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSchema") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientTokenId == nil { - copiedInput.clientTokenId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientTokenId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSecretsManager/SecretsManagerClient.swift b/Sources/Services/AWSSecretsManager/SecretsManagerClient.swift index c09432bfb42..80c1d6b2345 100644 --- a/Sources/Services/AWSSecretsManager/SecretsManagerClient.swift +++ b/Sources/Services/AWSSecretsManager/SecretsManagerClient.swift @@ -163,14 +163,7 @@ extension SecretsManagerClient: SecretsManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSecret") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -704,14 +697,7 @@ extension SecretsManagerClient: SecretsManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "putSecretValue") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -928,14 +914,7 @@ extension SecretsManagerClient: SecretsManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "rotateSecret") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1158,14 +1137,7 @@ extension SecretsManagerClient: SecretsManagerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateSecret") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSServiceCatalog/ServiceCatalogClient.swift b/Sources/Services/AWSServiceCatalog/ServiceCatalogClient.swift index da5b0d7472d..9ace02ff174 100644 --- a/Sources/Services/AWSServiceCatalog/ServiceCatalogClient.swift +++ b/Sources/Services/AWSServiceCatalog/ServiceCatalogClient.swift @@ -472,14 +472,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "copyProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -528,14 +521,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createConstraint") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -583,14 +569,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPortfolio") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -687,14 +666,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -742,14 +714,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProvisionedProductPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -797,14 +762,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProvisioningArtifact") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -851,14 +809,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceAction") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2384,14 +2335,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "executeProvisionedProductPlan") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2439,14 +2383,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "executeProvisionedProductServiceAction") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.executeToken == nil { - copiedInput.executeToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.executeToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2587,14 +2524,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importAsProvisionedProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3468,14 +3398,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "notifyProvisionProductEngineWorkflowResult") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3522,14 +3445,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "notifyTerminateProvisionedProductEngineWorkflowResult") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3576,14 +3492,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "notifyUpdateProvisionedProductEngineWorkflowResult") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3631,14 +3540,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "provisionProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.provisionToken == nil { - copiedInput.provisionToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.provisionToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3910,14 +3812,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "terminateProvisionedProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.terminateToken == nil { - copiedInput.terminateToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.terminateToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4153,14 +4048,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateProvisionedProduct") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.updateToken == nil { - copiedInput.updateToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.updateToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -4208,14 +4096,7 @@ extension ServiceCatalogClient: ServiceCatalogClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateProvisionedProductProperties") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.idempotencyToken == nil { - copiedInput.idempotencyToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.idempotencyToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSServiceCatalogAppRegistry/ServiceCatalogAppRegistryClient.swift b/Sources/Services/AWSServiceCatalogAppRegistry/ServiceCatalogAppRegistryClient.swift index 814e5583a70..ca7eb1367a8 100644 --- a/Sources/Services/AWSServiceCatalogAppRegistry/ServiceCatalogAppRegistryClient.swift +++ b/Sources/Services/AWSServiceCatalogAppRegistry/ServiceCatalogAppRegistryClient.swift @@ -189,14 +189,7 @@ extension ServiceCatalogAppRegistryClient: ServiceCatalogAppRegistryClientProtoc .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createApplication") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -244,14 +237,7 @@ extension ServiceCatalogAppRegistryClient: ServiceCatalogAppRegistryClientProtoc .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAttributeGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSServiceDiscovery/ServiceDiscoveryClient.swift b/Sources/Services/AWSServiceDiscovery/ServiceDiscoveryClient.swift index b415f52d664..fae1bd13c29 100644 --- a/Sources/Services/AWSServiceDiscovery/ServiceDiscoveryClient.swift +++ b/Sources/Services/AWSServiceDiscovery/ServiceDiscoveryClient.swift @@ -98,14 +98,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createHttpNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -155,14 +148,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPrivateDnsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -212,14 +198,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPublicDnsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -289,14 +268,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createService") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1063,14 +1035,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerInstance") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.creatorRequestId == nil { - copiedInput.creatorRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.creatorRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1212,14 +1177,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateHttpNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.updaterRequestId == nil { - copiedInput.updaterRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.updaterRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1316,14 +1274,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePrivateDnsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.updaterRequestId == nil { - copiedInput.updaterRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.updaterRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1372,14 +1323,7 @@ extension ServiceDiscoveryClient: ServiceDiscoveryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updatePublicDnsNamespace") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.updaterRequestId == nil { - copiedInput.updaterRequestId = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.updaterRequestId)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSigner/SignerClient.swift b/Sources/Services/AWSSigner/SignerClient.swift index d911b9aa637..f5f957e1aa7 100644 --- a/Sources/Services/AWSSigner/SignerClient.swift +++ b/Sources/Services/AWSSigner/SignerClient.swift @@ -847,14 +847,7 @@ extension SignerClient: SignerClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSigningJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSimSpaceWeaver/SimSpaceWeaverClient.swift b/Sources/Services/AWSSimSpaceWeaver/SimSpaceWeaverClient.swift index f6818de8227..ecb5560c183 100644 --- a/Sources/Services/AWSSimSpaceWeaver/SimSpaceWeaverClient.swift +++ b/Sources/Services/AWSSimSpaceWeaver/SimSpaceWeaverClient.swift @@ -471,14 +471,7 @@ extension SimSpaceWeaverClient: SimSpaceWeaverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startApp") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -575,14 +568,7 @@ extension SimSpaceWeaverClient: SimSpaceWeaverClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSimulation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSSnowDeviceManagement/SnowDeviceManagementClient.swift b/Sources/Services/AWSSnowDeviceManagement/SnowDeviceManagementClient.swift index 6f91ba8d838..43c70a936e9 100644 --- a/Sources/Services/AWSSnowDeviceManagement/SnowDeviceManagementClient.swift +++ b/Sources/Services/AWSSnowDeviceManagement/SnowDeviceManagementClient.swift @@ -144,14 +144,7 @@ extension SnowDeviceManagementClient: SnowDeviceManagementClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSTextract/TextractClient.swift b/Sources/Services/AWSTextract/TextractClient.swift index aaa57f93345..489507794d6 100644 --- a/Sources/Services/AWSTextract/TextractClient.swift +++ b/Sources/Services/AWSTextract/TextractClient.swift @@ -282,14 +282,7 @@ extension TextractClient: TextractClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAdapter") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -347,14 +340,7 @@ extension TextractClient: TextractClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAdapterVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSTimestreamQuery/TimestreamQueryClient.swift b/Sources/Services/AWSTimestreamQuery/TimestreamQueryClient.swift index f858b23c26a..6c327b3b7fe 100644 --- a/Sources/Services/AWSTimestreamQuery/TimestreamQueryClient.swift +++ b/Sources/Services/AWSTimestreamQuery/TimestreamQueryClient.swift @@ -149,14 +149,7 @@ extension TimestreamQueryClient: TimestreamQueryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createScheduledQuery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -363,14 +356,7 @@ extension TimestreamQueryClient: TimestreamQueryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "executeScheduledQuery") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -576,14 +562,7 @@ extension TimestreamQueryClient: TimestreamQueryClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "query") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSTimestreamWrite/TimestreamWriteClient.swift b/Sources/Services/AWSTimestreamWrite/TimestreamWriteClient.swift index 700632f71ac..14c1fdd88f4 100644 --- a/Sources/Services/AWSTimestreamWrite/TimestreamWriteClient.swift +++ b/Sources/Services/AWSTimestreamWrite/TimestreamWriteClient.swift @@ -101,14 +101,7 @@ extension TimestreamWriteClient: TimestreamWriteClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBatchLoadTask") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSTranslate/TranslateClient.swift b/Sources/Services/AWSTranslate/TranslateClient.swift index 20bc86c8d25..801a7b636fe 100644 --- a/Sources/Services/AWSTranslate/TranslateClient.swift +++ b/Sources/Services/AWSTranslate/TranslateClient.swift @@ -101,14 +101,7 @@ extension TranslateClient: TranslateClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createParallelData") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -685,14 +678,7 @@ extension TranslateClient: TranslateClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startTextTranslationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -992,14 +978,7 @@ extension TranslateClient: TranslateClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateParallelData") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSVPCLattice/VPCLatticeClient.swift b/Sources/Services/AWSVPCLattice/VPCLatticeClient.swift index e176a136103..a59ab91b6cc 100644 --- a/Sources/Services/AWSVPCLattice/VPCLatticeClient.swift +++ b/Sources/Services/AWSVPCLattice/VPCLatticeClient.swift @@ -148,14 +148,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAccessLogSubscription") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -206,14 +199,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createListener") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -264,14 +250,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -322,14 +301,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createService") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -380,14 +352,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceNetwork") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -438,14 +403,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceNetworkServiceAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -496,14 +454,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createServiceNetworkVpcAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -554,14 +505,7 @@ extension VPCLatticeClient: VPCLatticeClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTargetGroup") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSVerifiedPermissions/VerifiedPermissionsClient.swift b/Sources/Services/AWSVerifiedPermissions/VerifiedPermissionsClient.swift index febad0b6d2e..fd226902ad6 100644 --- a/Sources/Services/AWSVerifiedPermissions/VerifiedPermissionsClient.swift +++ b/Sources/Services/AWSVerifiedPermissions/VerifiedPermissionsClient.swift @@ -120,14 +120,7 @@ extension VerifiedPermissionsClient: VerifiedPermissionsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIdentitySource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -206,14 +199,7 @@ extension VerifiedPermissionsClient: VerifiedPermissionsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPolicy") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -284,14 +270,7 @@ extension VerifiedPermissionsClient: VerifiedPermissionsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPolicyStore") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -363,14 +342,7 @@ extension VerifiedPermissionsClient: VerifiedPermissionsClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPolicyTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSVoiceID/VoiceIDClient.swift b/Sources/Services/AWSVoiceID/VoiceIDClient.swift index 9d61cb3da6b..19541f49db8 100644 --- a/Sources/Services/AWSVoiceID/VoiceIDClient.swift +++ b/Sources/Services/AWSVoiceID/VoiceIDClient.swift @@ -151,14 +151,7 @@ extension VoiceIDClient: VoiceIDClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createDomain") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -210,14 +203,7 @@ extension VoiceIDClient: VoiceIDClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWatchlist") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1256,14 +1242,7 @@ extension VoiceIDClient: VoiceIDClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startFraudsterRegistrationJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1315,14 +1294,7 @@ extension VoiceIDClient: VoiceIDClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startSpeakerEnrollmentJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSWellArchitected/WellArchitectedClient.swift b/Sources/Services/AWSWellArchitected/WellArchitectedClient.swift index ae72aed9ef9..2adf42a953f 100644 --- a/Sources/Services/AWSWellArchitected/WellArchitectedClient.swift +++ b/Sources/Services/AWSWellArchitected/WellArchitectedClient.swift @@ -198,14 +198,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLensShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -256,14 +249,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createLensVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -314,14 +300,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMilestone") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -371,14 +350,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -429,14 +401,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createProfileShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -487,14 +452,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createReviewTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -545,14 +503,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTemplateShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -611,14 +562,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkload") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -669,14 +613,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createWorkloadShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -726,14 +663,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteLens") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -781,14 +711,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteLensShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -836,14 +759,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteProfile") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -891,14 +807,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteProfileShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -946,14 +855,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteReviewTemplate") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1001,14 +903,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteTemplateShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1056,14 +951,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteWorkload") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1111,14 +999,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteWorkloadShare") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1903,14 +1784,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "importLens") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3459,14 +3333,7 @@ extension WellArchitectedClient: WellArchitectedClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "upgradeProfileVersion") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientRequestToken == nil { - copiedInput.clientRequestToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientRequestToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSWisdom/WisdomClient.swift b/Sources/Services/AWSWisdom/WisdomClient.swift index 7afa28e2eb7..42a998c97d3 100644 --- a/Sources/Services/AWSWisdom/WisdomClient.swift +++ b/Sources/Services/AWSWisdom/WisdomClient.swift @@ -97,14 +97,7 @@ extension WisdomClient: WisdomClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAssistant") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -153,14 +146,7 @@ extension WisdomClient: WisdomClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAssistantAssociation") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -209,14 +195,7 @@ extension WisdomClient: WisdomClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createContent") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -272,14 +251,7 @@ extension WisdomClient: WisdomClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createKnowledgeBase") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -326,14 +298,7 @@ extension WisdomClient: WisdomClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createSession") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSWorkMail/WorkMailClient.swift b/Sources/Services/AWSWorkMail/WorkMailClient.swift index e5796db3295..68fe6ab6a95 100644 --- a/Sources/Services/AWSWorkMail/WorkMailClient.swift +++ b/Sources/Services/AWSWorkMail/WorkMailClient.swift @@ -247,14 +247,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "cancelMailboxExportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -357,14 +350,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createAvailabilityConfiguration") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -467,14 +453,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createImpersonationRole") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -523,14 +502,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createMobileDeviceAccessRule") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -580,14 +552,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createOrganization") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -1170,14 +1135,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "deleteOrganization") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3438,14 +3396,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "registerMailDomain") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -3603,14 +3554,7 @@ extension WorkMailClient: WorkMailClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "startMailboxExportJob") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/Sources/Services/AWSWorkSpacesWeb/WorkSpacesWebClient.swift b/Sources/Services/AWSWorkSpacesWeb/WorkSpacesWebClient.swift index 0614292e957..1a48d914aaa 100644 --- a/Sources/Services/AWSWorkSpacesWeb/WorkSpacesWebClient.swift +++ b/Sources/Services/AWSWorkSpacesWeb/WorkSpacesWebClient.swift @@ -381,14 +381,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createBrowserSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -439,14 +432,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIdentityProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -496,14 +482,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createIpAccessSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -553,14 +532,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createNetworkSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -611,14 +583,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createPortal") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -668,14 +633,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createTrustStore") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -725,14 +683,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUserAccessLoggingSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -782,14 +733,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "createUserSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2371,14 +2315,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "tagResource") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2473,14 +2410,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateBrowserSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2529,14 +2459,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateIdentityProvider") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2585,14 +2508,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateIpAccessSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2641,14 +2557,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateNetworkSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2747,14 +2656,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateTrustStore") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2803,14 +2705,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateUserAccessLoggingSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) @@ -2859,14 +2754,7 @@ extension WorkSpacesWebClient: WorkSpacesWebClientProtocol { .withSigningRegion(value: config.signingRegion) .build() var operation = ClientRuntime.OperationStack(id: "updateUserSettings") - operation.initializeStep.intercept(position: .after, id: "IdempotencyTokenMiddleware") { (context, input, next) -> ClientRuntime.OperationOutput in - let idempotencyTokenGenerator = context.getIdempotencyTokenGenerator() - var copiedInput = input - if input.clientToken == nil { - copiedInput.clientToken = idempotencyTokenGenerator.generateToken() - } - return try await next.handle(context: context, input: copiedInput) - } + operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.IdempotencyTokenMiddleware(keyPath: \.clientToken)) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware()) operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLHostMiddleware()) let endpointParams = EndpointParams(endpoint: config.endpoint, region: config.region, useDualStack: config.useDualStack ?? false, useFIPS: config.useFIPS ?? false) diff --git a/packageDependencies.plist b/packageDependencies.plist index 36aae43efee..9083c22629b 100644 --- a/packageDependencies.plist +++ b/packageDependencies.plist @@ -9,6 +9,6 @@ clientRuntimeBranch main clientRuntimeVersion - 0.33.0 + 0.34.0