service.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudwatchlogs
  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. // You can use Amazon CloudWatch Logs to monitor, store, and access your log
  12. // files from Amazon Elastic Compute Cloud (Amazon EC2) instances, Amazon CloudTrail,
  13. // or other sources. You can then retrieve the associated log data from CloudWatch
  14. // Logs using the Amazon CloudWatch console, the CloudWatch Logs commands in
  15. // the AWS CLI, the CloudWatch Logs API, or the CloudWatch Logs SDK.
  16. //
  17. // You can use CloudWatch Logs to:
  18. //
  19. // * Monitor Logs from Amazon EC2 Instances in Real-time: You can use CloudWatch
  20. // Logs to monitor applications and systems using log data. For example,
  21. // CloudWatch Logs can track the number of errors that occur in your application
  22. // logs and send you a notification whenever the rate of errors exceeds a
  23. // threshold you specify. CloudWatch Logs uses your log data for monitoring;
  24. // so, no code changes are required. For example, you can monitor application
  25. // logs for specific literal terms (such as "NullReferenceException") or
  26. // count the number of occurrences of a literal term at a particular position
  27. // in log data (such as "404" status codes in an Apache access log). When
  28. // the term you are searching for is found, CloudWatch Logs reports the data
  29. // to a Amazon CloudWatch metric that you specify.
  30. //
  31. // * Monitor Amazon CloudTrail Logged Events: You can create alarms in Amazon
  32. // CloudWatch and receive notifications of particular API activity as captured
  33. // by CloudTrail and use the notification to perform troubleshooting.
  34. //
  35. // * Archive Log Data: You can use CloudWatch Logs to store your log data
  36. // in highly durable storage. You can change the log retention setting so
  37. // that any log events older than this setting are automatically deleted.
  38. // The CloudWatch Logs agent makes it easy to quickly send both rotated and
  39. // non-rotated log data off of a host and into the log service. You can then
  40. // access the raw log data when you need it.
  41. //The service client's operations are safe to be used concurrently.
  42. // It is not safe to mutate any of the client's properties though.
  43. type CloudWatchLogs struct {
  44. *client.Client
  45. }
  46. // Used for custom client initialization logic
  47. var initClient func(*client.Client)
  48. // Used for custom request initialization logic
  49. var initRequest func(*request.Request)
  50. // A ServiceName is the name of the service the client will make API calls to.
  51. const ServiceName = "logs"
  52. // New creates a new instance of the CloudWatchLogs client with a session.
  53. // If additional configuration is needed for the client instance use the optional
  54. // aws.Config parameter to add your extra config.
  55. //
  56. // Example:
  57. // // Create a CloudWatchLogs client from just a session.
  58. // svc := cloudwatchlogs.New(mySession)
  59. //
  60. // // Create a CloudWatchLogs client with additional configuration
  61. // svc := cloudwatchlogs.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  62. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CloudWatchLogs {
  63. c := p.ClientConfig(ServiceName, cfgs...)
  64. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  65. }
  66. // newClient creates, initializes and returns a new service client instance.
  67. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CloudWatchLogs {
  68. svc := &CloudWatchLogs{
  69. Client: client.New(
  70. cfg,
  71. metadata.ClientInfo{
  72. ServiceName: ServiceName,
  73. SigningRegion: signingRegion,
  74. Endpoint: endpoint,
  75. APIVersion: "2014-03-28",
  76. JSONVersion: "1.1",
  77. TargetPrefix: "Logs_20140328",
  78. },
  79. handlers,
  80. ),
  81. }
  82. // Handlers
  83. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  84. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  85. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  86. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  87. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  88. // Run custom client initialization if present
  89. if initClient != nil {
  90. initClient(svc.Client)
  91. }
  92. return svc
  93. }
  94. // newRequest creates a new request for a CloudWatchLogs operation and runs any
  95. // custom request initialization.
  96. func (c *CloudWatchLogs) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  97. req := c.NewRequest(op, params, data)
  98. // Run custom request initialization if present
  99. if initRequest != nil {
  100. initRequest(req)
  101. }
  102. return req
  103. }