service.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package sts
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/client"
  6. "github.com/aws/aws-sdk-go/aws/client/metadata"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/aws/signer/v4"
  9. "github.com/aws/aws-sdk-go/private/protocol/query"
  10. )
  11. // STS provides the API operation methods for making requests to
  12. // AWS Security Token Service. See this package's package overview docs
  13. // for details on the service.
  14. //
  15. // STS methods are safe to use concurrently. It is not safe to
  16. // modify mutate any of the struct's properties though.
  17. type STS struct {
  18. *client.Client
  19. }
  20. // Used for custom client initialization logic
  21. var initClient func(*client.Client)
  22. // Used for custom request initialization logic
  23. var initRequest func(*request.Request)
  24. // Service information constants
  25. const (
  26. ServiceName = "sts" // Name of service.
  27. EndpointsID = ServiceName // ID to lookup a service endpoint with.
  28. ServiceID = "STS" // ServiceID is a unique identifier of a specific service.
  29. )
  30. // New creates a new instance of the STS client with a session.
  31. // If additional configuration is needed for the client instance use the optional
  32. // aws.Config parameter to add your extra config.
  33. //
  34. // Example:
  35. //
  36. // mySession := session.Must(session.NewSession())
  37. //
  38. // // Create a STS client from just a session.
  39. // svc := sts.New(mySession)
  40. //
  41. // // Create a STS client with additional configuration
  42. // svc := sts.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  43. func New(p client.ConfigProvider, cfgs ...*aws.Config) *STS {
  44. c := p.ClientConfig(EndpointsID, cfgs...)
  45. if c.SigningNameDerived || len(c.SigningName) == 0 {
  46. c.SigningName = EndpointsID
  47. // No Fallback
  48. }
  49. return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName, c.ResolvedRegion)
  50. }
  51. // newClient creates, initializes and returns a new service client instance.
  52. func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName, resolvedRegion string) *STS {
  53. svc := &STS{
  54. Client: client.New(
  55. cfg,
  56. metadata.ClientInfo{
  57. ServiceName: ServiceName,
  58. ServiceID: ServiceID,
  59. SigningName: signingName,
  60. SigningRegion: signingRegion,
  61. PartitionID: partitionID,
  62. Endpoint: endpoint,
  63. APIVersion: "2011-06-15",
  64. ResolvedRegion: resolvedRegion,
  65. },
  66. handlers,
  67. ),
  68. }
  69. // Handlers
  70. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  71. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  72. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  73. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  74. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  75. // Run custom client initialization if present
  76. if initClient != nil {
  77. initClient(svc.Client)
  78. }
  79. return svc
  80. }
  81. // newRequest creates a new request for a STS operation and runs any
  82. // custom request initialization.
  83. func (c *STS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  84. req := c.NewRequest(op, params, data)
  85. // Run custom request initialization if present
  86. if initRequest != nil {
  87. initRequest(req)
  88. }
  89. return req
  90. }