Skip to content

Commit

Permalink
feat(client-cloudwatch-logs): Add ClientToken to QueryDefinition CFN …
Browse files Browse the repository at this point in the history
…Handler in CWL
  • Loading branch information
awstools committed Sep 20, 2023
1 parent 24d8dfe commit f2d4554
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 11 deletions.
4 changes: 3 additions & 1 deletion clients/client-cloudwatch-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@
"@smithy/util-defaults-mode-node": "^2.0.10",
"@smithy/util-retry": "^2.0.0",
"@smithy/util-utf8": "^2.0.0",
"tslib": "^2.5.0"
"tslib": "^2.5.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@smithy/service-client-documentation-generator": "^2.0.0",
"@tsconfig/node14": "1.0.3",
"@types/node": "^14.14.31",
"@types/uuid": "^8.3.0",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"rimraf": "3.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface CreateLogGroupCommandOutput extends __MetadataBearer {}

/**
* @public
* <p>Creates a log group with the specified name. You can create up to 20,000 log groups per account.</p>
* <p>Creates a log group with the specified name. You can create up to 1,000,000 log groups per Region per account.</p>
* <p>You must use the following guidelines when naming a log group:</p>
* <ul>
* <li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ export interface PutMetricFilterCommandOutput extends __MetadataBearer {}
* found for
* a dimension is treated as a separate metric and accrues charges as a separate custom metric.
* </p>
* <p>CloudWatch Logs disables a metric filter if it generates 1,000 different name/value pairs for
* your specified dimensions within a certain amount of time. This helps to prevent accidental
* high charges.</p>
* <p>CloudWatch Logs might disable a metric filter if it generates 1,000 different name/value pairs for
* your specified dimensions within one hour.</p>
* <p>You can also set up a billing alarm to alert you if your charges are higher than
* expected. For more information,
* see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface PutQueryDefinitionCommandOutput extends PutQueryDefinitionRespo
* "STRING_VALUE",
* ],
* queryString: "STRING_VALUE", // required
* clientToken: "STRING_VALUE",
* };
* const command = new PutQueryDefinitionCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export interface PutRetentionPolicyCommandOutput extends __MetadataBearer {}
* retention setting until 72 hours after the previous retention period ends. Alternatively,
* wait to change the retention setting until you confirm that the earlier log events are
* deleted. </p>
* <p>When log events reach their retention setting they are marked for deletion. After
* they are marked for deletion, they do not add to your archival storage costs anymore, even if
* they are not actually deleted until later. These log events marked for deletion are also not
* included when you use an API to retrieve the <code>storedBytes</code> value to see how many bytes a log group is storing.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
7 changes: 7 additions & 0 deletions clients/client-cloudwatch-logs/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,13 @@ export interface PutQueryDefinitionRequest {
* For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html">CloudWatch Logs Insights Query Syntax</a>.</p>
*/
queryString: string | undefined;

/**
* @public
* <p>Used as an idempotency token, to avoid returning an exception if the service receives the same request twice because of a network
* error.</p>
*/
clientToken?: string;
}

/**
Expand Down
16 changes: 14 additions & 2 deletions clients/client-cloudwatch-logs/src/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@smithy/types";
import { v4 as generateIdempotencyToken } from "uuid";

import { AssociateKmsKeyCommandInput, AssociateKmsKeyCommandOutput } from "../commands/AssociateKmsKeyCommand";
import { CancelExportTaskCommandInput, CancelExportTaskCommandOutput } from "../commands/CancelExportTaskCommand";
Expand Down Expand Up @@ -725,7 +726,7 @@ export const se_PutQueryDefinitionCommand = async (
): Promise<__HttpRequest> => {
const headers: __HeaderBag = sharedHeaders("PutQueryDefinition");
let body: any;
body = JSON.stringify(_json(input));
body = JSON.stringify(se_PutQueryDefinitionRequest(input, context));
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

Expand Down Expand Up @@ -3844,7 +3845,18 @@ const se_PutMetricFilterRequest = (input: PutMetricFilterRequest, context: __Ser
});
};

// se_PutQueryDefinitionRequest omitted.
/**
* serializeAws_json1_1PutQueryDefinitionRequest
*/
const se_PutQueryDefinitionRequest = (input: PutQueryDefinitionRequest, context: __SerdeContext): any => {
return take(input, {
clientToken: [true, (_) => _ ?? generateIdempotencyToken()],
logGroupNames: _json,
name: [],
queryDefinitionId: [],
queryString: [],
});
};

// se_PutResourcePolicyRequest omitted.

Expand Down
25 changes: 21 additions & 4 deletions codegen/sdk-codegen/aws-models/cloudwatch-logs.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@
"smithy.api#input": {}
}
},
"com.amazonaws.cloudwatchlogs#ClientToken": {
"type": "string",
"traits": {
"smithy.api#length": {
"min": 36,
"max": 128
},
"smithy.api#pattern": "^\\S{36,128}$"
}
},
"com.amazonaws.cloudwatchlogs#CreateExportTask": {
"type": "operation",
"input": {
Expand Down Expand Up @@ -345,7 +355,7 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Creates a log group with the specified name. You can create up to 20,000 log groups per account.</p>\n <p>You must use the following guidelines when naming a log group:</p>\n <ul>\n <li>\n <p>Log group names must be unique within a Region for an Amazon Web Services\n account.</p>\n </li>\n <li>\n <p>Log group names can be between 1 and 512 characters long.</p>\n </li>\n <li>\n <p>Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), \n '/' (forward slash), '.' (period), and '#' (number sign)</p>\n </li>\n </ul>\n <p>When you create a log group, by default the log events in the log group do not expire.\n To set a retention policy so that events expire and are deleted after a specified time, use\n <a href=\"https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html\">PutRetentionPolicy</a>.</p>\n <p>If you associate an KMS key with the log group, ingested data is\n encrypted using the KMS key. This association is stored as long as the data\n encrypted with the KMS key is still within CloudWatch Logs. This enables\n CloudWatch Logs to decrypt this data whenever it is requested.</p>\n <p>If you attempt to associate a KMS key with the log group but the KMS key does not exist or the KMS key is disabled, you receive an\n <code>InvalidParameterException</code> error. </p>\n <important>\n <p>CloudWatch Logs supports only symmetric KMS keys. Do not associate an\n asymmetric KMS key with your log group. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html\">Using\n Symmetric and Asymmetric Keys</a>.</p>\n </important>"
"smithy.api#documentation": "<p>Creates a log group with the specified name. You can create up to 1,000,000 log groups per Region per account.</p>\n <p>You must use the following guidelines when naming a log group:</p>\n <ul>\n <li>\n <p>Log group names must be unique within a Region for an Amazon Web Services\n account.</p>\n </li>\n <li>\n <p>Log group names can be between 1 and 512 characters long.</p>\n </li>\n <li>\n <p>Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), \n '/' (forward slash), '.' (period), and '#' (number sign)</p>\n </li>\n </ul>\n <p>When you create a log group, by default the log events in the log group do not expire.\n To set a retention policy so that events expire and are deleted after a specified time, use\n <a href=\"https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html\">PutRetentionPolicy</a>.</p>\n <p>If you associate an KMS key with the log group, ingested data is\n encrypted using the KMS key. This association is stored as long as the data\n encrypted with the KMS key is still within CloudWatch Logs. This enables\n CloudWatch Logs to decrypt this data whenever it is requested.</p>\n <p>If you attempt to associate a KMS key with the log group but the KMS key does not exist or the KMS key is disabled, you receive an\n <code>InvalidParameterException</code> error. </p>\n <important>\n <p>CloudWatch Logs supports only symmetric KMS keys. Do not associate an\n asymmetric KMS key with your log group. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html\">Using\n Symmetric and Asymmetric Keys</a>.</p>\n </important>"
}
},
"com.amazonaws.cloudwatchlogs#CreateLogGroupRequest": {
Expand Down Expand Up @@ -5009,7 +5019,7 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Creates or updates a metric filter and associates it with the specified log group. With\n metric filters, you can configure rules to extract metric data from log events ingested\n through <a href=\"https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html\">PutLogEvents</a>.</p>\n <p>The maximum number of metric filters that can be associated with a log group is\n 100.</p>\n <p>When you create a metric filter, you can also optionally assign a unit and dimensions\n to the metric that is created.</p>\n <important>\n <p>Metrics extracted from log events are charged as custom metrics.\n To prevent unexpected high charges, do not specify high-cardinality fields such as \n <code>IPAddress</code> or <code>requestID</code> as dimensions. Each different value \n found for \n a dimension is treated as a separate metric and accrues charges as a separate custom metric.\n </p>\n <p>CloudWatch Logs disables a metric filter if it generates 1,000 different name/value pairs for\n your specified dimensions within a certain amount of time. This helps to prevent accidental\n high charges.</p>\n <p>You can also set up a billing alarm to alert you if your charges are higher than \n expected. For more information, \n see <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html\">\n Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges</a>.\n </p>\n </important>"
"smithy.api#documentation": "<p>Creates or updates a metric filter and associates it with the specified log group. With\n metric filters, you can configure rules to extract metric data from log events ingested\n through <a href=\"https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html\">PutLogEvents</a>.</p>\n <p>The maximum number of metric filters that can be associated with a log group is\n 100.</p>\n <p>When you create a metric filter, you can also optionally assign a unit and dimensions\n to the metric that is created.</p>\n <important>\n <p>Metrics extracted from log events are charged as custom metrics.\n To prevent unexpected high charges, do not specify high-cardinality fields such as \n <code>IPAddress</code> or <code>requestID</code> as dimensions. Each different value \n found for \n a dimension is treated as a separate metric and accrues charges as a separate custom metric.\n </p>\n <p>CloudWatch Logs might disable a metric filter if it generates 1,000 different name/value pairs for\n your specified dimensions within one hour.</p>\n <p>You can also set up a billing alarm to alert you if your charges are higher than \n expected. For more information, \n see <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html\">\n Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges</a>.\n </p>\n </important>"
}
},
"com.amazonaws.cloudwatchlogs#PutMetricFilterRequest": {
Expand Down Expand Up @@ -5102,6 +5112,13 @@
"smithy.api#documentation": "<p>The query string to use for this definition. \n For more information, see <a href=\"https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html\">CloudWatch Logs Insights Query Syntax</a>.</p>",
"smithy.api#required": {}
}
},
"clientToken": {
"target": "com.amazonaws.cloudwatchlogs#ClientToken",
"traits": {
"smithy.api#documentation": "<p>Used as an idempotency token, to avoid returning an exception if the service receives the same request twice because of a network\n error.</p>",
"smithy.api#idempotencyToken": {}
}
}
},
"traits": {
Expand Down Expand Up @@ -5202,7 +5219,7 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Sets the retention of the specified log group. With a retention policy, you can\n configure the number of days for which to retain log events in the specified log\n group.</p>\n <note>\n <p>CloudWatch Logs doesn’t immediately delete log events when they reach their retention\n setting. It typically takes up to 72 hours after that before log events are deleted, but in\n rare situations might take longer.</p>\n <p>To illustrate, imagine that you change a log group to have a longer retention setting\n when it contains log events that are past the expiration date, but haven’t been deleted.\n Those log events will take up to 72 hours to be deleted after the new retention date is\n reached. To make sure that log data is deleted permanently, keep a log group at its lower\n retention setting until 72 hours after the previous retention period ends. Alternatively,\n wait to change the retention setting until you confirm that the earlier log events are\n deleted. </p>\n </note>"
"smithy.api#documentation": "<p>Sets the retention of the specified log group. With a retention policy, you can\n configure the number of days for which to retain log events in the specified log\n group.</p>\n <note>\n <p>CloudWatch Logs doesn’t immediately delete log events when they reach their retention\n setting. It typically takes up to 72 hours after that before log events are deleted, but in\n rare situations might take longer.</p>\n <p>To illustrate, imagine that you change a log group to have a longer retention setting\n when it contains log events that are past the expiration date, but haven’t been deleted.\n Those log events will take up to 72 hours to be deleted after the new retention date is\n reached. To make sure that log data is deleted permanently, keep a log group at its lower\n retention setting until 72 hours after the previous retention period ends. Alternatively,\n wait to change the retention setting until you confirm that the earlier log events are\n deleted. </p>\n <p>When log events reach their retention setting they are marked for deletion. After\n they are marked for deletion, they do not add to your archival storage costs anymore, even if \n they are not actually deleted until later. These log events marked for deletion are also not \n included when you use an API to retrieve the <code>storedBytes</code> value to see how many bytes a log group is storing.</p>\n </note>"
}
},
"com.amazonaws.cloudwatchlogs#PutRetentionPolicyRequest": {
Expand Down Expand Up @@ -6504,4 +6521,4 @@
"type": "string"
}
}
}
}

0 comments on commit f2d4554

Please sign in to comment.