api_op_PutQueryDefinition.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. // Creates or updates a query definition for CloudWatch Logs Insights. For more
  11. // information, see Analyzing Log Data with CloudWatch Logs Insights
  12. // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html).
  13. // To update a query definition, specify its queryDefinitionId in your request. The
  14. // values of name, queryString, and logGroupNames are changed to the values that
  15. // you specify in your update operation. No current values are retained from the
  16. // current query definition. For example, if you update a current query definition
  17. // that includes log groups, and you don't specify the logGroupNames parameter in
  18. // your update operation, the query definition changes to contain no log groups.
  19. // You must have the logs:PutQueryDefinition permission to be able to perform this
  20. // operation.
  21. func (c *Client) PutQueryDefinition(ctx context.Context, params *PutQueryDefinitionInput, optFns ...func(*Options)) (*PutQueryDefinitionOutput, error) {
  22. if params == nil {
  23. params = &PutQueryDefinitionInput{}
  24. }
  25. result, metadata, err := c.invokeOperation(ctx, "PutQueryDefinition", params, optFns, c.addOperationPutQueryDefinitionMiddlewares)
  26. if err != nil {
  27. return nil, err
  28. }
  29. out := result.(*PutQueryDefinitionOutput)
  30. out.ResultMetadata = metadata
  31. return out, nil
  32. }
  33. type PutQueryDefinitionInput struct {
  34. // A name for the query definition. If you are saving a lot of query definitions,
  35. // we recommend that you name them so that you can easily find the ones you want by
  36. // using the first part of the name as a filter in the queryDefinitionNamePrefix
  37. // parameter of DescribeQueryDefinitions
  38. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeQueryDefinitions.html).
  39. //
  40. // This member is required.
  41. Name *string
  42. // The query string to use for this definition. For more information, see
  43. // CloudWatch Logs Insights Query Syntax
  44. // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html).
  45. //
  46. // This member is required.
  47. QueryString *string
  48. // Use this parameter to include specific log groups as part of your query
  49. // definition. If you are updating a query definition and you omit this parameter,
  50. // then the updated definition will contain no log groups.
  51. LogGroupNames []string
  52. // If you are updating a query definition, use this parameter to specify the ID of
  53. // the query definition that you want to update. You can use
  54. // DescribeQueryDefinitions
  55. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeQueryDefinitions.html)
  56. // to retrieve the IDs of your saved query definitions. If you are creating a query
  57. // definition, do not specify this parameter. CloudWatch generates a unique ID for
  58. // the new query definition and include it in the response to this operation.
  59. QueryDefinitionId *string
  60. noSmithyDocumentSerde
  61. }
  62. type PutQueryDefinitionOutput struct {
  63. // The ID of the query definition.
  64. QueryDefinitionId *string
  65. // Metadata pertaining to the operation's result.
  66. ResultMetadata middleware.Metadata
  67. noSmithyDocumentSerde
  68. }
  69. func (c *Client) addOperationPutQueryDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
  70. err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutQueryDefinition{}, middleware.After)
  71. if err != nil {
  72. return err
  73. }
  74. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutQueryDefinition{}, middleware.After)
  75. if err != nil {
  76. return err
  77. }
  78. if err = addSetLoggerMiddleware(stack, options); err != nil {
  79. return err
  80. }
  81. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  82. return err
  83. }
  84. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  85. return err
  86. }
  87. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  88. return err
  89. }
  90. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  91. return err
  92. }
  93. if err = addRetryMiddlewares(stack, options); err != nil {
  94. return err
  95. }
  96. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  97. return err
  98. }
  99. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  100. return err
  101. }
  102. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  103. return err
  104. }
  105. if err = addClientUserAgent(stack); err != nil {
  106. return err
  107. }
  108. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  109. return err
  110. }
  111. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  112. return err
  113. }
  114. if err = addOpPutQueryDefinitionValidationMiddleware(stack); err != nil {
  115. return err
  116. }
  117. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutQueryDefinition(options.Region), middleware.Before); err != nil {
  118. return err
  119. }
  120. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  121. return err
  122. }
  123. if err = addResponseErrorMiddleware(stack); err != nil {
  124. return err
  125. }
  126. if err = addRequestResponseLogging(stack, options); err != nil {
  127. return err
  128. }
  129. return nil
  130. }
  131. func newServiceMetadataMiddleware_opPutQueryDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
  132. return &awsmiddleware.RegisterServiceMetadata{
  133. Region: region,
  134. ServiceID: ServiceID,
  135. SigningName: "logs",
  136. OperationName: "PutQueryDefinition",
  137. }
  138. }