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