api_op_StartQuery.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/smithy-go/middleware"
  8. smithyhttp "github.com/aws/smithy-go/transport/http"
  9. )
  10. // Schedules a query of a log group using CloudWatch Logs Insights. You specify the
  11. // log group and time range to query and the query string to use. For more
  12. // information, see CloudWatch Logs Insights Query Syntax
  13. // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html).
  14. // Queries time out after 15 minutes of execution. If your queries are timing out,
  15. // reduce the time range being searched or partition your query into a number of
  16. // queries.
  17. func (c *Client) StartQuery(ctx context.Context, params *StartQueryInput, optFns ...func(*Options)) (*StartQueryOutput, error) {
  18. if params == nil {
  19. params = &StartQueryInput{}
  20. }
  21. result, metadata, err := c.invokeOperation(ctx, "StartQuery", params, optFns, c.addOperationStartQueryMiddlewares)
  22. if err != nil {
  23. return nil, err
  24. }
  25. out := result.(*StartQueryOutput)
  26. out.ResultMetadata = metadata
  27. return out, nil
  28. }
  29. type StartQueryInput struct {
  30. // The end of the time range to query. The range is inclusive, so the specified end
  31. // time is included in the query. Specified as epoch time, the number of seconds
  32. // since January 1, 1970, 00:00:00 UTC.
  33. //
  34. // This member is required.
  35. EndTime *int64
  36. // The query string to use. For more information, see CloudWatch Logs Insights
  37. // Query Syntax
  38. // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html).
  39. //
  40. // This member is required.
  41. QueryString *string
  42. // The beginning of the time range to query. The range is inclusive, so the
  43. // specified start time is included in the query. Specified as epoch time, the
  44. // number of seconds since January 1, 1970, 00:00:00 UTC.
  45. //
  46. // This member is required.
  47. StartTime *int64
  48. // The maximum number of log events to return in the query. If the query string
  49. // uses the fields command, only the specified fields and their values are
  50. // returned. The default is 1000.
  51. Limit *int32
  52. // The log group on which to perform the query. A StartQuery operation must include
  53. // a logGroupNames or a logGroupName parameter, but not both.
  54. LogGroupName *string
  55. // The list of log groups to be queried. You can include up to 20 log groups. A
  56. // StartQuery operation must include a logGroupNames or a logGroupName parameter,
  57. // but not both.
  58. LogGroupNames []string
  59. noSmithyDocumentSerde
  60. }
  61. type StartQueryOutput struct {
  62. // The unique ID of the query.
  63. QueryId *string
  64. // Metadata pertaining to the operation's result.
  65. ResultMetadata middleware.Metadata
  66. noSmithyDocumentSerde
  67. }
  68. func (c *Client) addOperationStartQueryMiddlewares(stack *middleware.Stack, options Options) (err error) {
  69. err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartQuery{}, middleware.After)
  70. if err != nil {
  71. return err
  72. }
  73. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartQuery{}, middleware.After)
  74. if err != nil {
  75. return err
  76. }
  77. if err = addSetLoggerMiddleware(stack, options); err != nil {
  78. return err
  79. }
  80. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  81. return err
  82. }
  83. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  84. return err
  85. }
  86. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  87. return err
  88. }
  89. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  90. return err
  91. }
  92. if err = addRetryMiddlewares(stack, options); err != nil {
  93. return err
  94. }
  95. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  96. return err
  97. }
  98. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  99. return err
  100. }
  101. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  102. return err
  103. }
  104. if err = addClientUserAgent(stack); err != nil {
  105. return err
  106. }
  107. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  108. return err
  109. }
  110. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  111. return err
  112. }
  113. if err = addOpStartQueryValidationMiddleware(stack); err != nil {
  114. return err
  115. }
  116. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartQuery(options.Region), middleware.Before); err != nil {
  117. return err
  118. }
  119. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  120. return err
  121. }
  122. if err = addResponseErrorMiddleware(stack); err != nil {
  123. return err
  124. }
  125. if err = addRequestResponseLogging(stack, options); err != nil {
  126. return err
  127. }
  128. return nil
  129. }
  130. func newServiceMetadataMiddleware_opStartQuery(region string) *awsmiddleware.RegisterServiceMetadata {
  131. return &awsmiddleware.RegisterServiceMetadata{
  132. Region: region,
  133. ServiceID: ServiceID,
  134. SigningName: "logs",
  135. OperationName: "StartQuery",
  136. }
  137. }