service.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudwatch
  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 CloudWatch monitors your Amazon Web Services (AWS) resources and the
  12. // applications you run on AWS in real-time. You can use CloudWatch to collect
  13. // and track metrics, which are the variables you want to measure for your resources
  14. // and applications.
  15. //
  16. // CloudWatch alarms send notifications or automatically make changes to the
  17. // resources you are monitoring based on rules that you define. For example,
  18. // you can monitor the CPU usage and disk reads and writes of your Amazon Elastic
  19. // Compute Cloud (Amazon EC2) instances and then use this data to determine
  20. // whether you should launch additional instances to handle increased load.
  21. // You can also use this data to stop under-used instances to save money.
  22. //
  23. // In addition to monitoring the built-in metrics that come with AWS, you can
  24. // monitor your own custom metrics. With CloudWatch, you gain system-wide visibility
  25. // into resource utilization, application performance, and operational health.
  26. //The service client's operations are safe to be used concurrently.
  27. // It is not safe to mutate any of the client's properties though.
  28. type CloudWatch struct {
  29. *client.Client
  30. }
  31. // Used for custom client initialization logic
  32. var initClient func(*client.Client)
  33. // Used for custom request initialization logic
  34. var initRequest func(*request.Request)
  35. // A ServiceName is the name of the service the client will make API calls to.
  36. const ServiceName = "monitoring"
  37. // New creates a new instance of the CloudWatch client with a session.
  38. // If additional configuration is needed for the client instance use the optional
  39. // aws.Config parameter to add your extra config.
  40. //
  41. // Example:
  42. // // Create a CloudWatch client from just a session.
  43. // svc := cloudwatch.New(mySession)
  44. //
  45. // // Create a CloudWatch client with additional configuration
  46. // svc := cloudwatch.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  47. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudWatch {
  48. c := p.ClientConfig(ServiceName, cfgs...)
  49. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  50. }
  51. // newClient creates, initializes and returns a new service client instance.
  52. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CloudWatch {
  53. svc := &CloudWatch{
  54. Client: client.New(
  55. cfg,
  56. metadata.ClientInfo{
  57. ServiceName: ServiceName,
  58. SigningRegion: signingRegion,
  59. Endpoint: endpoint,
  60. APIVersion: "2010-08-01",
  61. },
  62. handlers,
  63. ),
  64. }
  65. // Handlers
  66. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  67. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  68. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  69. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  70. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  71. // Run custom client initialization if present
  72. if initClient != nil {
  73. initClient(svc.Client)
  74. }
  75. return svc
  76. }
  77. // newRequest creates a new request for a CloudWatch operation and runs any
  78. // custom request initialization.
  79. func (c *CloudWatch) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  80. req := c.NewRequest(op, params, data)
  81. // Run custom request initialization if present
  82. if initRequest != nil {
  83. initRequest(req)
  84. }
  85. return req
  86. }