Skip to content

Commit

Permalink
feat(client-cloudwatch): Add support for managed Contributor Insights…
Browse files Browse the repository at this point in the history
… Rules
  • Loading branch information
awstools committed Aug 18, 2022
1 parent 1efffd9 commit 101b4c2
Show file tree
Hide file tree
Showing 11 changed files with 1,264 additions and 18 deletions.
96 changes: 96 additions & 0 deletions clients/client-cloudwatch/src/CloudWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ import {
ListDashboardsCommandInput,
ListDashboardsCommandOutput,
} from "./commands/ListDashboardsCommand";
import {
ListManagedInsightRulesCommand,
ListManagedInsightRulesCommandInput,
ListManagedInsightRulesCommandOutput,
} from "./commands/ListManagedInsightRulesCommand";
import { ListMetricsCommand, ListMetricsCommandInput, ListMetricsCommandOutput } from "./commands/ListMetricsCommand";
import {
ListMetricStreamsCommand,
Expand Down Expand Up @@ -138,6 +143,11 @@ import {
PutInsightRuleCommandInput,
PutInsightRuleCommandOutput,
} from "./commands/PutInsightRuleCommand";
import {
PutManagedInsightRulesCommand,
PutManagedInsightRulesCommandInput,
PutManagedInsightRulesCommandOutput,
} from "./commands/PutManagedInsightRulesCommand";
import {
PutMetricAlarmCommand,
PutMetricAlarmCommandInput,
Expand Down Expand Up @@ -1079,6 +1089,44 @@ export class CloudWatch extends CloudWatchClient {
}
}

/**
* <p>
* Returns a list
* that contains the number
* of managed Contributor Insights rules
* in your account.
*
* </p>
*/
public listManagedInsightRules(
args: ListManagedInsightRulesCommandInput,
options?: __HttpHandlerOptions
): Promise<ListManagedInsightRulesCommandOutput>;
public listManagedInsightRules(
args: ListManagedInsightRulesCommandInput,
cb: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
): void;
public listManagedInsightRules(
args: ListManagedInsightRulesCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
): void;
public listManagedInsightRules(
args: ListManagedInsightRulesCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListManagedInsightRulesCommandOutput) => void),
cb?: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
): Promise<ListManagedInsightRulesCommandOutput> | void {
const command = new ListManagedInsightRulesCommand(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>List the specified metrics. You can use the returned metrics with
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html">GetMetricData</a> or
Expand Down Expand Up @@ -1367,6 +1415,54 @@ export class CloudWatch extends CloudWatchClient {
}
}

/**
* <p>
* Creates a managed Contributor Insights rule
* for a specified Amazon Web Services resource.
* When you enable a managed rule,
* you create a Contributor Insights rule
* that collects data
* from Amazon Web Services services.
* You cannot edit these rules
* with <code>PutInsightRule</code>.
* The rules can be enabled, disabled, and deleted using <code>EnableInsightRules</code>, <code>DisableInsightRules</code>, and <code>DeleteInsightRules</code>.
* If a previously created managed rule is currently disabled,
* a subsequent call
* to this API will re-enable it.
* Use <code>ListManagedInsightRules</code>
* to describe all available rules.
*
* </p>
*/
public putManagedInsightRules(
args: PutManagedInsightRulesCommandInput,
options?: __HttpHandlerOptions
): Promise<PutManagedInsightRulesCommandOutput>;
public putManagedInsightRules(
args: PutManagedInsightRulesCommandInput,
cb: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
): void;
public putManagedInsightRules(
args: PutManagedInsightRulesCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
): void;
public putManagedInsightRules(
args: PutManagedInsightRulesCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutManagedInsightRulesCommandOutput) => void),
cb?: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
): Promise<PutManagedInsightRulesCommandOutput> | void {
const command = new PutManagedInsightRulesCommand(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>Creates or updates an alarm and associates it with the specified metric, metric math expression,
* or anomaly detection model.</p>
Expand Down
12 changes: 12 additions & 0 deletions clients/client-cloudwatch/src/CloudWatchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ import {
GetMetricWidgetImageCommandOutput,
} from "./commands/GetMetricWidgetImageCommand";
import { ListDashboardsCommandInput, ListDashboardsCommandOutput } from "./commands/ListDashboardsCommand";
import {
ListManagedInsightRulesCommandInput,
ListManagedInsightRulesCommandOutput,
} from "./commands/ListManagedInsightRulesCommand";
import { ListMetricsCommandInput, ListMetricsCommandOutput } from "./commands/ListMetricsCommand";
import { ListMetricStreamsCommandInput, ListMetricStreamsCommandOutput } from "./commands/ListMetricStreamsCommand";
import {
Expand All @@ -114,6 +118,10 @@ import { PutAnomalyDetectorCommandInput, PutAnomalyDetectorCommandOutput } from
import { PutCompositeAlarmCommandInput, PutCompositeAlarmCommandOutput } from "./commands/PutCompositeAlarmCommand";
import { PutDashboardCommandInput, PutDashboardCommandOutput } from "./commands/PutDashboardCommand";
import { PutInsightRuleCommandInput, PutInsightRuleCommandOutput } from "./commands/PutInsightRuleCommand";
import {
PutManagedInsightRulesCommandInput,
PutManagedInsightRulesCommandOutput,
} from "./commands/PutManagedInsightRulesCommand";
import { PutMetricAlarmCommandInput, PutMetricAlarmCommandOutput } from "./commands/PutMetricAlarmCommand";
import { PutMetricDataCommandInput, PutMetricDataCommandOutput } from "./commands/PutMetricDataCommand";
import { PutMetricStreamCommandInput, PutMetricStreamCommandOutput } from "./commands/PutMetricStreamCommand";
Expand Down Expand Up @@ -146,13 +154,15 @@ export type ServiceInputTypes =
| GetMetricStreamCommandInput
| GetMetricWidgetImageCommandInput
| ListDashboardsCommandInput
| ListManagedInsightRulesCommandInput
| ListMetricStreamsCommandInput
| ListMetricsCommandInput
| ListTagsForResourceCommandInput
| PutAnomalyDetectorCommandInput
| PutCompositeAlarmCommandInput
| PutDashboardCommandInput
| PutInsightRuleCommandInput
| PutManagedInsightRulesCommandInput
| PutMetricAlarmCommandInput
| PutMetricDataCommandInput
| PutMetricStreamCommandInput
Expand Down Expand Up @@ -184,13 +194,15 @@ export type ServiceOutputTypes =
| GetMetricStreamCommandOutput
| GetMetricWidgetImageCommandOutput
| ListDashboardsCommandOutput
| ListManagedInsightRulesCommandOutput
| ListMetricStreamsCommandOutput
| ListMetricsCommandOutput
| ListTagsForResourceCommandOutput
| PutAnomalyDetectorCommandOutput
| PutCompositeAlarmCommandOutput
| PutDashboardCommandOutput
| PutInsightRuleCommandOutput
| PutManagedInsightRulesCommandOutput
| PutMetricAlarmCommandOutput
| PutMetricDataCommandOutput
| PutMetricStreamCommandOutput
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// 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 { CloudWatchClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudWatchClient";
import {
ListManagedInsightRulesInput,
ListManagedInsightRulesInputFilterSensitiveLog,
ListManagedInsightRulesOutput,
ListManagedInsightRulesOutputFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_queryListManagedInsightRulesCommand,
serializeAws_queryListManagedInsightRulesCommand,
} from "../protocols/Aws_query";

export interface ListManagedInsightRulesCommandInput extends ListManagedInsightRulesInput {}
export interface ListManagedInsightRulesCommandOutput extends ListManagedInsightRulesOutput, __MetadataBearer {}

/**
* <p>
* Returns a list
* that contains the number
* of managed Contributor Insights rules
* in your account.
*
* </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CloudWatchClient, ListManagedInsightRulesCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
* // const { CloudWatchClient, ListManagedInsightRulesCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
* const client = new CloudWatchClient(config);
* const command = new ListManagedInsightRulesCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link ListManagedInsightRulesCommandInput} for command's `input` shape.
* @see {@link ListManagedInsightRulesCommandOutput} for command's `response` shape.
* @see {@link CloudWatchClientResolvedConfig | config} for CloudWatchClient's `config` shape.
*
*/
export class ListManagedInsightRulesCommand extends $Command<
ListManagedInsightRulesCommandInput,
ListManagedInsightRulesCommandOutput,
CloudWatchClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

const { logger } = configuration;
const clientName = "CloudWatchClient";
const commandName = "ListManagedInsightRulesCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: ListManagedInsightRulesInputFilterSensitiveLog,
outputFilterSensitiveLog: ListManagedInsightRulesOutputFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Loading

0 comments on commit 101b4c2

Please sign in to comment.