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