options.go (8996B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package signin 4 5 import ( 6 "context" 7 "net/http" 8 9 "github.com/aws/aws-sdk-go-v2/aws" 10 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 11 internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy" 12 smithyauth "github.com/aws/smithy-go/auth" 13 "github.com/aws/smithy-go/logging" 14 "github.com/aws/smithy-go/metrics" 15 "github.com/aws/smithy-go/middleware" 16 "github.com/aws/smithy-go/tracing" 17 smithyhttp "github.com/aws/smithy-go/transport/http" 18 ) 19 20 type HTTPClient interface { 21 Do(*http.Request) (*http.Response, error) 22 } 23 24 type Options struct { 25 // Set of options to modify how an operation is invoked. These apply to all 26 // operations invoked for this client. Use functional options on operation call to 27 // modify this list for per operation behavior. 28 APIOptions []func(*middleware.Stack) error 29 30 // The optional application specific identifier appended to the User-Agent header. 31 AppID string 32 33 // This endpoint will be given as input to an EndpointResolverV2. It is used for 34 // providing a custom base endpoint that is subject to modifications by the 35 // processing EndpointResolverV2. 36 BaseEndpoint *string 37 38 // Configures the events that will be sent to the configured logger. 39 ClientLogMode aws.ClientLogMode 40 41 // The credentials object to use when signing requests. 42 Credentials aws.CredentialsProvider 43 44 // The configuration DefaultsMode that the SDK should use when constructing the 45 // clients initial default settings. 46 DefaultsMode aws.DefaultsMode 47 48 // Disables SDK clock skew correction. When set, the SDK will not adjust request 49 // signing timestamps to compensate for clock drift between the client and the 50 // service. 51 DisableClockSkewCorrection bool 52 53 // The endpoint options to be used when attempting to resolve an endpoint. 54 EndpointOptions EndpointResolverOptions 55 56 // The service endpoint resolver. 57 // 58 // Deprecated: Deprecated: EndpointResolver and WithEndpointResolver. Providing a 59 // value for this field will likely prevent you from using any endpoint-related 60 // service features released after the introduction of EndpointResolverV2 and 61 // BaseEndpoint. 62 // 63 // To migrate an EndpointResolver implementation that uses a custom endpoint, set 64 // the client option BaseEndpoint instead. 65 EndpointResolver EndpointResolver 66 67 // Resolves the endpoint used for a particular service operation. 68 EndpointResolverV2 EndpointResolverV2 69 70 // Signature Version 4 (SigV4) Signer 71 HTTPSignerV4 HTTPSignerV4 72 73 // Provides idempotency tokens values that will be automatically populated into 74 // idempotent API operations. 75 IdempotencyTokenProvider IdempotencyTokenProvider 76 77 // The logger writer interface to write logging messages to. 78 Logger logging.Logger 79 80 // The client meter provider. 81 MeterProvider metrics.MeterProvider 82 83 // The region to send requests to. (Required) 84 Region string 85 86 // RetryMaxAttempts specifies the maximum number attempts an API client will call 87 // an operation that fails with a retryable error. A value of 0 is ignored, and 88 // will not be used to configure the API client created default retryer, or modify 89 // per operation call's retry max attempts. 90 // 91 // If specified in an operation call's functional options with a value that is 92 // different than the constructed client's Options, the Client's Retryer will be 93 // wrapped to use the operation's specific RetryMaxAttempts value. 94 RetryMaxAttempts int 95 96 // RetryMode specifies the retry mode the API client will be created with, if 97 // Retryer option is not also specified. 98 // 99 // When creating a new API Clients this member will only be used if the Retryer 100 // Options member is nil. This value will be ignored if Retryer is not nil. 101 // 102 // Currently does not support per operation call overrides, may in the future. 103 RetryMode aws.RetryMode 104 105 // Retryer guides how HTTP requests should be retried in case of recoverable 106 // failures. When nil the API client will use a default retryer. The kind of 107 // default retry created by the API client can be changed with the RetryMode 108 // option. 109 Retryer aws.Retryer 110 111 // The RuntimeEnvironment configuration, only populated if the DefaultsMode is set 112 // to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You 113 // should not populate this structure programmatically, or rely on the values here 114 // within your applications. 115 RuntimeEnvironment aws.RuntimeEnvironment 116 117 // The client tracer provider. 118 TracerProvider tracing.TracerProvider 119 120 // The initial DefaultsMode used when the client options were constructed. If the 121 // DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved 122 // value was at that point in time. 123 // 124 // Currently does not support per operation call overrides, may in the future. 125 resolvedDefaultsMode aws.DefaultsMode 126 127 // The HTTP client to invoke API calls with. Defaults to client's default HTTP 128 // implementation if nil. 129 HTTPClient HTTPClient 130 131 // Client registry of operation interceptors. 132 Interceptors smithyhttp.InterceptorRegistry 133 134 // The auth scheme resolver which determines how to authenticate for each 135 // operation. 136 AuthSchemeResolver AuthSchemeResolver 137 138 // The list of auth schemes supported by the client. 139 AuthSchemes []smithyhttp.AuthScheme 140 141 // Priority list of preferred auth scheme names (e.g. sigv4a). 142 AuthSchemePreference []string 143 } 144 145 // Copy creates a clone where the APIOptions list is deep copied. 146 func (o Options) Copy() Options { 147 to := o 148 to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions)) 149 copy(to.APIOptions, o.APIOptions) 150 to.Interceptors = o.Interceptors.Copy() 151 152 return to 153 } 154 155 func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver { 156 if schemeID == "aws.auth#sigv4" { 157 return getSigV4IdentityResolver(o) 158 } 159 if schemeID == "smithy.api#noAuth" { 160 return &smithyauth.AnonymousIdentityResolver{} 161 } 162 return nil 163 } 164 165 // WithAPIOptions returns a functional option for setting the Client's APIOptions 166 // option. 167 func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) { 168 return func(o *Options) { 169 o.APIOptions = append(o.APIOptions, optFns...) 170 } 171 } 172 173 // Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for 174 // this field will likely prevent you from using any endpoint-related service 175 // features released after the introduction of EndpointResolverV2 and BaseEndpoint. 176 // 177 // To migrate an EndpointResolver implementation that uses a custom endpoint, set 178 // the client option BaseEndpoint instead. 179 func WithEndpointResolver(v EndpointResolver) func(*Options) { 180 return func(o *Options) { 181 o.EndpointResolver = v 182 } 183 } 184 185 // WithEndpointResolverV2 returns a functional option for setting the Client's 186 // EndpointResolverV2 option. 187 func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) { 188 return func(o *Options) { 189 o.EndpointResolverV2 = v 190 } 191 } 192 193 func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver { 194 if o.Credentials != nil { 195 return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials} 196 } 197 return nil 198 } 199 200 // WithSigV4SigningName applies an override to the authentication workflow to 201 // use the given signing name for SigV4-authenticated operations. 202 // 203 // This is an advanced setting. The value here is FINAL, taking precedence over 204 // the resolved signing name from both auth scheme resolution and endpoint 205 // resolution. 206 func WithSigV4SigningName(name string) func(*Options) { 207 fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 208 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 209 ) { 210 return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in) 211 } 212 return func(o *Options) { 213 o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { 214 return s.Initialize.Add( 215 middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn), 216 middleware.Before, 217 ) 218 }) 219 } 220 } 221 222 // WithSigV4SigningRegion applies an override to the authentication workflow to 223 // use the given signing region for SigV4-authenticated operations. 224 // 225 // This is an advanced setting. The value here is FINAL, taking precedence over 226 // the resolved signing region from both auth scheme resolution and endpoint 227 // resolution. 228 func WithSigV4SigningRegion(region string) func(*Options) { 229 fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 230 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 231 ) { 232 return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in) 233 } 234 return func(o *Options) { 235 o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { 236 return s.Initialize.Add( 237 middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn), 238 middleware.Before, 239 ) 240 }) 241 } 242 } 243 244 func ignoreAnonymousAuth(options *Options) { 245 if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) { 246 options.Credentials = nil 247 } 248 }