service.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudhsm
  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. //The service client's operations are safe to be used concurrently.
  12. // It is not safe to mutate any of the client's properties though.
  13. type CloudHSM struct {
  14. *client.Client
  15. }
  16. // Used for custom client initialization logic
  17. var initClient func(*client.Client)
  18. // Used for custom request initialization logic
  19. var initRequest func(*request.Request)
  20. // A ServiceName is the name of the service the client will make API calls to.
  21. const ServiceName = "cloudhsm"
  22. // New creates a new instance of the CloudHSM client with a session.
  23. // If additional configuration is needed for the client instance use the optional
  24. // aws.Config parameter to add your extra config.
  25. //
  26. // Example:
  27. // // Create a CloudHSM client from just a session.
  28. // svc := cloudhsm.New(mySession)
  29. //
  30. // // Create a CloudHSM client with additional configuration
  31. // svc := cloudhsm.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  32. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudHSM {
  33. c := p.ClientConfig(ServiceName, cfgs...)
  34. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  35. }
  36. // newClient creates, initializes and returns a new service client instance.
  37. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CloudHSM {
  38. svc := &CloudHSM{
  39. Client: client.New(
  40. cfg,
  41. metadata.ClientInfo{
  42. ServiceName: ServiceName,
  43. SigningRegion: signingRegion,
  44. Endpoint: endpoint,
  45. APIVersion: "2014-05-30",
  46. JSONVersion: "1.1",
  47. TargetPrefix: "CloudHsmFrontendService",
  48. },
  49. handlers,
  50. ),
  51. }
  52. // Handlers
  53. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  54. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  55. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  56. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  57. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  58. // Run custom client initialization if present
  59. if initClient != nil {
  60. initClient(svc.Client)
  61. }
  62. return svc
  63. }
  64. // newRequest creates a new request for a CloudHSM operation and runs any
  65. // custom request initialization.
  66. func (c *CloudHSM) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  67. req := c.NewRequest(op, params, data)
  68. // Run custom request initialization if present
  69. if initRequest != nil {
  70. initRequest(req)
  71. }
  72. return req
  73. }