Skip to content

Commit 0964244

Browse files
author
awstools
committed
feat(client-iot): AWS IoT - AWS IoT Device Defender adds support to list metric datapoints collected for IoT devices through the ListMetricValues API
1 parent 8d798a8 commit 0964244

File tree

12 files changed

+626
-68
lines changed

12 files changed

+626
-68
lines changed

clients/client-iot/src/IoT.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,11 @@ import {
739739
ListManagedJobTemplatesCommandInput,
740740
ListManagedJobTemplatesCommandOutput,
741741
} from "./commands/ListManagedJobTemplatesCommand";
742+
import {
743+
ListMetricValuesCommand,
744+
ListMetricValuesCommandInput,
745+
ListMetricValuesCommandOutput,
746+
} from "./commands/ListMetricValuesCommand";
742747
import {
743748
ListMitigationActionsCommand,
744749
ListMitigationActionsCommandInput,
@@ -6385,6 +6390,39 @@ export class IoT extends IoTClient {
63856390
}
63866391
}
63876392

6393+
/**
6394+
* <p>Lists the values reported for an IoT Device Defender metric (device-side metric, cloud-side metric, or custom metric)
6395+
* by the given thing during the specified time period.</p>
6396+
*/
6397+
public listMetricValues(
6398+
args: ListMetricValuesCommandInput,
6399+
options?: __HttpHandlerOptions
6400+
): Promise<ListMetricValuesCommandOutput>;
6401+
public listMetricValues(
6402+
args: ListMetricValuesCommandInput,
6403+
cb: (err: any, data?: ListMetricValuesCommandOutput) => void
6404+
): void;
6405+
public listMetricValues(
6406+
args: ListMetricValuesCommandInput,
6407+
options: __HttpHandlerOptions,
6408+
cb: (err: any, data?: ListMetricValuesCommandOutput) => void
6409+
): void;
6410+
public listMetricValues(
6411+
args: ListMetricValuesCommandInput,
6412+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListMetricValuesCommandOutput) => void),
6413+
cb?: (err: any, data?: ListMetricValuesCommandOutput) => void
6414+
): Promise<ListMetricValuesCommandOutput> | void {
6415+
const command = new ListMetricValuesCommand(args);
6416+
if (typeof optionsOrCb === "function") {
6417+
this.send(command, optionsOrCb);
6418+
} else if (typeof cb === "function") {
6419+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
6420+
this.send(command, optionsOrCb || {}, cb);
6421+
} else {
6422+
return this.send(command, optionsOrCb);
6423+
}
6424+
}
6425+
63886426
/**
63896427
* <p>Gets a list of all mitigation actions that match the specified filter criteria.</p>
63906428
* <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">ListMitigationActions</a> action.</p>

clients/client-iot/src/IoTClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ import {
461461
ListManagedJobTemplatesCommandInput,
462462
ListManagedJobTemplatesCommandOutput,
463463
} from "./commands/ListManagedJobTemplatesCommand";
464+
import { ListMetricValuesCommandInput, ListMetricValuesCommandOutput } from "./commands/ListMetricValuesCommand";
464465
import {
465466
ListMitigationActionsCommandInput,
466467
ListMitigationActionsCommandOutput,
@@ -859,6 +860,7 @@ export type ServiceInputTypes =
859860
| ListJobTemplatesCommandInput
860861
| ListJobsCommandInput
861862
| ListManagedJobTemplatesCommandInput
863+
| ListMetricValuesCommandInput
862864
| ListMitigationActionsCommandInput
863865
| ListOTAUpdatesCommandInput
864866
| ListOutgoingCertificatesCommandInput
@@ -1097,6 +1099,7 @@ export type ServiceOutputTypes =
10971099
| ListJobTemplatesCommandOutput
10981100
| ListJobsCommandOutput
10991101
| ListManagedJobTemplatesCommandOutput
1102+
| ListMetricValuesCommandOutput
11001103
| ListMitigationActionsCommandOutput
11011104
| ListOTAUpdatesCommandOutput
11021105
| ListOutgoingCertificatesCommandOutput
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { IoTClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../IoTClient";
15+
import { ListMetricValuesRequest, ListMetricValuesResponse } from "../models/models_1";
16+
import {
17+
deserializeAws_restJson1ListMetricValuesCommand,
18+
serializeAws_restJson1ListMetricValuesCommand,
19+
} from "../protocols/Aws_restJson1";
20+
21+
export interface ListMetricValuesCommandInput extends ListMetricValuesRequest {}
22+
export interface ListMetricValuesCommandOutput extends ListMetricValuesResponse, __MetadataBearer {}
23+
24+
/**
25+
* <p>Lists the values reported for an IoT Device Defender metric (device-side metric, cloud-side metric, or custom metric)
26+
* by the given thing during the specified time period.</p>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { IoTClient, ListMetricValuesCommand } from "@aws-sdk/client-iot"; // ES Modules import
31+
* // const { IoTClient, ListMetricValuesCommand } = require("@aws-sdk/client-iot"); // CommonJS import
32+
* const client = new IoTClient(config);
33+
* const command = new ListMetricValuesCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link ListMetricValuesCommandInput} for command's `input` shape.
38+
* @see {@link ListMetricValuesCommandOutput} for command's `response` shape.
39+
* @see {@link IoTClientResolvedConfig | config} for IoTClient's `config` shape.
40+
*
41+
*/
42+
export class ListMetricValuesCommand extends $Command<
43+
ListMetricValuesCommandInput,
44+
ListMetricValuesCommandOutput,
45+
IoTClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: ListMetricValuesCommandInput) {
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: IoTClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<ListMetricValuesCommandInput, ListMetricValuesCommandOutput> {
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 = "IoTClient";
70+
const commandName = "ListMetricValuesCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: ListMetricValuesRequest.filterSensitiveLog,
76+
outputFilterSensitiveLog: ListMetricValuesResponse.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: ListMetricValuesCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_restJson1ListMetricValuesCommand(input, context);
88+
}
89+
90+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListMetricValuesCommandOutput> {
91+
return deserializeAws_restJson1ListMetricValuesCommand(output, context);
92+
}
93+
94+
// Start section: command_body_extra
95+
// End section: command_body_extra
96+
}

clients/client-iot/src/commands/ListThingPrincipalsCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@aws-sdk/types";
1313

1414
import { IoTClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../IoTClient";
15-
import { ListThingPrincipalsRequest, ListThingPrincipalsResponse } from "../models/models_1";
15+
import { ListThingPrincipalsRequest, ListThingPrincipalsResponse } from "../models/models_2";
1616
import {
1717
deserializeAws_restJson1ListThingPrincipalsCommand,
1818
serializeAws_restJson1ListThingPrincipalsCommand,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export * from "./ListJobExecutionsForThingCommand";
153153
export * from "./ListJobTemplatesCommand";
154154
export * from "./ListJobsCommand";
155155
export * from "./ListManagedJobTemplatesCommand";
156+
export * from "./ListMetricValuesCommand";
156157
export * from "./ListMitigationActionsCommand";
157158
export * from "./ListOTAUpdatesCommand";
158159
export * from "./ListOutgoingCertificatesCommand";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,12 +5505,12 @@ export interface CustomCodeSigning {
55055505
certificateChain?: CodeSigningCertificateChain;
55065506

55075507
/**
5508-
* <p>The hash algorithm used to code sign the file. You can use a string as the algorithm name if the target over-the-air (OTA) update devices are able to verify the signature that was generated using the same signature algorithm. For example, FreeRTOS uses <code>SHA256</code> or <code>SHA1</code>, so you can pass either of them based on which was used for generating the signature.</p>
5508+
* <p>The hash algorithm used to code sign the file.</p>
55095509
*/
55105510
hashAlgorithm?: string;
55115511

55125512
/**
5513-
* <p>The signature algorithm used to code sign the file. You can use a string as the algorithm name if the target over-the-air (OTA) update devices are able to verify the signature that was generated using the same signature algorithm. For example, FreeRTOS uses <code>ECDSA</code> or <code>RSA</code>, so you can pass either of them based on which was used for generating the signature.</p>
5513+
* <p>The signature algorithm used to code sign the file.</p>
55145514
*/
55155515
signatureAlgorithm?: string;
55165516
}

clients/client-iot/src/models/models_1.ts

Lines changed: 99 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ import {
3434
CustomMetricType,
3535
DayOfWeek,
3636
DimensionType,
37+
DimensionValueOperator,
3738
FleetMetricUnit,
3839
JobExecutionsRetryConfig,
3940
JobExecutionsRolloutConfig,
4041
LogLevel,
4142
MetricToRetain,
43+
MetricValue,
4244
MitigationActionParams,
4345
OTAUpdateFile,
4446
OTAUpdateStatus,
@@ -6895,6 +6897,103 @@ export namespace ListManagedJobTemplatesResponse {
68956897
});
68966898
}
68976899

6900+
export interface ListMetricValuesRequest {
6901+
/**
6902+
* <p>The name of the thing for which security profile metric values are returned.</p>
6903+
*/
6904+
thingName: string | undefined;
6905+
6906+
/**
6907+
* <p>The name of the security profile metric for which values are returned.</p>
6908+
*/
6909+
metricName: string | undefined;
6910+
6911+
/**
6912+
* <p>The dimension name.</p>
6913+
*/
6914+
dimensionName?: string;
6915+
6916+
/**
6917+
* <p>The dimension value operator.</p>
6918+
*/
6919+
dimensionValueOperator?: DimensionValueOperator | string;
6920+
6921+
/**
6922+
* <p>The start of the time period for which metric values are returned.</p>
6923+
*/
6924+
startTime: Date | undefined;
6925+
6926+
/**
6927+
* <p>The end of the time period for which metric values are returned.</p>
6928+
*/
6929+
endTime: Date | undefined;
6930+
6931+
/**
6932+
* <p>The maximum number of results to return at one time.</p>
6933+
*/
6934+
maxResults?: number;
6935+
6936+
/**
6937+
* <p>The token for the next set of results.</p>
6938+
*/
6939+
nextToken?: string;
6940+
}
6941+
6942+
export namespace ListMetricValuesRequest {
6943+
/**
6944+
* @internal
6945+
*/
6946+
export const filterSensitiveLog = (obj: ListMetricValuesRequest): any => ({
6947+
...obj,
6948+
});
6949+
}
6950+
6951+
/**
6952+
* <p>A metric.</p>
6953+
*/
6954+
export interface MetricDatum {
6955+
/**
6956+
* <p>The time the metric value was reported.</p>
6957+
*/
6958+
timestamp?: Date;
6959+
6960+
/**
6961+
* <p>The value reported for the metric.</p>
6962+
*/
6963+
value?: MetricValue;
6964+
}
6965+
6966+
export namespace MetricDatum {
6967+
/**
6968+
* @internal
6969+
*/
6970+
export const filterSensitiveLog = (obj: MetricDatum): any => ({
6971+
...obj,
6972+
});
6973+
}
6974+
6975+
export interface ListMetricValuesResponse {
6976+
/**
6977+
* <p>The data the thing reports for the metric during the specified time period.</p>
6978+
*/
6979+
metricDatumList?: MetricDatum[];
6980+
6981+
/**
6982+
* <p>A token that can be used to retrieve the next set of results, or <code>null</code>
6983+
* if there are no additional results.</p>
6984+
*/
6985+
nextToken?: string;
6986+
}
6987+
6988+
export namespace ListMetricValuesResponse {
6989+
/**
6990+
* @internal
6991+
*/
6992+
export const filterSensitiveLog = (obj: ListMetricValuesResponse): any => ({
6993+
...obj,
6994+
});
6995+
}
6996+
68986997
export interface ListMitigationActionsRequest {
68996998
/**
69006999
* <p>Specify a value to limit the result to mitigation actions with a specific action type.</p>
@@ -8242,63 +8341,3 @@ export namespace ListThingGroupsForThingResponse {
82428341
...obj,
82438342
});
82448343
}
8245-
8246-
/**
8247-
* <p>The input for the ListThingPrincipal operation.</p>
8248-
*/
8249-
export interface ListThingPrincipalsRequest {
8250-
/**
8251-
* <p>To retrieve the next set of results, the <code>nextToken</code>
8252-
* value from a previous response; otherwise <b>null</b> to receive
8253-
* the first set of results.</p>
8254-
*/
8255-
nextToken?: string;
8256-
8257-
/**
8258-
* <p>The maximum number of results to return in this operation.</p>
8259-
*/
8260-
maxResults?: number;
8261-
8262-
/**
8263-
* <p>The name of the thing.</p>
8264-
*/
8265-
thingName: string | undefined;
8266-
}
8267-
8268-
export namespace ListThingPrincipalsRequest {
8269-
/**
8270-
* @internal
8271-
*/
8272-
export const filterSensitiveLog = (obj: ListThingPrincipalsRequest): any => ({
8273-
...obj,
8274-
});
8275-
}
8276-
8277-
/**
8278-
* <p>The output from the ListThingPrincipals operation.</p>
8279-
*/
8280-
export interface ListThingPrincipalsResponse {
8281-
/**
8282-
* <p>The principals associated with the thing.</p>
8283-
*/
8284-
principals?: string[];
8285-
8286-
/**
8287-
* <p>The token to use to get the next set of results, or <b>null</b> if there are no additional results.</p>
8288-
*/
8289-
nextToken?: string;
8290-
}
8291-
8292-
export namespace ListThingPrincipalsResponse {
8293-
/**
8294-
* @internal
8295-
*/
8296-
export const filterSensitiveLog = (obj: ListThingPrincipalsResponse): any => ({
8297-
...obj,
8298-
});
8299-
}
8300-
8301-
export enum ReportType {
8302-
ERRORS = "ERRORS",
8303-
RESULTS = "RESULTS",
8304-
}

0 commit comments

Comments
 (0)