service.go 3.2 KB

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