api_op_PutLogEvents.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  6. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  7. "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
  8. "github.com/aws/smithy-go/middleware"
  9. smithyhttp "github.com/aws/smithy-go/transport/http"
  10. )
  11. // Uploads a batch of log events to the specified log stream. You must include the
  12. // sequence token obtained from the response of the previous call. An upload in a
  13. // newly created log stream does not require a sequence token. You can also get the
  14. // sequence token in the expectedSequenceToken field from
  15. // InvalidSequenceTokenException. If you call PutLogEvents twice within a narrow
  16. // time period using the same value for sequenceToken, both calls might be
  17. // successful or one might be rejected. The batch of events must satisfy the
  18. // following constraints:
  19. //
  20. // * The maximum batch size is 1,048,576 bytes. This size
  21. // is calculated as the sum of all event messages in UTF-8, plus 26 bytes for each
  22. // log event.
  23. //
  24. // * None of the log events in the batch can be more than 2 hours in
  25. // the future.
  26. //
  27. // * None of the log events in the batch can be older than 14 days or
  28. // older than the retention period of the log group.
  29. //
  30. // * The log events in the batch
  31. // must be in chronological order by their timestamp. The timestamp is the time the
  32. // event occurred, expressed as the number of milliseconds after Jan 1, 1970
  33. // 00:00:00 UTC. (In Amazon Web Services Tools for PowerShell and the Amazon Web
  34. // Services SDK for .NET, the timestamp is specified in .NET format:
  35. // yyyy-mm-ddThh:mm:ss. For example, 2017-09-15T13:45:30.)
  36. //
  37. // * A batch of log events
  38. // in a single request cannot span more than 24 hours. Otherwise, the operation
  39. // fails.
  40. //
  41. // * The maximum number of log events in a batch is 10,000.
  42. //
  43. // * There is a
  44. // quota of 5 requests per second per log stream. Additional requests are
  45. // throttled. This quota can't be changed.
  46. //
  47. // If a call to PutLogEvents returns
  48. // "UnrecognizedClientException" the most likely cause is an invalid Amazon Web
  49. // Services access key ID or secret key.
  50. func (c *Client) PutLogEvents(ctx context.Context, params *PutLogEventsInput, optFns ...func(*Options)) (*PutLogEventsOutput, error) {
  51. if params == nil {
  52. params = &PutLogEventsInput{}
  53. }
  54. result, metadata, err := c.invokeOperation(ctx, "PutLogEvents", params, optFns, c.addOperationPutLogEventsMiddlewares)
  55. if err != nil {
  56. return nil, err
  57. }
  58. out := result.(*PutLogEventsOutput)
  59. out.ResultMetadata = metadata
  60. return out, nil
  61. }
  62. type PutLogEventsInput struct {
  63. // The log events.
  64. //
  65. // This member is required.
  66. LogEvents []types.InputLogEvent
  67. // The name of the log group.
  68. //
  69. // This member is required.
  70. LogGroupName *string
  71. // The name of the log stream.
  72. //
  73. // This member is required.
  74. LogStreamName *string
  75. // The sequence token obtained from the response of the previous PutLogEvents call.
  76. // An upload in a newly created log stream does not require a sequence token. You
  77. // can also get the sequence token using DescribeLogStreams
  78. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html).
  79. // If you call PutLogEvents twice within a narrow time period using the same value
  80. // for sequenceToken, both calls might be successful or one might be rejected.
  81. SequenceToken *string
  82. noSmithyDocumentSerde
  83. }
  84. type PutLogEventsOutput struct {
  85. // The next sequence token.
  86. NextSequenceToken *string
  87. // The rejected events.
  88. RejectedLogEventsInfo *types.RejectedLogEventsInfo
  89. // Metadata pertaining to the operation's result.
  90. ResultMetadata middleware.Metadata
  91. noSmithyDocumentSerde
  92. }
  93. func (c *Client) addOperationPutLogEventsMiddlewares(stack *middleware.Stack, options Options) (err error) {
  94. err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutLogEvents{}, middleware.After)
  95. if err != nil {
  96. return err
  97. }
  98. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutLogEvents{}, middleware.After)
  99. if err != nil {
  100. return err
  101. }
  102. if err = addSetLoggerMiddleware(stack, options); err != nil {
  103. return err
  104. }
  105. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  106. return err
  107. }
  108. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  109. return err
  110. }
  111. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  112. return err
  113. }
  114. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  115. return err
  116. }
  117. if err = addRetryMiddlewares(stack, options); err != nil {
  118. return err
  119. }
  120. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  121. return err
  122. }
  123. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  124. return err
  125. }
  126. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  127. return err
  128. }
  129. if err = addClientUserAgent(stack); err != nil {
  130. return err
  131. }
  132. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  133. return err
  134. }
  135. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  136. return err
  137. }
  138. if err = addOpPutLogEventsValidationMiddleware(stack); err != nil {
  139. return err
  140. }
  141. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutLogEvents(options.Region), middleware.Before); err != nil {
  142. return err
  143. }
  144. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  145. return err
  146. }
  147. if err = addResponseErrorMiddleware(stack); err != nil {
  148. return err
  149. }
  150. if err = addRequestResponseLogging(stack, options); err != nil {
  151. return err
  152. }
  153. return nil
  154. }
  155. func newServiceMetadataMiddleware_opPutLogEvents(region string) *awsmiddleware.RegisterServiceMetadata {
  156. return &awsmiddleware.RegisterServiceMetadata{
  157. Region: region,
  158. ServiceID: ServiceID,
  159. SigningName: "logs",
  160. OperationName: "PutLogEvents",
  161. }
  162. }