src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

endpoints.go (26593B)


      1 // Code generated by smithy-go-codegen DO NOT EDIT.
      2 
      3 package route53
      4 
      5 import (
      6 	"context"
      7 	"errors"
      8 	"fmt"
      9 	"github.com/aws/aws-sdk-go-v2/aws"
     10 	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
     11 	internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources"
     12 	"github.com/aws/aws-sdk-go-v2/internal/endpoints"
     13 	"github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn"
     14 	internalendpoints "github.com/aws/aws-sdk-go-v2/service/route53/internal/endpoints"
     15 	smithy "github.com/aws/smithy-go"
     16 	smithyauth "github.com/aws/smithy-go/auth"
     17 	smithyendpoints "github.com/aws/smithy-go/endpoints"
     18 	"github.com/aws/smithy-go/middleware"
     19 	"github.com/aws/smithy-go/ptr"
     20 	"github.com/aws/smithy-go/tracing"
     21 	smithyhttp "github.com/aws/smithy-go/transport/http"
     22 	"net/http"
     23 	"net/url"
     24 	"os"
     25 	"strings"
     26 )
     27 
     28 // EndpointResolverOptions is the service endpoint resolver options
     29 type EndpointResolverOptions = internalendpoints.Options
     30 
     31 // EndpointResolver interface for resolving service endpoints.
     32 type EndpointResolver interface {
     33 	ResolveEndpoint(region string, options EndpointResolverOptions) (aws.Endpoint, error)
     34 }
     35 
     36 var _ EndpointResolver = &internalendpoints.Resolver{}
     37 
     38 // NewDefaultEndpointResolver constructs a new service endpoint resolver
     39 func NewDefaultEndpointResolver() *internalendpoints.Resolver {
     40 	return internalendpoints.New()
     41 }
     42 
     43 // EndpointResolverFunc is a helper utility that wraps a function so it satisfies
     44 // the EndpointResolver interface. This is useful when you want to add additional
     45 // endpoint resolving logic, or stub out specific endpoints with custom values.
     46 type EndpointResolverFunc func(region string, options EndpointResolverOptions) (aws.Endpoint, error)
     47 
     48 func (fn EndpointResolverFunc) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) {
     49 	return fn(region, options)
     50 }
     51 
     52 // EndpointResolverFromURL returns an EndpointResolver configured using the
     53 // provided endpoint url. By default, the resolved endpoint resolver uses the
     54 // client region as signing region, and the endpoint source is set to
     55 // EndpointSourceCustom.You can provide functional options to configure endpoint
     56 // values for the resolved endpoint.
     57 func EndpointResolverFromURL(url string, optFns ...func(*aws.Endpoint)) EndpointResolver {
     58 	e := aws.Endpoint{URL: url, Source: aws.EndpointSourceCustom}
     59 	for _, fn := range optFns {
     60 		fn(&e)
     61 	}
     62 
     63 	return EndpointResolverFunc(
     64 		func(region string, options EndpointResolverOptions) (aws.Endpoint, error) {
     65 			if len(e.SigningRegion) == 0 {
     66 				e.SigningRegion = region
     67 			}
     68 			return e, nil
     69 		},
     70 	)
     71 }
     72 
     73 type ResolveEndpoint struct {
     74 	Resolver EndpointResolver
     75 	Options  EndpointResolverOptions
     76 }
     77 
     78 func (*ResolveEndpoint) ID() string {
     79 	return "ResolveEndpoint"
     80 }
     81 
     82 func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
     83 	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
     84 ) {
     85 	if !awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
     86 		return next.HandleSerialize(ctx, in)
     87 	}
     88 
     89 	req, ok := in.Request.(*smithyhttp.Request)
     90 	if !ok {
     91 		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
     92 	}
     93 
     94 	if m.Resolver == nil {
     95 		return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil")
     96 	}
     97 
     98 	eo := m.Options
     99 	eo.Logger = middleware.GetLogger(ctx)
    100 
    101 	var endpoint aws.Endpoint
    102 	endpoint, err = m.Resolver.ResolveEndpoint(awsmiddleware.GetRegion(ctx), eo)
    103 	if err != nil {
    104 		nf := (&aws.EndpointNotFoundError{})
    105 		if errors.As(err, &nf) {
    106 			ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, false)
    107 			return next.HandleSerialize(ctx, in)
    108 		}
    109 		return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
    110 	}
    111 
    112 	req.URL, err = url.Parse(endpoint.URL)
    113 	if err != nil {
    114 		return out, metadata, fmt.Errorf("failed to parse endpoint URL: %w", err)
    115 	}
    116 
    117 	if len(awsmiddleware.GetSigningName(ctx)) == 0 {
    118 		signingName := endpoint.SigningName
    119 		if len(signingName) == 0 {
    120 			signingName = "route53"
    121 		}
    122 		ctx = awsmiddleware.SetSigningName(ctx, signingName)
    123 	}
    124 	ctx = awsmiddleware.SetEndpointSource(ctx, endpoint.Source)
    125 	ctx = smithyhttp.SetHostnameImmutable(ctx, endpoint.HostnameImmutable)
    126 	ctx = awsmiddleware.SetSigningRegion(ctx, endpoint.SigningRegion)
    127 	ctx = awsmiddleware.SetPartitionID(ctx, endpoint.PartitionID)
    128 	return next.HandleSerialize(ctx, in)
    129 }
    130 func addResolveEndpointMiddleware(stack *middleware.Stack, o Options) error {
    131 	return stack.Serialize.Insert(&ResolveEndpoint{
    132 		Resolver: o.EndpointResolver,
    133 		Options:  o.EndpointOptions,
    134 	}, "OperationSerializer", middleware.Before)
    135 }
    136 
    137 func removeResolveEndpointMiddleware(stack *middleware.Stack) error {
    138 	_, err := stack.Serialize.Remove((&ResolveEndpoint{}).ID())
    139 	return err
    140 }
    141 
    142 type wrappedEndpointResolver struct {
    143 	awsResolver aws.EndpointResolverWithOptions
    144 }
    145 
    146 func (w *wrappedEndpointResolver) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) {
    147 	return w.awsResolver.ResolveEndpoint(ServiceID, region, options)
    148 }
    149 
    150 type awsEndpointResolverAdaptor func(service, region string) (aws.Endpoint, error)
    151 
    152 func (a awsEndpointResolverAdaptor) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) {
    153 	return a(service, region)
    154 }
    155 
    156 var _ aws.EndpointResolverWithOptions = awsEndpointResolverAdaptor(nil)
    157 
    158 // withEndpointResolver returns an aws.EndpointResolverWithOptions that first delegates endpoint resolution to the awsResolver.
    159 // If awsResolver returns aws.EndpointNotFoundError error, the v1 resolver middleware will swallow the error,
    160 // and set an appropriate context flag such that fallback will occur when EndpointResolverV2 is invoked
    161 // via its middleware.
    162 //
    163 // If another error (besides aws.EndpointNotFoundError) is returned, then that error will be propagated.
    164 func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptions aws.EndpointResolverWithOptions) EndpointResolver {
    165 	var resolver aws.EndpointResolverWithOptions
    166 
    167 	if awsResolverWithOptions != nil {
    168 		resolver = awsResolverWithOptions
    169 	} else if awsResolver != nil {
    170 		resolver = awsEndpointResolverAdaptor(awsResolver.ResolveEndpoint)
    171 	}
    172 
    173 	return &wrappedEndpointResolver{
    174 		awsResolver: resolver,
    175 	}
    176 }
    177 
    178 func finalizeClientEndpointResolverOptions(options *Options) {
    179 	options.EndpointOptions.LogDeprecated = options.ClientLogMode.IsDeprecatedUsage()
    180 
    181 	if len(options.EndpointOptions.ResolvedRegion) == 0 {
    182 		const fipsInfix = "-fips-"
    183 		const fipsPrefix = "fips-"
    184 		const fipsSuffix = "-fips"
    185 
    186 		if strings.Contains(options.Region, fipsInfix) ||
    187 			strings.Contains(options.Region, fipsPrefix) ||
    188 			strings.Contains(options.Region, fipsSuffix) {
    189 			options.EndpointOptions.ResolvedRegion = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(
    190 				options.Region, fipsInfix, "-"), fipsPrefix, ""), fipsSuffix, "")
    191 			options.EndpointOptions.UseFIPSEndpoint = aws.FIPSEndpointStateEnabled
    192 		}
    193 	}
    194 
    195 }
    196 
    197 func resolveEndpointResolverV2(options *Options) {
    198 	if options.EndpointResolverV2 == nil {
    199 		options.EndpointResolverV2 = NewDefaultEndpointResolverV2()
    200 	}
    201 }
    202 
    203 func resolveBaseEndpoint(cfg aws.Config, o *Options) {
    204 	if cfg.BaseEndpoint != nil {
    205 		o.BaseEndpoint = cfg.BaseEndpoint
    206 	}
    207 
    208 	_, g := os.LookupEnv("AWS_ENDPOINT_URL")
    209 	_, s := os.LookupEnv("AWS_ENDPOINT_URL_ROUTE_53")
    210 
    211 	if g && !s {
    212 		return
    213 	}
    214 
    215 	value, found, err := internalConfig.ResolveServiceBaseEndpoint(context.Background(), "Route 53", cfg.ConfigSources)
    216 	if found && err == nil {
    217 		o.BaseEndpoint = &value
    218 	}
    219 }
    220 
    221 func bindRegion(region string) *string {
    222 	if region == "" {
    223 		return nil
    224 	}
    225 	return aws.String(endpoints.MapFIPSRegion(region))
    226 }
    227 
    228 // EndpointParameters provides the parameters that influence how endpoints are
    229 // resolved.
    230 type EndpointParameters struct {
    231 	// The AWS region used to dispatch the request.
    232 	//
    233 	// Parameter is
    234 	// required.
    235 	//
    236 	// AWS::Region
    237 	Region *string
    238 
    239 	// When true, use the dual-stack endpoint. If the configured endpoint does not
    240 	// support dual-stack, dispatching the request MAY return an error.
    241 	//
    242 	// Defaults to
    243 	// false if no value is provided.
    244 	//
    245 	// AWS::UseDualStack
    246 	UseDualStack *bool
    247 
    248 	// When true, send this request to the FIPS-compliant regional endpoint. If the
    249 	// configured endpoint does not have a FIPS compliant endpoint, dispatching the
    250 	// request will return an error.
    251 	//
    252 	// Defaults to false if no value is
    253 	// provided.
    254 	//
    255 	// AWS::UseFIPS
    256 	UseFIPS *bool
    257 
    258 	// Override the endpoint used to send this request
    259 	//
    260 	// Parameter is
    261 	// required.
    262 	//
    263 	// SDK::Endpoint
    264 	Endpoint *string
    265 }
    266 
    267 // ValidateRequired validates required parameters are set.
    268 func (p EndpointParameters) ValidateRequired() error {
    269 	if p.UseDualStack == nil {
    270 		return fmt.Errorf("parameter UseDualStack is required")
    271 	}
    272 
    273 	if p.UseFIPS == nil {
    274 		return fmt.Errorf("parameter UseFIPS is required")
    275 	}
    276 
    277 	return nil
    278 }
    279 
    280 // WithDefaults returns a shallow copy of EndpointParameterswith default values
    281 // applied to members where applicable.
    282 func (p EndpointParameters) WithDefaults() EndpointParameters {
    283 	if p.UseDualStack == nil {
    284 		p.UseDualStack = ptr.Bool(false)
    285 	}
    286 
    287 	if p.UseFIPS == nil {
    288 		p.UseFIPS = ptr.Bool(false)
    289 	}
    290 	return p
    291 }
    292 
    293 type stringSlice []string
    294 
    295 func (s stringSlice) Get(i int) *string {
    296 	if i < 0 || i >= len(s) {
    297 		return nil
    298 	}
    299 
    300 	v := s[i]
    301 	return &v
    302 }
    303 
    304 // EndpointResolverV2 provides the interface for resolving service endpoints.
    305 type EndpointResolverV2 interface {
    306 	// ResolveEndpoint attempts to resolve the endpoint with the provided options,
    307 	// returning the endpoint if found. Otherwise an error is returned.
    308 	ResolveEndpoint(ctx context.Context, params EndpointParameters) (
    309 		smithyendpoints.Endpoint, error,
    310 	)
    311 }
    312 
    313 // resolver provides the implementation for resolving endpoints.
    314 type resolver struct{}
    315 
    316 func NewDefaultEndpointResolverV2() EndpointResolverV2 {
    317 	return &resolver{}
    318 }
    319 
    320 // ResolveEndpoint attempts to resolve the endpoint with the provided options,
    321 // returning the endpoint if found. Otherwise an error is returned.
    322 func (r *resolver) ResolveEndpoint(
    323 	ctx context.Context, params EndpointParameters,
    324 ) (
    325 	endpoint smithyendpoints.Endpoint, err error,
    326 ) {
    327 	params = params.WithDefaults()
    328 	if err = params.ValidateRequired(); err != nil {
    329 		return endpoint, fmt.Errorf("endpoint parameters are not valid, %w", err)
    330 	}
    331 	_UseDualStack := *params.UseDualStack
    332 	_ = _UseDualStack
    333 	_UseFIPS := *params.UseFIPS
    334 	_ = _UseFIPS
    335 
    336 	if exprVal := params.Endpoint; exprVal != nil {
    337 		_Endpoint := *exprVal
    338 		_ = _Endpoint
    339 		if _UseFIPS == true {
    340 			return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: FIPS and custom endpoint are not supported")
    341 		}
    342 		if _UseDualStack == true {
    343 			return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Dualstack and custom endpoint are not supported")
    344 		}
    345 		uriString := _Endpoint
    346 
    347 		uri, err := url.Parse(uriString)
    348 		if err != nil {
    349 			return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    350 		}
    351 
    352 		return smithyendpoints.Endpoint{
    353 			URI:     *uri,
    354 			Headers: http.Header{},
    355 		}, nil
    356 	}
    357 	if exprVal := params.Region; exprVal != nil {
    358 		_Region := *exprVal
    359 		_ = _Region
    360 		if exprVal := awsrulesfn.GetPartition(_Region); exprVal != nil {
    361 			_PartitionResult := *exprVal
    362 			_ = _PartitionResult
    363 			if _PartitionResult.Name == "aws" {
    364 				if _UseFIPS == false {
    365 					if _UseDualStack == false {
    366 						uriString := "https://route53.amazonaws.com"
    367 
    368 						uri, err := url.Parse(uriString)
    369 						if err != nil {
    370 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    371 						}
    372 
    373 						return smithyendpoints.Endpoint{
    374 							URI:     *uri,
    375 							Headers: http.Header{},
    376 							Properties: func() smithy.Properties {
    377 								var out smithy.Properties
    378 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    379 									{
    380 										SchemeID: "aws.auth#sigv4",
    381 										SignerProperties: func() smithy.Properties {
    382 											var sp smithy.Properties
    383 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    384 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    385 
    386 											smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1")
    387 											return sp
    388 										}(),
    389 									},
    390 								})
    391 								return out
    392 							}(),
    393 						}, nil
    394 					}
    395 				}
    396 			}
    397 			if _PartitionResult.Name == "aws" {
    398 				if _UseFIPS == true {
    399 					if _UseDualStack == false {
    400 						uriString := "https://route53-fips.amazonaws.com"
    401 
    402 						uri, err := url.Parse(uriString)
    403 						if err != nil {
    404 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    405 						}
    406 
    407 						return smithyendpoints.Endpoint{
    408 							URI:     *uri,
    409 							Headers: http.Header{},
    410 							Properties: func() smithy.Properties {
    411 								var out smithy.Properties
    412 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    413 									{
    414 										SchemeID: "aws.auth#sigv4",
    415 										SignerProperties: func() smithy.Properties {
    416 											var sp smithy.Properties
    417 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    418 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    419 
    420 											smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1")
    421 											return sp
    422 										}(),
    423 									},
    424 								})
    425 								return out
    426 							}(),
    427 						}, nil
    428 					}
    429 				}
    430 			}
    431 			if _PartitionResult.Name == "aws-cn" {
    432 				if _UseFIPS == false {
    433 					if _UseDualStack == false {
    434 						uriString := "https://route53.amazonaws.com.cn"
    435 
    436 						uri, err := url.Parse(uriString)
    437 						if err != nil {
    438 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    439 						}
    440 
    441 						return smithyendpoints.Endpoint{
    442 							URI:     *uri,
    443 							Headers: http.Header{},
    444 							Properties: func() smithy.Properties {
    445 								var out smithy.Properties
    446 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    447 									{
    448 										SchemeID: "aws.auth#sigv4",
    449 										SignerProperties: func() smithy.Properties {
    450 											var sp smithy.Properties
    451 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    452 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    453 
    454 											smithyhttp.SetSigV4SigningRegion(&sp, "cn-northwest-1")
    455 											return sp
    456 										}(),
    457 									},
    458 								})
    459 								return out
    460 							}(),
    461 						}, nil
    462 					}
    463 				}
    464 			}
    465 			if _PartitionResult.Name == "aws-us-gov" {
    466 				if _UseFIPS == false {
    467 					if _UseDualStack == false {
    468 						uriString := "https://route53.us-gov.amazonaws.com"
    469 
    470 						uri, err := url.Parse(uriString)
    471 						if err != nil {
    472 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    473 						}
    474 
    475 						return smithyendpoints.Endpoint{
    476 							URI:     *uri,
    477 							Headers: http.Header{},
    478 							Properties: func() smithy.Properties {
    479 								var out smithy.Properties
    480 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    481 									{
    482 										SchemeID: "aws.auth#sigv4",
    483 										SignerProperties: func() smithy.Properties {
    484 											var sp smithy.Properties
    485 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    486 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    487 
    488 											smithyhttp.SetSigV4SigningRegion(&sp, "us-gov-west-1")
    489 											return sp
    490 										}(),
    491 									},
    492 								})
    493 								return out
    494 							}(),
    495 						}, nil
    496 					}
    497 				}
    498 			}
    499 			if _PartitionResult.Name == "aws-us-gov" {
    500 				if _UseFIPS == true {
    501 					if _UseDualStack == false {
    502 						uriString := "https://route53.us-gov.amazonaws.com"
    503 
    504 						uri, err := url.Parse(uriString)
    505 						if err != nil {
    506 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    507 						}
    508 
    509 						return smithyendpoints.Endpoint{
    510 							URI:     *uri,
    511 							Headers: http.Header{},
    512 							Properties: func() smithy.Properties {
    513 								var out smithy.Properties
    514 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    515 									{
    516 										SchemeID: "aws.auth#sigv4",
    517 										SignerProperties: func() smithy.Properties {
    518 											var sp smithy.Properties
    519 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    520 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    521 
    522 											smithyhttp.SetSigV4SigningRegion(&sp, "us-gov-west-1")
    523 											return sp
    524 										}(),
    525 									},
    526 								})
    527 								return out
    528 							}(),
    529 						}, nil
    530 					}
    531 				}
    532 			}
    533 			if _PartitionResult.Name == "aws-iso" {
    534 				if _UseFIPS == false {
    535 					if _UseDualStack == false {
    536 						uriString := "https://route53.c2s.ic.gov"
    537 
    538 						uri, err := url.Parse(uriString)
    539 						if err != nil {
    540 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    541 						}
    542 
    543 						return smithyendpoints.Endpoint{
    544 							URI:     *uri,
    545 							Headers: http.Header{},
    546 							Properties: func() smithy.Properties {
    547 								var out smithy.Properties
    548 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    549 									{
    550 										SchemeID: "aws.auth#sigv4",
    551 										SignerProperties: func() smithy.Properties {
    552 											var sp smithy.Properties
    553 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    554 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    555 
    556 											smithyhttp.SetSigV4SigningRegion(&sp, "us-iso-east-1")
    557 											return sp
    558 										}(),
    559 									},
    560 								})
    561 								return out
    562 							}(),
    563 						}, nil
    564 					}
    565 				}
    566 			}
    567 			if _PartitionResult.Name == "aws-iso-b" {
    568 				if _UseFIPS == false {
    569 					if _UseDualStack == false {
    570 						uriString := "https://route53.sc2s.sgov.gov"
    571 
    572 						uri, err := url.Parse(uriString)
    573 						if err != nil {
    574 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    575 						}
    576 
    577 						return smithyendpoints.Endpoint{
    578 							URI:     *uri,
    579 							Headers: http.Header{},
    580 							Properties: func() smithy.Properties {
    581 								var out smithy.Properties
    582 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    583 									{
    584 										SchemeID: "aws.auth#sigv4",
    585 										SignerProperties: func() smithy.Properties {
    586 											var sp smithy.Properties
    587 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    588 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    589 
    590 											smithyhttp.SetSigV4SigningRegion(&sp, "us-isob-east-1")
    591 											return sp
    592 										}(),
    593 									},
    594 								})
    595 								return out
    596 							}(),
    597 						}, nil
    598 					}
    599 				}
    600 			}
    601 			if _PartitionResult.Name == "aws-iso-e" {
    602 				if _UseFIPS == false {
    603 					if _UseDualStack == false {
    604 						uriString := "https://route53.cloud.adc-e.uk"
    605 
    606 						uri, err := url.Parse(uriString)
    607 						if err != nil {
    608 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    609 						}
    610 
    611 						return smithyendpoints.Endpoint{
    612 							URI:     *uri,
    613 							Headers: http.Header{},
    614 							Properties: func() smithy.Properties {
    615 								var out smithy.Properties
    616 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    617 									{
    618 										SchemeID: "aws.auth#sigv4",
    619 										SignerProperties: func() smithy.Properties {
    620 											var sp smithy.Properties
    621 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    622 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    623 
    624 											smithyhttp.SetSigV4SigningRegion(&sp, "eu-isoe-west-1")
    625 											return sp
    626 										}(),
    627 									},
    628 								})
    629 								return out
    630 							}(),
    631 						}, nil
    632 					}
    633 				}
    634 			}
    635 			if _PartitionResult.Name == "aws-iso-f" {
    636 				if _UseFIPS == false {
    637 					if _UseDualStack == false {
    638 						uriString := "https://route53.csp.hci.ic.gov"
    639 
    640 						uri, err := url.Parse(uriString)
    641 						if err != nil {
    642 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    643 						}
    644 
    645 						return smithyendpoints.Endpoint{
    646 							URI:     *uri,
    647 							Headers: http.Header{},
    648 							Properties: func() smithy.Properties {
    649 								var out smithy.Properties
    650 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    651 									{
    652 										SchemeID: "aws.auth#sigv4",
    653 										SignerProperties: func() smithy.Properties {
    654 											var sp smithy.Properties
    655 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    656 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    657 
    658 											smithyhttp.SetSigV4SigningRegion(&sp, "us-isof-south-1")
    659 											return sp
    660 										}(),
    661 									},
    662 								})
    663 								return out
    664 							}(),
    665 						}, nil
    666 					}
    667 				}
    668 			}
    669 			if _PartitionResult.Name == "aws-eusc" {
    670 				if _UseFIPS == false {
    671 					if _UseDualStack == false {
    672 						uriString := "https://route53.amazonaws.eu"
    673 
    674 						uri, err := url.Parse(uriString)
    675 						if err != nil {
    676 							return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    677 						}
    678 
    679 						return smithyendpoints.Endpoint{
    680 							URI:     *uri,
    681 							Headers: http.Header{},
    682 							Properties: func() smithy.Properties {
    683 								var out smithy.Properties
    684 								smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
    685 									{
    686 										SchemeID: "aws.auth#sigv4",
    687 										SignerProperties: func() smithy.Properties {
    688 											var sp smithy.Properties
    689 											smithyhttp.SetSigV4SigningName(&sp, "route53")
    690 											smithyhttp.SetSigV4ASigningName(&sp, "route53")
    691 
    692 											smithyhttp.SetSigV4SigningRegion(&sp, "eusc-de-east-1")
    693 											return sp
    694 										}(),
    695 									},
    696 								})
    697 								return out
    698 							}(),
    699 						}, nil
    700 					}
    701 				}
    702 			}
    703 			if _UseFIPS == true {
    704 				if _UseDualStack == true {
    705 					if true == _PartitionResult.SupportsFIPS {
    706 						if true == _PartitionResult.SupportsDualStack {
    707 							uriString := func() string {
    708 								var out strings.Builder
    709 								out.WriteString("https://route53-fips.")
    710 								out.WriteString(_Region)
    711 								out.WriteString(".")
    712 								out.WriteString(_PartitionResult.DualStackDnsSuffix)
    713 								return out.String()
    714 							}()
    715 
    716 							uri, err := url.Parse(uriString)
    717 							if err != nil {
    718 								return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    719 							}
    720 
    721 							return smithyendpoints.Endpoint{
    722 								URI:     *uri,
    723 								Headers: http.Header{},
    724 							}, nil
    725 						}
    726 					}
    727 					return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both")
    728 				}
    729 			}
    730 			if _UseFIPS == true {
    731 				if _PartitionResult.SupportsFIPS == true {
    732 					uriString := func() string {
    733 						var out strings.Builder
    734 						out.WriteString("https://route53-fips.")
    735 						out.WriteString(_Region)
    736 						out.WriteString(".")
    737 						out.WriteString(_PartitionResult.DnsSuffix)
    738 						return out.String()
    739 					}()
    740 
    741 					uri, err := url.Parse(uriString)
    742 					if err != nil {
    743 						return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    744 					}
    745 
    746 					return smithyendpoints.Endpoint{
    747 						URI:     *uri,
    748 						Headers: http.Header{},
    749 					}, nil
    750 				}
    751 				return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS")
    752 			}
    753 			if _UseDualStack == true {
    754 				if true == _PartitionResult.SupportsDualStack {
    755 					uriString := func() string {
    756 						var out strings.Builder
    757 						out.WriteString("https://route53.")
    758 						out.WriteString(_Region)
    759 						out.WriteString(".")
    760 						out.WriteString(_PartitionResult.DualStackDnsSuffix)
    761 						return out.String()
    762 					}()
    763 
    764 					uri, err := url.Parse(uriString)
    765 					if err != nil {
    766 						return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    767 					}
    768 
    769 					return smithyendpoints.Endpoint{
    770 						URI:     *uri,
    771 						Headers: http.Header{},
    772 					}, nil
    773 				}
    774 				return endpoint, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack")
    775 			}
    776 			uriString := func() string {
    777 				var out strings.Builder
    778 				out.WriteString("https://route53.")
    779 				out.WriteString(_Region)
    780 				out.WriteString(".")
    781 				out.WriteString(_PartitionResult.DnsSuffix)
    782 				return out.String()
    783 			}()
    784 
    785 			uri, err := url.Parse(uriString)
    786 			if err != nil {
    787 				return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
    788 			}
    789 
    790 			return smithyendpoints.Endpoint{
    791 				URI:     *uri,
    792 				Headers: http.Header{},
    793 			}, nil
    794 		}
    795 		return endpoint, fmt.Errorf("Endpoint resolution failed. Invalid operation or environment input.")
    796 	}
    797 	return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region")
    798 }
    799 
    800 type endpointParamsBinder interface {
    801 	bindEndpointParams(*EndpointParameters)
    802 }
    803 
    804 func bindEndpointParams(ctx context.Context, input interface{}, options Options) *EndpointParameters {
    805 	params := &EndpointParameters{}
    806 
    807 	params.Region = bindRegion(options.Region)
    808 	params.UseDualStack = aws.Bool(options.EndpointOptions.UseDualStackEndpoint == aws.DualStackEndpointStateEnabled)
    809 	params.UseFIPS = aws.Bool(options.EndpointOptions.UseFIPSEndpoint == aws.FIPSEndpointStateEnabled)
    810 	params.Endpoint = options.BaseEndpoint
    811 
    812 	if b, ok := input.(endpointParamsBinder); ok {
    813 		b.bindEndpointParams(params)
    814 	}
    815 
    816 	return params
    817 }
    818 
    819 type resolveEndpointV2Middleware struct {
    820 	options Options
    821 }
    822 
    823 func (*resolveEndpointV2Middleware) ID() string {
    824 	return "ResolveEndpointV2"
    825 }
    826 
    827 func (m *resolveEndpointV2Middleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
    828 	out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
    829 ) {
    830 	_, span := tracing.StartSpan(ctx, "ResolveEndpoint")
    831 	defer span.End()
    832 
    833 	if awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
    834 		return next.HandleFinalize(ctx, in)
    835 	}
    836 
    837 	req, ok := in.Request.(*smithyhttp.Request)
    838 	if !ok {
    839 		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
    840 	}
    841 
    842 	if m.options.EndpointResolverV2 == nil {
    843 		return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil")
    844 	}
    845 
    846 	params := bindEndpointParams(ctx, getOperationInput(ctx), m.options)
    847 	endpt, err := timeOperationMetric(ctx, "client.call.resolve_endpoint_duration",
    848 		func() (smithyendpoints.Endpoint, error) {
    849 			return m.options.EndpointResolverV2.ResolveEndpoint(ctx, *params)
    850 		})
    851 	if err != nil {
    852 		return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
    853 	}
    854 
    855 	span.SetProperty("client.call.resolved_endpoint", endpt.URI.String())
    856 
    857 	if endpt.URI.RawPath == "" && req.URL.RawPath != "" {
    858 		endpt.URI.RawPath = endpt.URI.Path
    859 	}
    860 	req.URL.Scheme = endpt.URI.Scheme
    861 	req.URL.Host = endpt.URI.Host
    862 	req.URL.Path = smithyhttp.JoinPath(endpt.URI.Path, req.URL.Path)
    863 	req.URL.RawPath = smithyhttp.JoinPath(endpt.URI.RawPath, req.URL.RawPath)
    864 	for k := range endpt.Headers {
    865 		req.Header.Set(k, endpt.Headers.Get(k))
    866 	}
    867 
    868 	rscheme := getResolvedAuthScheme(ctx)
    869 	if rscheme == nil {
    870 		return out, metadata, fmt.Errorf("no resolved auth scheme")
    871 	}
    872 
    873 	opts, _ := smithyauth.GetAuthOptions(&endpt.Properties)
    874 	for _, o := range opts {
    875 		rscheme.SignerProperties.SetAll(&o.SignerProperties)
    876 	}
    877 
    878 	span.End()
    879 	return next.HandleFinalize(ctx, in)
    880 }