service.go 4.6 KB

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