service.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package kms
  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/jsonrpc"
  10. )
  11. // AWS Key Management Service (AWS KMS) is an encryption and key management
  12. // web service. This guide describes the AWS KMS operations that you can call
  13. // programmatically. For general information about AWS KMS, see the AWS Key
  14. // Management Service Developer Guide (http://docs.aws.amazon.com/kms/latest/developerguide/).
  15. //
  16. // AWS provides SDKs that consist of libraries and sample code for various
  17. // programming languages and platforms (Java, Ruby, .Net, iOS, Android, etc.).
  18. // The SDKs provide a convenient way to create programmatic access to AWS KMS
  19. // and other AWS services. For example, the SDKs take care of tasks such as
  20. // signing requests (see below), managing errors, and retrying requests automatically.
  21. // For more information about the AWS SDKs, including how to download and install
  22. // them, see Tools for Amazon Web Services (http://aws.amazon.com/tools/).
  23. //
  24. // We recommend that you use the AWS SDKs to make programmatic API calls to
  25. // AWS KMS.
  26. //
  27. // Clients must support TLS (Transport Layer Security) 1.0. We recommend TLS
  28. // 1.2. Clients must also support cipher suites with Perfect Forward Secrecy
  29. // (PFS) such as Ephemeral Diffie-Hellman (DHE) or Elliptic Curve Ephemeral
  30. // Diffie-Hellman (ECDHE). Most modern systems such as Java 7 and later support
  31. // these modes.
  32. //
  33. // Signing Requests
  34. //
  35. // Requests must be signed by using an access key ID and a secret access key.
  36. // We strongly recommend that you do not use your AWS account (root) access
  37. // key ID and secret key for everyday work with AWS KMS. Instead, use the access
  38. // key ID and secret access key for an IAM user, or you can use the AWS Security
  39. // Token Service to generate temporary security credentials that you can use
  40. // to sign requests.
  41. //
  42. // All AWS KMS operations require Signature Version 4 (http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
  43. //
  44. // Logging API Requests
  45. //
  46. // AWS KMS supports AWS CloudTrail, a service that logs AWS API calls and related
  47. // events for your AWS account and delivers them to an Amazon S3 bucket that
  48. // you specify. By using the information collected by CloudTrail, you can determine
  49. // what requests were made to AWS KMS, who made the request, when it was made,
  50. // and so on. To learn more about CloudTrail, including how to turn it on and
  51. // find your log files, see the AWS CloudTrail User Guide (http://docs.aws.amazon.com/awscloudtrail/latest/userguide/).
  52. //
  53. // Additional Resources
  54. //
  55. // For more information about credentials and request signing, see the following:
  56. //
  57. // AWS Security Credentials (http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html)
  58. // - This topic provides general information about the types of credentials
  59. // used for accessing AWS.
  60. //
  61. // Temporary Security Credentials (http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)
  62. // - This section of the IAM User Guide describes how to create and use temporary
  63. // security credentials.
  64. //
  65. // Signature Version 4 Signing Process (http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)
  66. // - This set of topics walks you through the process of signing a request using
  67. // an access key ID and a secret access key.
  68. //
  69. // Commonly Used APIs
  70. //
  71. // Of the APIs discussed in this guide, the following will prove the most useful
  72. // for most applications. You will likely perform actions other than these,
  73. // such as creating keys and assigning policies, by using the console.
  74. //
  75. // Encrypt
  76. //
  77. // Decrypt
  78. //
  79. // GenerateDataKey
  80. //
  81. // GenerateDataKeyWithoutPlaintext
  82. //The service client's operations are safe to be used concurrently.
  83. // It is not safe to mutate any of the client's properties though.
  84. type KMS struct {
  85. *client.Client
  86. }
  87. // Used for custom client initialization logic
  88. var initClient func(*client.Client)
  89. // Used for custom request initialization logic
  90. var initRequest func(*request.Request)
  91. // A ServiceName is the name of the service the client will make API calls to.
  92. const ServiceName = "kms"
  93. // New creates a new instance of the KMS client with a session.
  94. // If additional configuration is needed for the client instance use the optional
  95. // aws.Config parameter to add your extra config.
  96. //
  97. // Example:
  98. // // Create a KMS client from just a session.
  99. // svc := kms.New(mySession)
  100. //
  101. // // Create a KMS client with additional configuration
  102. // svc := kms.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  103. func New(p client.ConfigProvider, cfgs ...*aws.Config) *KMS {
  104. c := p.ClientConfig(ServiceName, cfgs...)
  105. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  106. }
  107. // newClient creates, initializes and returns a new service client instance.
  108. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *KMS {
  109. svc := &KMS{
  110. Client: client.New(
  111. cfg,
  112. metadata.ClientInfo{
  113. ServiceName: ServiceName,
  114. SigningRegion: signingRegion,
  115. Endpoint: endpoint,
  116. APIVersion: "2014-11-01",
  117. JSONVersion: "1.1",
  118. TargetPrefix: "TrentService",
  119. },
  120. handlers,
  121. ),
  122. }
  123. // Handlers
  124. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  125. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  126. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  127. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  128. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  129. // Run custom client initialization if present
  130. if initClient != nil {
  131. initClient(svc.Client)
  132. }
  133. return svc
  134. }
  135. // newRequest creates a new request for a KMS operation and runs any
  136. // custom request initialization.
  137. func (c *KMS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  138. req := c.NewRequest(op, params, data)
  139. // Run custom request initialization if present
  140. if initRequest != nil {
  141. initRequest(req)
  142. }
  143. return req
  144. }