service.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. // The AWS Security Token Service (STS) is a web service that enables you to
  12. // request temporary, limited-privilege credentials for AWS Identity and Access
  13. // Management (IAM) users or for users that you authenticate (federated users).
  14. // This guide provides descriptions of the STS API. For more detailed information
  15. // about using this service, go to Temporary Security Credentials (http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html).
  16. //
  17. // As an alternative to using the API, you can use one of the AWS SDKs, which
  18. // consist of libraries and sample code for various programming languages and
  19. // platforms (Java, Ruby, .NET, iOS, Android, etc.). The SDKs provide a convenient
  20. // way to create programmatic access to STS. For example, the SDKs take care
  21. // of cryptographically signing requests, managing errors, and retrying requests
  22. // automatically. For information about the AWS SDKs, including how to download
  23. // and install them, see the Tools for Amazon Web Services page (http://aws.amazon.com/tools/).
  24. //
  25. // For information about setting up signatures and authorization through the
  26. // API, go to Signing AWS API Requests (http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html)
  27. // in the AWS General Reference. For general information about the Query API,
  28. // go to Making Query Requests (http://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html)
  29. // in Using IAM. For information about using security tokens with other AWS
  30. // products, go to AWS Services That Work with IAM (http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)
  31. // in the IAM User Guide.
  32. //
  33. // If you're new to AWS and need additional technical information about a specific
  34. // AWS product, you can find the product's technical documentation at http://aws.amazon.com/documentation/
  35. // (http://aws.amazon.com/documentation/).
  36. //
  37. // Endpoints
  38. //
  39. // The AWS Security Token Service (STS) has a default endpoint of https://sts.amazonaws.com
  40. // that maps to the US East (N. Virginia) region. Additional regions are available
  41. // and are activated by default. For more information, see Activating and Deactivating
  42. // AWS STS in an AWS Region (http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html)
  43. // in the IAM User Guide.
  44. //
  45. // For information about STS endpoints, see Regions and Endpoints (http://docs.aws.amazon.com/general/latest/gr/rande.html#sts_region)
  46. // in the AWS General Reference.
  47. //
  48. // Recording API requests
  49. //
  50. // STS supports AWS CloudTrail, which is a service that records AWS calls for
  51. // your AWS account and delivers log files to an Amazon S3 bucket. By using
  52. // information collected by CloudTrail, you can determine what requests were
  53. // successfully made to STS, who made the request, when it was made, and so
  54. // on. To learn more about CloudTrail, including how to turn it on and find
  55. // your log files, see the AWS CloudTrail User Guide (http://docs.aws.amazon.com/awscloudtrail/latest/userguide/what_is_cloud_trail_top_level.html).
  56. // The service client's operations are safe to be used concurrently.
  57. // It is not safe to mutate any of the client's properties though.
  58. // Please also see https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15
  59. type STS struct {
  60. *client.Client
  61. }
  62. // Used for custom client initialization logic
  63. var initClient func(*client.Client)
  64. // Used for custom request initialization logic
  65. var initRequest func(*request.Request)
  66. // Service information constants
  67. const (
  68. ServiceName = "sts" // Service endpoint prefix API calls made to.
  69. EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
  70. )
  71. // New creates a new instance of the STS client with a session.
  72. // If additional configuration is needed for the client instance use the optional
  73. // aws.Config parameter to add your extra config.
  74. //
  75. // Example:
  76. // // Create a STS client from just a session.
  77. // svc := sts.New(mySession)
  78. //
  79. // // Create a STS client with additional configuration
  80. // svc := sts.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  81. func New(p client.ConfigProvider, cfgs ...*aws.Config) *STS {
  82. c := p.ClientConfig(EndpointsID, cfgs...)
  83. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
  84. }
  85. // newClient creates, initializes and returns a new service client instance.
  86. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *STS {
  87. svc := &STS{
  88. Client: client.New(
  89. cfg,
  90. metadata.ClientInfo{
  91. ServiceName: ServiceName,
  92. SigningName: signingName,
  93. SigningRegion: signingRegion,
  94. Endpoint: endpoint,
  95. APIVersion: "2011-06-15",
  96. },
  97. handlers,
  98. ),
  99. }
  100. // Handlers
  101. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  102. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  103. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  104. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  105. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  106. // Run custom client initialization if present
  107. if initClient != nil {
  108. initClient(svc.Client)
  109. }
  110. return svc
  111. }
  112. // newRequest creates a new request for a STS operation and runs any
  113. // custom request initialization.
  114. func (c *STS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  115. req := c.NewRequest(op, params, data)
  116. // Run custom request initialization if present
  117. if initRequest != nil {
  118. initRequest(req)
  119. }
  120. return req
  121. }