service.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudwatchevents
  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. // Amazon CloudWatch Events helps you to respond to state changes in your AWS
  12. // resources. When your resources change state they automatically send events
  13. // into an event stream. You can create rules that match selected events in
  14. // the stream and route them to targets to take action. You can also use rules
  15. // to take action on a pre-determined schedule. For example, you can configure
  16. // rules to:
  17. //
  18. // Automatically invoke an AWS Lambda function to update DNS entries when
  19. // an event notifies you that Amazon EC2 instance enters the running state.
  20. // Direct specific API records from CloudTrail to an Amazon Kinesis stream for
  21. // detailed analysis of potential security or availability risks. Periodically
  22. // invoke a built-in target to create a snapshot of an Amazon EBS volume.
  23. // For more information about Amazon CloudWatch Events features, see the Amazon
  24. // CloudWatch Developer Guide (http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide).
  25. //The service client's operations are safe to be used concurrently.
  26. // It is not safe to mutate any of the client's properties though.
  27. type CloudWatchEvents struct {
  28. *client.Client
  29. }
  30. // Used for custom client initialization logic
  31. var initClient func(*client.Client)
  32. // Used for custom request initialization logic
  33. var initRequest func(*request.Request)
  34. // A ServiceName is the name of the service the client will make API calls to.
  35. const ServiceName = "events"
  36. // New creates a new instance of the CloudWatchEvents client with a session.
  37. // If additional configuration is needed for the client instance use the optional
  38. // aws.Config parameter to add your extra config.
  39. //
  40. // Example:
  41. // // Create a CloudWatchEvents client from just a session.
  42. // svc := cloudwatchevents.New(mySession)
  43. //
  44. // // Create a CloudWatchEvents client with additional configuration
  45. // svc := cloudwatchevents.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  46. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudWatchEvents {
  47. c := p.ClientConfig(ServiceName, cfgs...)
  48. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  49. }
  50. // newClient creates, initializes and returns a new service client instance.
  51. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CloudWatchEvents {
  52. svc := &CloudWatchEvents{
  53. Client: client.New(
  54. cfg,
  55. metadata.ClientInfo{
  56. ServiceName: ServiceName,
  57. SigningRegion: signingRegion,
  58. Endpoint: endpoint,
  59. APIVersion: "2015-10-07",
  60. JSONVersion: "1.1",
  61. TargetPrefix: "AWSEvents",
  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(jsonrpc.UnmarshalErrorHandler)
  72. // Run custom client initialization if present
  73. if initClient != nil {
  74. initClient(svc.Client)
  75. }
  76. return svc
  77. }
  78. // newRequest creates a new request for a CloudWatchEvents operation and runs any
  79. // custom request initialization.
  80. func (c *CloudWatchEvents) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  81. req := c.NewRequest(op, params, data)
  82. // Run custom request initialization if present
  83. if initRequest != nil {
  84. initRequest(req)
  85. }
  86. return req
  87. }