Skip to content

Commit

Permalink
feat(client-lookoutmetrics): Adding filters to Alert and adding new U…
Browse files Browse the repository at this point in the history
…pdateAlert API.
  • Loading branch information
awstools committed Jun 14, 2022
1 parent 9c9825e commit d52f9aa
Show file tree
Hide file tree
Showing 7 changed files with 636 additions and 4 deletions.
27 changes: 27 additions & 0 deletions clients/client-lookoutmetrics/src/LookoutMetrics.ts
Expand Up @@ -107,6 +107,7 @@ import {
UntagResourceCommandInput,
UntagResourceCommandOutput,
} from "./commands/UntagResourceCommand";
import { UpdateAlertCommand, UpdateAlertCommandInput, UpdateAlertCommandOutput } from "./commands/UpdateAlertCommand";
import {
UpdateAnomalyDetectorCommand,
UpdateAnomalyDetectorCommandInput,
Expand Down Expand Up @@ -935,6 +936,32 @@ export class LookoutMetrics extends LookoutMetricsClient {
}
}

/**
* <p>Make changes to an existing alert.</p>
*/
public updateAlert(args: UpdateAlertCommandInput, options?: __HttpHandlerOptions): Promise<UpdateAlertCommandOutput>;
public updateAlert(args: UpdateAlertCommandInput, cb: (err: any, data?: UpdateAlertCommandOutput) => void): void;
public updateAlert(
args: UpdateAlertCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: UpdateAlertCommandOutput) => void
): void;
public updateAlert(
args: UpdateAlertCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UpdateAlertCommandOutput) => void),
cb?: (err: any, data?: UpdateAlertCommandOutput) => void
): Promise<UpdateAlertCommandOutput> | void {
const command = new UpdateAlertCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Updates a detector. After activation, you can only change a detector's ingestion delay and description.</p>
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-lookoutmetrics/src/LookoutMetricsClient.ts
Expand Up @@ -118,6 +118,7 @@ import {
import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
import { UpdateAlertCommandInput, UpdateAlertCommandOutput } from "./commands/UpdateAlertCommand";
import {
UpdateAnomalyDetectorCommandInput,
UpdateAnomalyDetectorCommandOutput,
Expand Down Expand Up @@ -152,6 +153,7 @@ export type ServiceInputTypes =
| PutFeedbackCommandInput
| TagResourceCommandInput
| UntagResourceCommandInput
| UpdateAlertCommandInput
| UpdateAnomalyDetectorCommandInput
| UpdateMetricSetCommandInput;

Expand Down Expand Up @@ -182,6 +184,7 @@ export type ServiceOutputTypes =
| PutFeedbackCommandOutput
| TagResourceCommandOutput
| UntagResourceCommandOutput
| UpdateAlertCommandOutput
| UpdateAnomalyDetectorCommandOutput
| UpdateMetricSetCommandOutput;

Expand Down
96 changes: 96 additions & 0 deletions clients/client-lookoutmetrics/src/commands/UpdateAlertCommand.ts
@@ -0,0 +1,96 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { LookoutMetricsClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../LookoutMetricsClient";
import { UpdateAlertRequest, UpdateAlertResponse } from "../models/models_0";
import {
deserializeAws_restJson1UpdateAlertCommand,
serializeAws_restJson1UpdateAlertCommand,
} from "../protocols/Aws_restJson1";

export interface UpdateAlertCommandInput extends UpdateAlertRequest {}
export interface UpdateAlertCommandOutput extends UpdateAlertResponse, __MetadataBearer {}

/**
* <p>Make changes to an existing alert.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { LookoutMetricsClient, UpdateAlertCommand } from "@aws-sdk/client-lookoutmetrics"; // ES Modules import
* // const { LookoutMetricsClient, UpdateAlertCommand } = require("@aws-sdk/client-lookoutmetrics"); // CommonJS import
* const client = new LookoutMetricsClient(config);
* const command = new UpdateAlertCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link UpdateAlertCommandInput} for command's `input` shape.
* @see {@link UpdateAlertCommandOutput} for command's `response` shape.
* @see {@link LookoutMetricsClientResolvedConfig | config} for LookoutMetricsClient's `config` shape.
*
*/
export class UpdateAlertCommand extends $Command<
UpdateAlertCommandInput,
UpdateAlertCommandOutput,
LookoutMetricsClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: UpdateAlertCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: LookoutMetricsClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<UpdateAlertCommandInput, UpdateAlertCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "LookoutMetricsClient";
const commandName = "UpdateAlertCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: UpdateAlertRequest.filterSensitiveLog,
outputFilterSensitiveLog: UpdateAlertResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: UpdateAlertCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1UpdateAlertCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<UpdateAlertCommandOutput> {
return deserializeAws_restJson1UpdateAlertCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-lookoutmetrics/src/commands/index.ts
Expand Up @@ -25,5 +25,6 @@ export * from "./ListTagsForResourceCommand";
export * from "./PutFeedbackCommand";
export * from "./TagResourceCommand";
export * from "./UntagResourceCommand";
export * from "./UpdateAlertCommand";
export * from "./UpdateAnomalyDetectorCommand";
export * from "./UpdateMetricSetCommand";
126 changes: 125 additions & 1 deletion clients/client-lookoutmetrics/src/models/models_0.ts
Expand Up @@ -71,6 +71,20 @@ export interface SNSConfiguration {

/**
* <p>The format of the SNS topic.</p>
* <ul>
* <li>
* <p>
* <code>JSON</code> – Send JSON alerts with an anomaly ID and a link to the anomaly detail page. This is the default.</p>
* </li>
* <li>
* <p>
* <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>
* </li>
* <li>
* <p>
* <code>SHORT_TEXT</code> – Send human-readable alerts with a link to the anomaly detail page. We recommend this for SMS.</p>
* </li>
* </ul>
*/
SnsFormat?: SnsFormat | string;
}
Expand Down Expand Up @@ -310,6 +324,54 @@ export enum AggregationFunction {
SUM = "SUM",
}

/**
* <p>The dimension filter, containing DimensionName and DimensionValueList.</p>
*/
export interface DimensionFilter {
/**
* <p>The name of the dimension to filter on.</p>
*/
DimensionName?: string;

/**
* <p>The list of values for the dimension specified in DimensionName that you want to filter on.</p>
*/
DimensionValueList?: string[];
}

export namespace DimensionFilter {
/**
* @internal
*/
export const filterSensitiveLog = (obj: DimensionFilter): any => ({
...obj,
});
}

/**
* <p>The configuration of the alert filters.</p>
*/
export interface AlertFilters {
/**
* <p>The list of measures that you want to get alerts for.</p>
*/
MetricList?: string[];

/**
* <p>The list of DimensionFilter objects that are used for dimension-based filtering.</p>
*/
DimensionFilterList?: DimensionFilter[];
}

export namespace AlertFilters {
/**
* @internal
*/
export const filterSensitiveLog = (obj: AlertFilters): any => ({
...obj,
});
}

export enum AlertStatus {
ACTIVE = "ACTIVE",
INACTIVE = "INACTIVE",
Expand Down Expand Up @@ -373,6 +435,11 @@ export interface Alert {
* <p>The time at which the alert was created.</p>
*/
CreationTime?: Date;

/**
* <p>The configuration of the alert filters, containing MetricList and DimensionFilter.</p>
*/
AlertFilters?: AlertFilters;
}

export namespace Alert {
Expand Down Expand Up @@ -1096,7 +1163,7 @@ export interface CreateAlertRequest {
/**
* <p>An integer from 0 to 100 specifying the alert sensitivity threshold.</p>
*/
AlertSensitivityThreshold: number | undefined;
AlertSensitivityThreshold?: number;

/**
* <p>A description of the alert.</p>
Expand All @@ -1117,6 +1184,11 @@ export interface CreateAlertRequest {
* <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>
*/
Tags?: Record<string, string>;

/**
* <p>The configuration of the alert filters, containing MetricList and DimensionFilterList.</p>
*/
AlertFilters?: AlertFilters;
}

export namespace CreateAlertRequest {
Expand Down Expand Up @@ -3068,6 +3140,58 @@ export namespace UntagResourceResponse {
});
}

export interface UpdateAlertRequest {
/**
* <p>The ARN of the alert to update.</p>
*/
AlertArn: string | undefined;

/**
* <p>A description of the alert.</p>
*/
AlertDescription?: string;

/**
* <p>An integer from 0 to 100 specifying the alert sensitivity threshold.</p>
*/
AlertSensitivityThreshold?: number;

/**
* <p>Action that will be triggered when there is an alert.</p>
*/
Action?: Action;

/**
* <p>The configuration of the alert filters, containing MetricList and DimensionFilterList.</p>
*/
AlertFilters?: AlertFilters;
}

export namespace UpdateAlertRequest {
/**
* @internal
*/
export const filterSensitiveLog = (obj: UpdateAlertRequest): any => ({
...obj,
});
}

export interface UpdateAlertResponse {
/**
* <p>The ARN of the updated alert.</p>
*/
AlertArn?: string;
}

export namespace UpdateAlertResponse {
/**
* @internal
*/
export const filterSensitiveLog = (obj: UpdateAlertResponse): any => ({
...obj,
});
}

export interface UpdateAnomalyDetectorRequest {
/**
* <p>The ARN of the detector to update.</p>
Expand Down

0 comments on commit d52f9aa

Please sign in to comment.