service.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // THIS FILE IS AUTOMATICALLY GENERATED. 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. type STS struct {
  59. *client.Client
  60. }
  61. // Used for custom client initialization logic
  62. var initClient func(*client.Client)
  63. // Used for custom request initialization logic
  64. var initRequest func(*request.Request)
  65. // A ServiceName is the name of the service the client will make API calls to.
  66. const ServiceName = "sts"
  67. // New creates a new instance of the STS client with a session.
  68. // If additional configuration is needed for the client instance use the optional
  69. // aws.Config parameter to add your extra config.
  70. //
  71. // Example:
  72. // // Create a STS client from just a session.
  73. // svc := sts.New(mySession)
  74. //
  75. // // Create a STS client with additional configuration
  76. // svc := sts.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  77. func New(p client.ConfigProvider, cfgs ...*aws.Config) *STS {
  78. c := p.ClientConfig(ServiceName, cfgs...)
  79. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  80. }
  81. // newClient creates, initializes and returns a new service client instance.
  82. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *STS {
  83. svc := &STS{
  84. Client: client.New(
  85. cfg,
  86. metadata.ClientInfo{
  87. ServiceName: ServiceName,
  88. SigningRegion: signingRegion,
  89. Endpoint: endpoint,
  90. APIVersion: "2011-06-15",
  91. },
  92. handlers,
  93. ),
  94. }
  95. // Handlers
  96. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  97. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  98. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  99. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  100. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  101. // Run custom client initialization if present
  102. if initClient != nil {
  103. initClient(svc.Client)
  104. }
  105. return svc
  106. }
  107. // newRequest creates a new request for a STS operation and runs any
  108. // custom request initialization.
  109. func (c *STS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  110. req := c.NewRequest(op, params, data)
  111. // Run custom request initialization if present
  112. if initRequest != nil {
  113. initRequest(req)
  114. }
  115. return req
  116. }