Skip to content

Commit d52f9aa

Browse files
author
awstools
committed
feat(client-lookoutmetrics): Adding filters to Alert and adding new UpdateAlert API.
1 parent 9c9825e commit d52f9aa

File tree

7 files changed

+636
-4
lines changed

7 files changed

+636
-4
lines changed

clients/client-lookoutmetrics/src/LookoutMetrics.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import {
107107
UntagResourceCommandInput,
108108
UntagResourceCommandOutput,
109109
} from "./commands/UntagResourceCommand";
110+
import { UpdateAlertCommand, UpdateAlertCommandInput, UpdateAlertCommandOutput } from "./commands/UpdateAlertCommand";
110111
import {
111112
UpdateAnomalyDetectorCommand,
112113
UpdateAnomalyDetectorCommandInput,
@@ -935,6 +936,32 @@ export class LookoutMetrics extends LookoutMetricsClient {
935936
}
936937
}
937938

939+
/**
940+
* <p>Make changes to an existing alert.</p>
941+
*/
942+
public updateAlert(args: UpdateAlertCommandInput, options?: __HttpHandlerOptions): Promise<UpdateAlertCommandOutput>;
943+
public updateAlert(args: UpdateAlertCommandInput, cb: (err: any, data?: UpdateAlertCommandOutput) => void): void;
944+
public updateAlert(
945+
args: UpdateAlertCommandInput,
946+
options: __HttpHandlerOptions,
947+
cb: (err: any, data?: UpdateAlertCommandOutput) => void
948+
): void;
949+
public updateAlert(
950+
args: UpdateAlertCommandInput,
951+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UpdateAlertCommandOutput) => void),
952+
cb?: (err: any, data?: UpdateAlertCommandOutput) => void
953+
): Promise<UpdateAlertCommandOutput> | void {
954+
const command = new UpdateAlertCommand(args);
955+
if (typeof optionsOrCb === "function") {
956+
this.send(command, optionsOrCb);
957+
} else if (typeof cb === "function") {
958+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
959+
this.send(command, optionsOrCb || {}, cb);
960+
} else {
961+
return this.send(command, optionsOrCb);
962+
}
963+
}
964+
938965
/**
939966
* <p>Updates a detector. After activation, you can only change a detector's ingestion delay and description.</p>
940967
*/

clients/client-lookoutmetrics/src/LookoutMetricsClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ import {
118118
import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
119119
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
120120
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
121+
import { UpdateAlertCommandInput, UpdateAlertCommandOutput } from "./commands/UpdateAlertCommand";
121122
import {
122123
UpdateAnomalyDetectorCommandInput,
123124
UpdateAnomalyDetectorCommandOutput,
@@ -152,6 +153,7 @@ export type ServiceInputTypes =
152153
| PutFeedbackCommandInput
153154
| TagResourceCommandInput
154155
| UntagResourceCommandInput
156+
| UpdateAlertCommandInput
155157
| UpdateAnomalyDetectorCommandInput
156158
| UpdateMetricSetCommandInput;
157159

@@ -182,6 +184,7 @@ export type ServiceOutputTypes =
182184
| PutFeedbackCommandOutput
183185
| TagResourceCommandOutput
184186
| UntagResourceCommandOutput
187+
| UpdateAlertCommandOutput
185188
| UpdateAnomalyDetectorCommandOutput
186189
| UpdateMetricSetCommandOutput;
187190

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { LookoutMetricsClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../LookoutMetricsClient";
16+
import { UpdateAlertRequest, UpdateAlertResponse } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1UpdateAlertCommand,
19+
serializeAws_restJson1UpdateAlertCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface UpdateAlertCommandInput extends UpdateAlertRequest {}
23+
export interface UpdateAlertCommandOutput extends UpdateAlertResponse, __MetadataBearer {}
24+
25+
/**
26+
* <p>Make changes to an existing alert.</p>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { LookoutMetricsClient, UpdateAlertCommand } from "@aws-sdk/client-lookoutmetrics"; // ES Modules import
31+
* // const { LookoutMetricsClient, UpdateAlertCommand } = require("@aws-sdk/client-lookoutmetrics"); // CommonJS import
32+
* const client = new LookoutMetricsClient(config);
33+
* const command = new UpdateAlertCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link UpdateAlertCommandInput} for command's `input` shape.
38+
* @see {@link UpdateAlertCommandOutput} for command's `response` shape.
39+
* @see {@link LookoutMetricsClientResolvedConfig | config} for LookoutMetricsClient's `config` shape.
40+
*
41+
*/
42+
export class UpdateAlertCommand extends $Command<
43+
UpdateAlertCommandInput,
44+
UpdateAlertCommandOutput,
45+
LookoutMetricsClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: UpdateAlertCommandInput) {
51+
// Start section: command_constructor
52+
super();
53+
// End section: command_constructor
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
resolveMiddleware(
60+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
61+
configuration: LookoutMetricsClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<UpdateAlertCommandInput, UpdateAlertCommandOutput> {
64+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
65+
66+
const stack = clientStack.concat(this.middlewareStack);
67+
68+
const { logger } = configuration;
69+
const clientName = "LookoutMetricsClient";
70+
const commandName = "UpdateAlertCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: UpdateAlertRequest.filterSensitiveLog,
76+
outputFilterSensitiveLog: UpdateAlertResponse.filterSensitiveLog,
77+
};
78+
const { requestHandler } = configuration;
79+
return stack.resolve(
80+
(request: FinalizeHandlerArguments<any>) =>
81+
requestHandler.handle(request.request as __HttpRequest, options || {}),
82+
handlerExecutionContext
83+
);
84+
}
85+
86+
private serialize(input: UpdateAlertCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_restJson1UpdateAlertCommand(input, context);
88+
}
89+
90+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<UpdateAlertCommandOutput> {
91+
return deserializeAws_restJson1UpdateAlertCommand(output, context);
92+
}
93+
94+
// Start section: command_body_extra
95+
// End section: command_body_extra
96+
}

clients/client-lookoutmetrics/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export * from "./ListTagsForResourceCommand";
2525
export * from "./PutFeedbackCommand";
2626
export * from "./TagResourceCommand";
2727
export * from "./UntagResourceCommand";
28+
export * from "./UpdateAlertCommand";
2829
export * from "./UpdateAnomalyDetectorCommand";
2930
export * from "./UpdateMetricSetCommand";

clients/client-lookoutmetrics/src/models/models_0.ts

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ export interface SNSConfiguration {
7171

7272
/**
7373
* <p>The format of the SNS topic.</p>
74+
* <ul>
75+
* <li>
76+
* <p>
77+
* <code>JSON</code> – Send JSON alerts with an anomaly ID and a link to the anomaly detail page. This is the default.</p>
78+
* </li>
79+
* <li>
80+
* <p>
81+
* <code>LONG_TEXT</code> – Send human-readable alerts with information about the impacted timeseries and a link to the anomaly detail page. We recommend this for email.</p>
82+
* </li>
83+
* <li>
84+
* <p>
85+
* <code>SHORT_TEXT</code> – Send human-readable alerts with a link to the anomaly detail page. We recommend this for SMS.</p>
86+
* </li>
87+
* </ul>
7488
*/
7589
SnsFormat?: SnsFormat | string;
7690
}
@@ -310,6 +324,54 @@ export enum AggregationFunction {
310324
SUM = "SUM",
311325
}
312326

327+
/**
328+
* <p>The dimension filter, containing DimensionName and DimensionValueList.</p>
329+
*/
330+
export interface DimensionFilter {
331+
/**
332+
* <p>The name of the dimension to filter on.</p>
333+
*/
334+
DimensionName?: string;
335+
336+
/**
337+
* <p>The list of values for the dimension specified in DimensionName that you want to filter on.</p>
338+
*/
339+
DimensionValueList?: string[];
340+
}
341+
342+
export namespace DimensionFilter {
343+
/**
344+
* @internal
345+
*/
346+
export const filterSensitiveLog = (obj: DimensionFilter): any => ({
347+
...obj,
348+
});
349+
}
350+
351+
/**
352+
* <p>The configuration of the alert filters.</p>
353+
*/
354+
export interface AlertFilters {
355+
/**
356+
* <p>The list of measures that you want to get alerts for.</p>
357+
*/
358+
MetricList?: string[];
359+
360+
/**
361+
* <p>The list of DimensionFilter objects that are used for dimension-based filtering.</p>
362+
*/
363+
DimensionFilterList?: DimensionFilter[];
364+
}
365+
366+
export namespace AlertFilters {
367+
/**
368+
* @internal
369+
*/
370+
export const filterSensitiveLog = (obj: AlertFilters): any => ({
371+
...obj,
372+
});
373+
}
374+
313375
export enum AlertStatus {
314376
ACTIVE = "ACTIVE",
315377
INACTIVE = "INACTIVE",
@@ -373,6 +435,11 @@ export interface Alert {
373435
* <p>The time at which the alert was created.</p>
374436
*/
375437
CreationTime?: Date;
438+
439+
/**
440+
* <p>The configuration of the alert filters, containing MetricList and DimensionFilter.</p>
441+
*/
442+
AlertFilters?: AlertFilters;
376443
}
377444

378445
export namespace Alert {
@@ -1096,7 +1163,7 @@ export interface CreateAlertRequest {
10961163
/**
10971164
* <p>An integer from 0 to 100 specifying the alert sensitivity threshold.</p>
10981165
*/
1099-
AlertSensitivityThreshold: number | undefined;
1166+
AlertSensitivityThreshold?: number;
11001167

11011168
/**
11021169
* <p>A description of the alert.</p>
@@ -1117,6 +1184,11 @@ export interface CreateAlertRequest {
11171184
* <p>A list of <a href="https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html">tags</a> to apply to the alert.</p>
11181185
*/
11191186
Tags?: Record<string, string>;
1187+
1188+
/**
1189+
* <p>The configuration of the alert filters, containing MetricList and DimensionFilterList.</p>
1190+
*/
1191+
AlertFilters?: AlertFilters;
11201192
}
11211193

11221194
export namespace CreateAlertRequest {
@@ -3068,6 +3140,58 @@ export namespace UntagResourceResponse {
30683140
});
30693141
}
30703142

3143+
export interface UpdateAlertRequest {
3144+
/**
3145+
* <p>The ARN of the alert to update.</p>
3146+
*/
3147+
AlertArn: string | undefined;
3148+
3149+
/**
3150+
* <p>A description of the alert.</p>
3151+
*/
3152+
AlertDescription?: string;
3153+
3154+
/**
3155+
* <p>An integer from 0 to 100 specifying the alert sensitivity threshold.</p>
3156+
*/
3157+
AlertSensitivityThreshold?: number;
3158+
3159+
/**
3160+
* <p>Action that will be triggered when there is an alert.</p>
3161+
*/
3162+
Action?: Action;
3163+
3164+
/**
3165+
* <p>The configuration of the alert filters, containing MetricList and DimensionFilterList.</p>
3166+
*/
3167+
AlertFilters?: AlertFilters;
3168+
}
3169+
3170+
export namespace UpdateAlertRequest {
3171+
/**
3172+
* @internal
3173+
*/
3174+
export const filterSensitiveLog = (obj: UpdateAlertRequest): any => ({
3175+
...obj,
3176+
});
3177+
}
3178+
3179+
export interface UpdateAlertResponse {
3180+
/**
3181+
* <p>The ARN of the updated alert.</p>
3182+
*/
3183+
AlertArn?: string;
3184+
}
3185+
3186+
export namespace UpdateAlertResponse {
3187+
/**
3188+
* @internal
3189+
*/
3190+
export const filterSensitiveLog = (obj: UpdateAlertResponse): any => ({
3191+
...obj,
3192+
});
3193+
}
3194+
30713195
export interface UpdateAnomalyDetectorRequest {
30723196
/**
30733197
* <p>The ARN of the detector to update.</p>

0 commit comments

Comments
 (0)