Skip to content

Commit 101b4c2

Browse files
author
awstools
committed
feat(client-cloudwatch): Add support for managed Contributor Insights Rules
1 parent 1efffd9 commit 101b4c2

File tree

11 files changed

+1264
-18
lines changed

11 files changed

+1264
-18
lines changed

clients/client-cloudwatch/src/CloudWatch.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ import {
107107
ListDashboardsCommandInput,
108108
ListDashboardsCommandOutput,
109109
} from "./commands/ListDashboardsCommand";
110+
import {
111+
ListManagedInsightRulesCommand,
112+
ListManagedInsightRulesCommandInput,
113+
ListManagedInsightRulesCommandOutput,
114+
} from "./commands/ListManagedInsightRulesCommand";
110115
import { ListMetricsCommand, ListMetricsCommandInput, ListMetricsCommandOutput } from "./commands/ListMetricsCommand";
111116
import {
112117
ListMetricStreamsCommand,
@@ -138,6 +143,11 @@ import {
138143
PutInsightRuleCommandInput,
139144
PutInsightRuleCommandOutput,
140145
} from "./commands/PutInsightRuleCommand";
146+
import {
147+
PutManagedInsightRulesCommand,
148+
PutManagedInsightRulesCommandInput,
149+
PutManagedInsightRulesCommandOutput,
150+
} from "./commands/PutManagedInsightRulesCommand";
141151
import {
142152
PutMetricAlarmCommand,
143153
PutMetricAlarmCommandInput,
@@ -1079,6 +1089,44 @@ export class CloudWatch extends CloudWatchClient {
10791089
}
10801090
}
10811091

1092+
/**
1093+
* <p>
1094+
* Returns a list
1095+
* that contains the number
1096+
* of managed Contributor Insights rules
1097+
* in your account.
1098+
*
1099+
* </p>
1100+
*/
1101+
public listManagedInsightRules(
1102+
args: ListManagedInsightRulesCommandInput,
1103+
options?: __HttpHandlerOptions
1104+
): Promise<ListManagedInsightRulesCommandOutput>;
1105+
public listManagedInsightRules(
1106+
args: ListManagedInsightRulesCommandInput,
1107+
cb: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
1108+
): void;
1109+
public listManagedInsightRules(
1110+
args: ListManagedInsightRulesCommandInput,
1111+
options: __HttpHandlerOptions,
1112+
cb: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
1113+
): void;
1114+
public listManagedInsightRules(
1115+
args: ListManagedInsightRulesCommandInput,
1116+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListManagedInsightRulesCommandOutput) => void),
1117+
cb?: (err: any, data?: ListManagedInsightRulesCommandOutput) => void
1118+
): Promise<ListManagedInsightRulesCommandOutput> | void {
1119+
const command = new ListManagedInsightRulesCommand(args);
1120+
if (typeof optionsOrCb === "function") {
1121+
this.send(command, optionsOrCb);
1122+
} else if (typeof cb === "function") {
1123+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
1124+
this.send(command, optionsOrCb || {}, cb);
1125+
} else {
1126+
return this.send(command, optionsOrCb);
1127+
}
1128+
}
1129+
10821130
/**
10831131
* <p>List the specified metrics. You can use the returned metrics with
10841132
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html">GetMetricData</a> or
@@ -1367,6 +1415,54 @@ export class CloudWatch extends CloudWatchClient {
13671415
}
13681416
}
13691417

1418+
/**
1419+
* <p>
1420+
* Creates a managed Contributor Insights rule
1421+
* for a specified Amazon Web Services resource.
1422+
* When you enable a managed rule,
1423+
* you create a Contributor Insights rule
1424+
* that collects data
1425+
* from Amazon Web Services services.
1426+
* You cannot edit these rules
1427+
* with <code>PutInsightRule</code>.
1428+
* The rules can be enabled, disabled, and deleted using <code>EnableInsightRules</code>, <code>DisableInsightRules</code>, and <code>DeleteInsightRules</code>.
1429+
* If a previously created managed rule is currently disabled,
1430+
* a subsequent call
1431+
* to this API will re-enable it.
1432+
* Use <code>ListManagedInsightRules</code>
1433+
* to describe all available rules.
1434+
*
1435+
* </p>
1436+
*/
1437+
public putManagedInsightRules(
1438+
args: PutManagedInsightRulesCommandInput,
1439+
options?: __HttpHandlerOptions
1440+
): Promise<PutManagedInsightRulesCommandOutput>;
1441+
public putManagedInsightRules(
1442+
args: PutManagedInsightRulesCommandInput,
1443+
cb: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
1444+
): void;
1445+
public putManagedInsightRules(
1446+
args: PutManagedInsightRulesCommandInput,
1447+
options: __HttpHandlerOptions,
1448+
cb: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
1449+
): void;
1450+
public putManagedInsightRules(
1451+
args: PutManagedInsightRulesCommandInput,
1452+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutManagedInsightRulesCommandOutput) => void),
1453+
cb?: (err: any, data?: PutManagedInsightRulesCommandOutput) => void
1454+
): Promise<PutManagedInsightRulesCommandOutput> | void {
1455+
const command = new PutManagedInsightRulesCommand(args);
1456+
if (typeof optionsOrCb === "function") {
1457+
this.send(command, optionsOrCb);
1458+
} else if (typeof cb === "function") {
1459+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
1460+
this.send(command, optionsOrCb || {}, cb);
1461+
} else {
1462+
return this.send(command, optionsOrCb);
1463+
}
1464+
}
1465+
13701466
/**
13711467
* <p>Creates or updates an alarm and associates it with the specified metric, metric math expression,
13721468
* or anomaly detection model.</p>

clients/client-cloudwatch/src/CloudWatchClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ import {
104104
GetMetricWidgetImageCommandOutput,
105105
} from "./commands/GetMetricWidgetImageCommand";
106106
import { ListDashboardsCommandInput, ListDashboardsCommandOutput } from "./commands/ListDashboardsCommand";
107+
import {
108+
ListManagedInsightRulesCommandInput,
109+
ListManagedInsightRulesCommandOutput,
110+
} from "./commands/ListManagedInsightRulesCommand";
107111
import { ListMetricsCommandInput, ListMetricsCommandOutput } from "./commands/ListMetricsCommand";
108112
import { ListMetricStreamsCommandInput, ListMetricStreamsCommandOutput } from "./commands/ListMetricStreamsCommand";
109113
import {
@@ -114,6 +118,10 @@ import { PutAnomalyDetectorCommandInput, PutAnomalyDetectorCommandOutput } from
114118
import { PutCompositeAlarmCommandInput, PutCompositeAlarmCommandOutput } from "./commands/PutCompositeAlarmCommand";
115119
import { PutDashboardCommandInput, PutDashboardCommandOutput } from "./commands/PutDashboardCommand";
116120
import { PutInsightRuleCommandInput, PutInsightRuleCommandOutput } from "./commands/PutInsightRuleCommand";
121+
import {
122+
PutManagedInsightRulesCommandInput,
123+
PutManagedInsightRulesCommandOutput,
124+
} from "./commands/PutManagedInsightRulesCommand";
117125
import { PutMetricAlarmCommandInput, PutMetricAlarmCommandOutput } from "./commands/PutMetricAlarmCommand";
118126
import { PutMetricDataCommandInput, PutMetricDataCommandOutput } from "./commands/PutMetricDataCommand";
119127
import { PutMetricStreamCommandInput, PutMetricStreamCommandOutput } from "./commands/PutMetricStreamCommand";
@@ -146,13 +154,15 @@ export type ServiceInputTypes =
146154
| GetMetricStreamCommandInput
147155
| GetMetricWidgetImageCommandInput
148156
| ListDashboardsCommandInput
157+
| ListManagedInsightRulesCommandInput
149158
| ListMetricStreamsCommandInput
150159
| ListMetricsCommandInput
151160
| ListTagsForResourceCommandInput
152161
| PutAnomalyDetectorCommandInput
153162
| PutCompositeAlarmCommandInput
154163
| PutDashboardCommandInput
155164
| PutInsightRuleCommandInput
165+
| PutManagedInsightRulesCommandInput
156166
| PutMetricAlarmCommandInput
157167
| PutMetricDataCommandInput
158168
| PutMetricStreamCommandInput
@@ -184,13 +194,15 @@ export type ServiceOutputTypes =
184194
| GetMetricStreamCommandOutput
185195
| GetMetricWidgetImageCommandOutput
186196
| ListDashboardsCommandOutput
197+
| ListManagedInsightRulesCommandOutput
187198
| ListMetricStreamsCommandOutput
188199
| ListMetricsCommandOutput
189200
| ListTagsForResourceCommandOutput
190201
| PutAnomalyDetectorCommandOutput
191202
| PutCompositeAlarmCommandOutput
192203
| PutDashboardCommandOutput
193204
| PutInsightRuleCommandOutput
205+
| PutManagedInsightRulesCommandOutput
194206
| PutMetricAlarmCommandOutput
195207
| PutMetricDataCommandOutput
196208
| PutMetricStreamCommandOutput
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 { CloudWatchClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudWatchClient";
16+
import {
17+
ListManagedInsightRulesInput,
18+
ListManagedInsightRulesInputFilterSensitiveLog,
19+
ListManagedInsightRulesOutput,
20+
ListManagedInsightRulesOutputFilterSensitiveLog,
21+
} from "../models/models_0";
22+
import {
23+
deserializeAws_queryListManagedInsightRulesCommand,
24+
serializeAws_queryListManagedInsightRulesCommand,
25+
} from "../protocols/Aws_query";
26+
27+
export interface ListManagedInsightRulesCommandInput extends ListManagedInsightRulesInput {}
28+
export interface ListManagedInsightRulesCommandOutput extends ListManagedInsightRulesOutput, __MetadataBearer {}
29+
30+
/**
31+
* <p>
32+
* Returns a list
33+
* that contains the number
34+
* of managed Contributor Insights rules
35+
* in your account.
36+
*
37+
* </p>
38+
* @example
39+
* Use a bare-bones client and the command you need to make an API call.
40+
* ```javascript
41+
* import { CloudWatchClient, ListManagedInsightRulesCommand } from "@aws-sdk/client-cloudwatch"; // ES Modules import
42+
* // const { CloudWatchClient, ListManagedInsightRulesCommand } = require("@aws-sdk/client-cloudwatch"); // CommonJS import
43+
* const client = new CloudWatchClient(config);
44+
* const command = new ListManagedInsightRulesCommand(input);
45+
* const response = await client.send(command);
46+
* ```
47+
*
48+
* @see {@link ListManagedInsightRulesCommandInput} for command's `input` shape.
49+
* @see {@link ListManagedInsightRulesCommandOutput} for command's `response` shape.
50+
* @see {@link CloudWatchClientResolvedConfig | config} for CloudWatchClient's `config` shape.
51+
*
52+
*/
53+
export class ListManagedInsightRulesCommand extends $Command<
54+
ListManagedInsightRulesCommandInput,
55+
ListManagedInsightRulesCommandOutput,
56+
CloudWatchClientResolvedConfig
57+
> {
58+
// Start section: command_properties
59+
// End section: command_properties
60+
61+
constructor(readonly input: ListManagedInsightRulesCommandInput) {
62+
// Start section: command_constructor
63+
super();
64+
// End section: command_constructor
65+
}
66+
67+
/**
68+
* @internal
69+
*/
70+
resolveMiddleware(
71+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
72+
configuration: CloudWatchClientResolvedConfig,
73+
options?: __HttpHandlerOptions
74+
): Handler<ListManagedInsightRulesCommandInput, ListManagedInsightRulesCommandOutput> {
75+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
76+
77+
const stack = clientStack.concat(this.middlewareStack);
78+
79+
const { logger } = configuration;
80+
const clientName = "CloudWatchClient";
81+
const commandName = "ListManagedInsightRulesCommand";
82+
const handlerExecutionContext: HandlerExecutionContext = {
83+
logger,
84+
clientName,
85+
commandName,
86+
inputFilterSensitiveLog: ListManagedInsightRulesInputFilterSensitiveLog,
87+
outputFilterSensitiveLog: ListManagedInsightRulesOutputFilterSensitiveLog,
88+
};
89+
const { requestHandler } = configuration;
90+
return stack.resolve(
91+
(request: FinalizeHandlerArguments<any>) =>
92+
requestHandler.handle(request.request as __HttpRequest, options || {}),
93+
handlerExecutionContext
94+
);
95+
}
96+
97+
private serialize(input: ListManagedInsightRulesCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
98+
return serializeAws_queryListManagedInsightRulesCommand(input, context);
99+
}
100+
101+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListManagedInsightRulesCommandOutput> {
102+
return deserializeAws_queryListManagedInsightRulesCommand(output, context);
103+
}
104+
105+
// Start section: command_body_extra
106+
// End section: command_body_extra
107+
}

0 commit comments

Comments
 (0)