service.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package iam
  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. // AWS Identity and Access Management (IAM) is a web service that you can use
  12. // to manage users and user permissions under your AWS account. This guide provides
  13. // descriptions of IAM actions that you can call programmatically. For general
  14. // information about IAM, see AWS Identity and Access Management (IAM) (http://aws.amazon.com/iam/).
  15. // For the user guide for IAM, see Using IAM (http://docs.aws.amazon.com/IAM/latest/UserGuide/).
  16. //
  17. // AWS provides SDKs that consist of libraries and sample code for various
  18. // programming languages and platforms (Java, Ruby, .NET, iOS, Android, etc.).
  19. // The SDKs provide a convenient way to create programmatic access to IAM and
  20. // AWS. For example, the SDKs take care of tasks such as cryptographically signing
  21. // requests (see below), managing errors, and retrying requests automatically.
  22. // For information about the AWS SDKs, including how to download and install
  23. // them, see the Tools for Amazon Web Services (http://aws.amazon.com/tools/)
  24. // page.
  25. //
  26. // We recommend that you use the AWS SDKs to make programmatic API calls to
  27. // IAM. However, you can also use the IAM Query API to make direct calls to
  28. // the IAM web service. To learn more about the IAM Query API, see Making Query
  29. // Requests (http://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html)
  30. // in the Using IAM guide. IAM supports GET and POST requests for all actions.
  31. // That is, the API does not require you to use GET for some actions and POST
  32. // for others. However, GET requests are subject to the limitation size of a
  33. // URL. Therefore, for operations that require larger sizes, use a POST request.
  34. //
  35. // Signing Requests
  36. //
  37. // Requests must be signed using an access key ID and a secret access key.
  38. // We strongly recommend that you do not use your AWS account access key ID
  39. // and secret access key for everyday work with IAM. You can use the access
  40. // key ID and secret access key for an IAM user or you can use the AWS Security
  41. // Token Service to generate temporary security credentials and use those to
  42. // sign requests.
  43. //
  44. // To sign requests, we recommend that you use Signature Version 4 (http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
  45. // If you have an existing application that uses Signature Version 2, you do
  46. // not have to update it to use Signature Version 4. However, some operations
  47. // now require Signature Version 4. The documentation for operations that require
  48. // version 4 indicate this requirement.
  49. //
  50. // Additional Resources
  51. //
  52. // For more information, see the following:
  53. //
  54. // AWS Security Credentials (http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html).
  55. // This topic provides general information about the types of credentials used
  56. // for accessing AWS.
  57. //
  58. // IAM Best Practices (http://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.html).
  59. // This topic presents a list of suggestions for using the IAM service to help
  60. // secure your AWS resources.
  61. //
  62. // Signing AWS API Requests (http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html).
  63. // This set of topics walk you through the process of signing a request using
  64. // an access key ID and secret access key.
  65. //The service client's operations are safe to be used concurrently.
  66. // It is not safe to mutate any of the client's properties though.
  67. type IAM struct {
  68. *client.Client
  69. }
  70. // Used for custom client initialization logic
  71. var initClient func(*client.Client)
  72. // Used for custom request initialization logic
  73. var initRequest func(*request.Request)
  74. // A ServiceName is the name of the service the client will make API calls to.
  75. const ServiceName = "iam"
  76. // New creates a new instance of the IAM client with a session.
  77. // If additional configuration is needed for the client instance use the optional
  78. // aws.Config parameter to add your extra config.
  79. //
  80. // Example:
  81. // // Create a IAM client from just a session.
  82. // svc := iam.New(mySession)
  83. //
  84. // // Create a IAM client with additional configuration
  85. // svc := iam.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  86. func New(p client.ConfigProvider, cfgs ...*aws.Config) *IAM {
  87. c := p.ClientConfig(ServiceName, cfgs...)
  88. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  89. }
  90. // newClient creates, initializes and returns a new service client instance.
  91. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *IAM {
  92. svc := &IAM{
  93. Client: client.New(
  94. cfg,
  95. metadata.ClientInfo{
  96. ServiceName: ServiceName,
  97. SigningRegion: signingRegion,
  98. Endpoint: endpoint,
  99. APIVersion: "2010-05-08",
  100. },
  101. handlers,
  102. ),
  103. }
  104. // Handlers
  105. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  106. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  107. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  108. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  109. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  110. // Run custom client initialization if present
  111. if initClient != nil {
  112. initClient(svc.Client)
  113. }
  114. return svc
  115. }
  116. // newRequest creates a new request for a IAM operation and runs any
  117. // custom request initialization.
  118. func (c *IAM) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  119. req := c.NewRequest(op, params, data)
  120. // Run custom request initialization if present
  121. if initRequest != nil {
  122. initRequest(req)
  123. }
  124. return req
  125. }