service.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package sns
  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. // Amazon Simple Notification Service (Amazon SNS) is a web service that enables
  12. // you to build distributed web-enabled applications. Applications can use Amazon
  13. // SNS to easily push real-time notification messages to interested subscribers
  14. // over multiple delivery protocols. For more information about this product
  15. // see http://aws.amazon.com/sns (http://aws.amazon.com/sns/). For detailed
  16. // information about Amazon SNS features and their associated API calls, see
  17. // the Amazon SNS Developer Guide (http://docs.aws.amazon.com/sns/latest/dg/).
  18. //
  19. // We also provide SDKs that enable you to access Amazon SNS from your preferred
  20. // programming language. The SDKs contain functionality that automatically takes
  21. // care of tasks such as: cryptographically signing your service requests, retrying
  22. // requests, and handling error responses. For a list of available SDKs, go
  23. // to Tools for Amazon Web Services (http://aws.amazon.com/tools/).
  24. //The service client's operations are safe to be used concurrently.
  25. // It is not safe to mutate any of the client's properties though.
  26. type SNS struct {
  27. *client.Client
  28. }
  29. // Used for custom client initialization logic
  30. var initClient func(*client.Client)
  31. // Used for custom request initialization logic
  32. var initRequest func(*request.Request)
  33. // A ServiceName is the name of the service the client will make API calls to.
  34. const ServiceName = "sns"
  35. // New creates a new instance of the SNS client with a session.
  36. // If additional configuration is needed for the client instance use the optional
  37. // aws.Config parameter to add your extra config.
  38. //
  39. // Example:
  40. // // Create a SNS client from just a session.
  41. // svc := sns.New(mySession)
  42. //
  43. // // Create a SNS client with additional configuration
  44. // svc := sns.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  45. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SNS {
  46. c := p.ClientConfig(ServiceName, cfgs...)
  47. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  48. }
  49. // newClient creates, initializes and returns a new service client instance.
  50. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *SNS {
  51. svc := &SNS{
  52. Client: client.New(
  53. cfg,
  54. metadata.ClientInfo{
  55. ServiceName: ServiceName,
  56. SigningRegion: signingRegion,
  57. Endpoint: endpoint,
  58. APIVersion: "2010-03-31",
  59. },
  60. handlers,
  61. ),
  62. }
  63. // Handlers
  64. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  65. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  66. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  67. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  68. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  69. // Run custom client initialization if present
  70. if initClient != nil {
  71. initClient(svc.Client)
  72. }
  73. return svc
  74. }
  75. // newRequest creates a new request for a SNS operation and runs any
  76. // custom request initialization.
  77. func (c *SNS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  78. req := c.NewRequest(op, params, data)
  79. // Run custom request initialization if present
  80. if initRequest != nil {
  81. initRequest(req)
  82. }
  83. return req
  84. }