service.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Code generated by private/model/cli/gen-api/main.go. 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. // Please also see https://docs.aws.amazon.com/goto/WebAPI/monitoring-2010-08-01
  29. type CloudWatch struct {
  30. *client.Client
  31. }
  32. // Used for custom client initialization logic
  33. var initClient func(*client.Client)
  34. // Used for custom request initialization logic
  35. var initRequest func(*request.Request)
  36. // Service information constants
  37. const (
  38. ServiceName = "monitoring" // Service endpoint prefix API calls made to.
  39. EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
  40. )
  41. // New creates a new instance of the CloudWatch client with a session.
  42. // If additional configuration is needed for the client instance use the optional
  43. // aws.Config parameter to add your extra config.
  44. //
  45. // Example:
  46. // // Create a CloudWatch client from just a session.
  47. // svc := cloudwatch.New(mySession)
  48. //
  49. // // Create a CloudWatch client with additional configuration
  50. // svc := cloudwatch.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  51. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudWatch {
  52. c := p.ClientConfig(EndpointsID, cfgs...)
  53. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
  54. }
  55. // newClient creates, initializes and returns a new service client instance.
  56. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *CloudWatch {
  57. svc := &CloudWatch{
  58. Client: client.New(
  59. cfg,
  60. metadata.ClientInfo{
  61. ServiceName: ServiceName,
  62. SigningName: signingName,
  63. SigningRegion: signingRegion,
  64. Endpoint: endpoint,
  65. APIVersion: "2010-08-01",
  66. },
  67. handlers,
  68. ),
  69. }
  70. // Handlers
  71. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  72. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  73. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  74. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  75. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  76. // Run custom client initialization if present
  77. if initClient != nil {
  78. initClient(svc.Client)
  79. }
  80. return svc
  81. }
  82. // newRequest creates a new request for a CloudWatch operation and runs any
  83. // custom request initialization.
  84. func (c *CloudWatch) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  85. req := c.NewRequest(op, params, data)
  86. // Run custom request initialization if present
  87. if initRequest != nil {
  88. initRequest(req)
  89. }
  90. return req
  91. }