options.go (8833B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package route53 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 // The logger writer interface to write logging messages to. 74 Logger logging.Logger 75 76 // The client meter provider. 77 MeterProvider metrics.MeterProvider 78 79 // The region to send requests to. (Required) 80 Region string 81 82 // RetryMaxAttempts specifies the maximum number attempts an API client will call 83 // an operation that fails with a retryable error. A value of 0 is ignored, and 84 // will not be used to configure the API client created default retryer, or modify 85 // per operation call's retry max attempts. 86 // 87 // If specified in an operation call's functional options with a value that is 88 // different than the constructed client's Options, the Client's Retryer will be 89 // wrapped to use the operation's specific RetryMaxAttempts value. 90 RetryMaxAttempts int 91 92 // RetryMode specifies the retry mode the API client will be created with, if 93 // Retryer option is not also specified. 94 // 95 // When creating a new API Clients this member will only be used if the Retryer 96 // Options member is nil. This value will be ignored if Retryer is not nil. 97 // 98 // Currently does not support per operation call overrides, may in the future. 99 RetryMode aws.RetryMode 100 101 // Retryer guides how HTTP requests should be retried in case of recoverable 102 // failures. When nil the API client will use a default retryer. The kind of 103 // default retry created by the API client can be changed with the RetryMode 104 // option. 105 Retryer aws.Retryer 106 107 // The RuntimeEnvironment configuration, only populated if the DefaultsMode is set 108 // to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You 109 // should not populate this structure programmatically, or rely on the values here 110 // within your applications. 111 RuntimeEnvironment aws.RuntimeEnvironment 112 113 // The client tracer provider. 114 TracerProvider tracing.TracerProvider 115 116 // The initial DefaultsMode used when the client options were constructed. If the 117 // DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved 118 // value was at that point in time. 119 // 120 // Currently does not support per operation call overrides, may in the future. 121 resolvedDefaultsMode aws.DefaultsMode 122 123 // The HTTP client to invoke API calls with. Defaults to client's default HTTP 124 // implementation if nil. 125 HTTPClient HTTPClient 126 127 // Client registry of operation interceptors. 128 Interceptors smithyhttp.InterceptorRegistry 129 130 // The auth scheme resolver which determines how to authenticate for each 131 // operation. 132 AuthSchemeResolver AuthSchemeResolver 133 134 // The list of auth schemes supported by the client. 135 AuthSchemes []smithyhttp.AuthScheme 136 137 // Priority list of preferred auth scheme names (e.g. sigv4a). 138 AuthSchemePreference []string 139 } 140 141 // Copy creates a clone where the APIOptions list is deep copied. 142 func (o Options) Copy() Options { 143 to := o 144 to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions)) 145 copy(to.APIOptions, o.APIOptions) 146 to.Interceptors = o.Interceptors.Copy() 147 148 return to 149 } 150 151 func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver { 152 if schemeID == "aws.auth#sigv4" { 153 return getSigV4IdentityResolver(o) 154 } 155 if schemeID == "smithy.api#noAuth" { 156 return &smithyauth.AnonymousIdentityResolver{} 157 } 158 return nil 159 } 160 161 // WithAPIOptions returns a functional option for setting the Client's APIOptions 162 // option. 163 func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) { 164 return func(o *Options) { 165 o.APIOptions = append(o.APIOptions, optFns...) 166 } 167 } 168 169 // Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for 170 // this field will likely prevent you from using any endpoint-related service 171 // features released after the introduction of EndpointResolverV2 and BaseEndpoint. 172 // 173 // To migrate an EndpointResolver implementation that uses a custom endpoint, set 174 // the client option BaseEndpoint instead. 175 func WithEndpointResolver(v EndpointResolver) func(*Options) { 176 return func(o *Options) { 177 o.EndpointResolver = v 178 } 179 } 180 181 // WithEndpointResolverV2 returns a functional option for setting the Client's 182 // EndpointResolverV2 option. 183 func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) { 184 return func(o *Options) { 185 o.EndpointResolverV2 = v 186 } 187 } 188 189 func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver { 190 if o.Credentials != nil { 191 return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials} 192 } 193 return nil 194 } 195 196 // WithSigV4SigningName applies an override to the authentication workflow to 197 // use the given signing name for SigV4-authenticated operations. 198 // 199 // This is an advanced setting. The value here is FINAL, taking precedence over 200 // the resolved signing name from both auth scheme resolution and endpoint 201 // resolution. 202 func WithSigV4SigningName(name string) func(*Options) { 203 fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 204 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 205 ) { 206 return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in) 207 } 208 return func(o *Options) { 209 o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { 210 return s.Initialize.Add( 211 middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn), 212 middleware.Before, 213 ) 214 }) 215 } 216 } 217 218 // WithSigV4SigningRegion applies an override to the authentication workflow to 219 // use the given signing region for SigV4-authenticated operations. 220 // 221 // This is an advanced setting. The value here is FINAL, taking precedence over 222 // the resolved signing region from both auth scheme resolution and endpoint 223 // resolution. 224 func WithSigV4SigningRegion(region string) func(*Options) { 225 fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 226 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 227 ) { 228 return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in) 229 } 230 return func(o *Options) { 231 o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error { 232 return s.Initialize.Add( 233 middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn), 234 middleware.Before, 235 ) 236 }) 237 } 238 } 239 240 func ignoreAnonymousAuth(options *Options) { 241 if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) { 242 options.Credentials = nil 243 } 244 }