Skip to content

Commit

Permalink
fix: default HTTPClient uses HttpClientConfiguration passed in from c…
Browse files Browse the repository at this point in the history
…lient config
  • Loading branch information
AndrewFossAWS committed May 1, 2024
1 parent 03b0bfa commit 2371eeb
Show file tree
Hide file tree
Showing 92 changed files with 247 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ public class DefaultAuthSchemeResolver: AuthSchemeResolver {
return DefaultAuthSchemeResolverParameters(operation: opName)
}
}

public typealias ClientConfigurationDefaults
= DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>
21 changes: 20 additions & 1 deletion Sources/WeatherSDK/WeatherClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extension WeatherClient {
}

public convenience init(telemetryProvider: ClientRuntime.TelemetryProvider? = nil, retryStrategyOptions: ClientRuntime.RetryStrategyOptions? = nil, clientLogMode: ClientRuntime.ClientLogMode? = nil, endpoint: Swift.String? = nil, idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator? = nil, httpClientEngine: ClientRuntime.HTTPClient? = nil, httpClientConfiguration: ClientRuntime.HttpClientConfiguration? = nil, authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ClientRuntime.AuthSchemeResolver? = nil) throws {
self.init(telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, retryStrategyOptions ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.defaultRetryStrategyOptions, clientLogMode ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.defaultClientLogMode, endpoint, idempotencyTokenGenerator ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.defaultIdempotencyTokenGenerator, httpClientEngine ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.makeClient(), httpClientConfiguration ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.defaultHttpClientConfiguration, authSchemes, authSchemeResolver ?? DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider>.defaultAuthSchemeResolver)
self.init(telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, retryStrategyOptions ?? ClientConfigurationDefaults.defaultRetryStrategyOptions, clientLogMode ?? ClientConfigurationDefaults.defaultClientLogMode, endpoint, idempotencyTokenGenerator ?? ClientConfigurationDefaults.defaultIdempotencyTokenGenerator, httpClientEngine ?? ClientConfigurationDefaults.makeClient(httpClientConfiguration: httpClientConfiguration ?? ClientConfigurationDefaults.defaultHttpClientConfiguration), httpClientConfiguration ?? ClientConfigurationDefaults.defaultHttpClientConfiguration, authSchemes, authSchemeResolver ?? ClientConfigurationDefaults.defaultAuthSchemeResolver)
}

public convenience required init() async throws {
Expand Down Expand Up @@ -120,6 +120,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<CreateCityInput, CreateCityOutput>(id: "createCity")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<CreateCityInput, CreateCityOutput>(CreateCityInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -160,6 +161,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<GetCityInput, GetCityOutput>(id: "getCity")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<GetCityInput, GetCityOutput>(GetCityInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -198,6 +200,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<GetCityAnnouncementsInput, GetCityAnnouncementsOutput>(id: "getCityAnnouncements")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<GetCityAnnouncementsInput, GetCityAnnouncementsOutput>(GetCityAnnouncementsInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -235,6 +238,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<GetCityImageInput, GetCityImageOutput>(id: "getCityImage")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<GetCityImageInput, GetCityImageOutput>(GetCityImageInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -267,6 +271,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<GetCurrentTimeInput, GetCurrentTimeOutput>(id: "getCurrentTime")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<GetCurrentTimeInput, GetCurrentTimeOutput>(GetCurrentTimeInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -299,6 +304,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<GetForecastInput, GetForecastOutput>(id: "getForecast")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<GetForecastInput, GetForecastOutput>(GetForecastInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -331,6 +337,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<InvokeInput, InvokeOutput>(id: "invoke")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<InvokeInput, InvokeOutput>(InvokeInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -371,6 +378,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<ListCitiesInput, ListCitiesOutput>(id: "listCities")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<ListCitiesInput, ListCitiesOutput>(ListCitiesInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -404,6 +412,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyFakeAuthInput, OnlyFakeAuthOutput>(id: "onlyFakeAuth")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyFakeAuthInput, OnlyFakeAuthOutput>(OnlyFakeAuthInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -436,6 +445,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyFakeAuthOptionalInput, OnlyFakeAuthOptionalOutput>(id: "onlyFakeAuthOptional")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyFakeAuthOptionalInput, OnlyFakeAuthOptionalOutput>(OnlyFakeAuthOptionalInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -468,6 +478,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpApiKeyAndBearerAuthInput, OnlyHttpApiKeyAndBearerAuthOutput>(id: "onlyHttpApiKeyAndBearerAuth")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpApiKeyAndBearerAuthInput, OnlyHttpApiKeyAndBearerAuthOutput>(OnlyHttpApiKeyAndBearerAuthInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -500,6 +511,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpApiKeyAndBearerAuthReversedInput, OnlyHttpApiKeyAndBearerAuthReversedOutput>(id: "onlyHttpApiKeyAndBearerAuthReversed")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpApiKeyAndBearerAuthReversedInput, OnlyHttpApiKeyAndBearerAuthReversedOutput>(OnlyHttpApiKeyAndBearerAuthReversedInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -532,6 +544,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpApiKeyAuthInput, OnlyHttpApiKeyAuthOutput>(id: "onlyHttpApiKeyAuth")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpApiKeyAuthInput, OnlyHttpApiKeyAuthOutput>(OnlyHttpApiKeyAuthInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -564,6 +577,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpApiKeyAuthOptionalInput, OnlyHttpApiKeyAuthOptionalOutput>(id: "onlyHttpApiKeyAuthOptional")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpApiKeyAuthOptionalInput, OnlyHttpApiKeyAuthOptionalOutput>(OnlyHttpApiKeyAuthOptionalInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -596,6 +610,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpBearerAuthInput, OnlyHttpBearerAuthOutput>(id: "onlyHttpBearerAuth")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpBearerAuthInput, OnlyHttpBearerAuthOutput>(OnlyHttpBearerAuthInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -628,6 +643,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlyHttpBearerAuthOptionalInput, OnlyHttpBearerAuthOptionalOutput>(id: "onlyHttpBearerAuthOptional")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlyHttpBearerAuthOptionalInput, OnlyHttpBearerAuthOptionalOutput>(OnlyHttpBearerAuthOptionalInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -660,6 +676,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlySigv4AuthInput, OnlySigv4AuthOutput>(id: "onlySigv4Auth")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlySigv4AuthInput, OnlySigv4AuthOutput>(OnlySigv4AuthInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -692,6 +709,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<OnlySigv4AuthOptionalInput, OnlySigv4AuthOptionalOutput>(id: "onlySigv4AuthOptional")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<OnlySigv4AuthOptionalInput, OnlySigv4AuthOptionalOutput>(OnlySigv4AuthOptionalInput.urlPathProvider(_:)))
Expand Down Expand Up @@ -724,6 +742,7 @@ extension WeatherClient {
.withAuthSchemes(value: config.authSchemes ?? [])
.withAuthSchemeResolver(value: config.authSchemeResolver)
.withUnsignedPayloadTrait(value: false)
.withSocketTimeout(value: config.httpClientConfiguration.socketTimeout)
.build()
var operation = ClientRuntime.OperationStack<SameAsServiceInput, SameAsServiceOutput>(id: "sameAsService")
operation.initializeStep.intercept(position: .after, middleware: ClientRuntime.URLPathMiddleware<SameAsServiceInput, SameAsServiceOutput>(SameAsServiceInput.urlPathProvider(_:)))
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/Baz.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ClientRuntime

extension WeatherClientTypes {
public struct Baz: Swift.Equatable {
public struct Baz {
public var bar: Swift.String?
public var baz: Swift.String?

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/CityCoordinates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ClientRuntime

extension WeatherClientTypes {
public struct CityCoordinates: Swift.Equatable {
public struct CityCoordinates {
/// This member is required.
public var latitude: Swift.Float?
/// This member is required.
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/CitySummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ClientRuntime

extension WeatherClientTypes {
public struct CitySummary: Swift.Equatable {
public struct CitySummary {
public var `case`: Swift.String?
/// This member is required.
public var cityId: Swift.String?
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/CreateCityInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct CreateCityInput: Swift.Equatable {
public struct CreateCityInput {
public var city: WeatherClientTypes.CitySummary?
/// This member is required.
public var coordinates: WeatherClientTypes.CityCoordinates?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct CreateCityInputBody: Swift.Equatable {
struct CreateCityInputBody {
let name: Swift.String?
let coordinates: WeatherClientTypes.CityCoordinates?
let city: WeatherClientTypes.CitySummary?
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/CreateCityOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct CreateCityOutput: Swift.Equatable {
public struct CreateCityOutput {
/// This member is required.
public var cityId: Swift.String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct CreateCityOutputBody: Swift.Equatable {
struct CreateCityOutputBody {
let cityId: Swift.String?
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/Foo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ClientRuntime

extension WeatherClientTypes {
public struct Foo: Swift.Equatable {
public struct Foo {
public var bar: Swift.String?
public var baz: Swift.String?

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityAnnouncementsInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct GetCityAnnouncementsInput: Swift.Equatable {
public struct GetCityAnnouncementsInput {
/// This member is required.
public var cityId: Swift.String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct GetCityAnnouncementsInputBody: Swift.Equatable {
struct GetCityAnnouncementsInputBody {
}

extension GetCityAnnouncementsInputBody: Swift.Decodable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityAnnouncementsOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct GetCityAnnouncementsOutput: Swift.Equatable {
public struct GetCityAnnouncementsOutput {
public var lastUpdated: ClientRuntime.Date?

public init(
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityImageInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct GetCityImageInput: Swift.Equatable {
public struct GetCityImageInput {
/// This member is required.
public var cityId: Swift.String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct GetCityImageInputBody: Swift.Equatable {
struct GetCityImageInputBody {
}

extension GetCityImageInputBody: Swift.Decodable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityImageOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct GetCityImageOutput: Swift.Equatable {
public struct GetCityImageOutput {
/// This member is required.
public var image: ClientRuntime.ByteStream?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct GetCityImageOutputBody: Swift.Equatable {
struct GetCityImageOutputBody {
let image: ClientRuntime.ByteStream?
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ClientRuntime

/// The input used to get a city.
public struct GetCityInput: Swift.Equatable {
public struct GetCityInput {
/// This member is required.
public var cityId: Swift.String?

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityInputBody+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct GetCityInputBody: Swift.Equatable {
struct GetCityInputBody {
}

extension GetCityInputBody: Swift.Decodable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeatherSDK/models/GetCityOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

public struct GetCityOutput: Swift.Equatable {
public struct GetCityOutput {
public var city: WeatherClientTypes.CitySummary?
/// This member is required.
public var coordinates: WeatherClientTypes.CityCoordinates?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ClientRuntime

struct GetCityOutputBody: Swift.Equatable {
struct GetCityOutputBody {
let name: Swift.String?
let coordinates: WeatherClientTypes.CityCoordinates?
let city: WeatherClientTypes.CitySummary?
Expand Down
Loading

0 comments on commit 2371eeb

Please sign in to comment.