Skip to content

Commit

Permalink
feat(client-cloudwatch): Adds support for filtering by metric names i…
Browse files Browse the repository at this point in the history
…n CloudWatch Metric Streams.
  • Loading branch information
awstools committed May 4, 2023
1 parent fd48f2d commit 6666673
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 8 deletions.
Expand Up @@ -50,11 +50,17 @@ export interface GetMetricStreamCommandOutput extends GetMetricStreamOutput, __M
* // IncludeFilters: [ // MetricStreamFilters
* // { // MetricStreamFilter
* // Namespace: "STRING_VALUE",
* // MetricNames: [ // MetricStreamFilterMetricNames
* // "STRING_VALUE",
* // ],
* // },
* // ],
* // ExcludeFilters: [
* // {
* // Namespace: "STRING_VALUE",
* // MetricNames: [
* // "STRING_VALUE",
* // ],
* // },
* // ],
* // FirehoseArn: "STRING_VALUE",
Expand Down
Expand Up @@ -58,6 +58,7 @@ export interface PutMetricAlarmCommandOutput extends __MetadataBearer {}
* are called <code>AWSServiceRoleForCloudWatchEvents</code> and
* <code>AWSServiceRoleForCloudWatchAlarms_ActionSSM</code>.
* For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role">Amazon Web Services service-linked role</a>.</p>
* <p>Each <code>PutMetricAlarm</code> action has a maximum uncompressed payload of 120 KB.</p>
* <p>
* <b>Cross-account alarms</b>
* </p>
Expand Down
Expand Up @@ -77,11 +77,17 @@ export interface PutMetricStreamCommandOutput extends PutMetricStreamOutput, __M
* IncludeFilters: [ // MetricStreamFilters
* { // MetricStreamFilter
* Namespace: "STRING_VALUE",
* MetricNames: [ // MetricStreamFilterMetricNames
* "STRING_VALUE",
* ],
* },
* ],
* ExcludeFilters: [
* {
* Namespace: "STRING_VALUE",
* MetricNames: [
* "STRING_VALUE",
* ],
* },
* ],
* FirehoseArn: "STRING_VALUE", // required
Expand Down
30 changes: 22 additions & 8 deletions clients/client-cloudwatch/src/models/models_0.ts
Expand Up @@ -2467,16 +2467,30 @@ export interface GetMetricStreamInput {

/**
* @public
* <p>This structure contains the name of one of the metric namespaces that is listed in
* a filter of a metric stream.</p>
* <p>The namespace can contain only ASCII printable characters (ASCII range 32 through 126). It must
* contain at least one non-whitespace character.</p>
* <p>This structure contains a metric namespace and optionally, a list of metric names,
* to either include in a metric stream or exclude from
* a metric stream.</p>
* <p>A metric stream's filters can include up to 1000 total names. This limit
* applies to the sum of namespace names and metric names in the filters. For example,
* this could include 10 metric namespace filters with 99 metrics each, or 20 namespace filters
* with 49 metrics specified in each filter.</p>
*/
export interface MetricStreamFilter {
/**
* <p>The name of the metric namespace in the filter.</p>
* <p>The name of the metric namespace for this filter.</p>
* <p>The namespace can contain only ASCII printable characters (ASCII range 32 through 126). It must
* contain at least one non-whitespace character.</p>
*/
Namespace?: string;

/**
* <p>The names of the metrics to either include or exclude from the metric stream. </p>
* <p>If you omit this parameter, all metrics in the namespace are included or excluded,
* depending on whether this filter is specified as an exclude filter or an include filter.</p>
* <p>Each metric name can contain only ASCII printable characters (ASCII range 32 through 126).
* Each metric name must contain at least one non-whitespace character.</p>
*/
MetricNames?: string[];
}

/**
Expand Down Expand Up @@ -3635,7 +3649,7 @@ export interface PutMetricAlarmInput {
* </li>
* </ul>
* <p>
* <b>SSN notification action:</b>
* <b>SNS notification action:</b>
* </p>
* <ul>
* <li>
Expand Down Expand Up @@ -3725,7 +3739,7 @@ export interface PutMetricAlarmInput {
* </li>
* </ul>
* <p>
* <b>SSN notification action:</b>
* <b>SNS notification action:</b>
* </p>
* <ul>
* <li>
Expand Down Expand Up @@ -3815,7 +3829,7 @@ export interface PutMetricAlarmInput {
* </li>
* </ul>
* <p>
* <b>SSN notification action:</b>
* <b>SNS notification action:</b>
* </p>
* <ul>
* <li>
Expand Down
45 changes: 45 additions & 0 deletions clients/client-cloudwatch/src/protocols/Aws_query.ts
Expand Up @@ -4060,6 +4060,32 @@ const se_MetricStreamFilter = (input: MetricStreamFilter, context: __SerdeContex
if (input.Namespace != null) {
entries["Namespace"] = input.Namespace;
}
if (input.MetricNames != null) {
const memberEntries = se_MetricStreamFilterMetricNames(input.MetricNames, context);
if (input.MetricNames?.length === 0) {
entries.MetricNames = [];
}
Object.entries(memberEntries).forEach(([key, value]) => {
const loc = `MetricNames.${key}`;
entries[loc] = value;
});
}
return entries;
};

/**
* serializeAws_queryMetricStreamFilterMetricNames
*/
const se_MetricStreamFilterMetricNames = (input: string[], context: __SerdeContext): any => {
const entries: any = {};
let counter = 1;
for (const entry of input) {
if (entry === null) {
continue;
}
entries[`member.${counter}`] = entry;
counter++;
}
return entries;
};

Expand Down Expand Up @@ -6294,9 +6320,28 @@ const de_MetricStreamFilter = (output: any, context: __SerdeContext): MetricStre
if (output["Namespace"] !== undefined) {
contents.Namespace = __expectString(output["Namespace"]);
}
if (output.MetricNames === "") {
contents.MetricNames = [];
} else if (output["MetricNames"] !== undefined && output["MetricNames"]["member"] !== undefined) {
contents.MetricNames = de_MetricStreamFilterMetricNames(
__getArrayIfSingleItem(output["MetricNames"]["member"]),
context
);
}
return contents;
};

/**
* deserializeAws_queryMetricStreamFilterMetricNames
*/
const de_MetricStreamFilterMetricNames = (output: any, context: __SerdeContext): string[] => {
return (output || [])
.filter((e: any) => e != null)
.map((entry: any) => {
return __expectString(entry) as any;
});
};

/**
* deserializeAws_queryMetricStreamFilters
*/
Expand Down

0 comments on commit 6666673

Please sign in to comment.