diff --git a/clients/client-iot-events-data/src/IoTEventsData.ts b/clients/client-iot-events-data/src/IoTEventsData.ts index 261e78125ff4..d5263d59007f 100644 --- a/clients/client-iot-events-data/src/IoTEventsData.ts +++ b/clients/client-iot-events-data/src/IoTEventsData.ts @@ -6,6 +6,11 @@ import { BatchAcknowledgeAlarmCommandInput, BatchAcknowledgeAlarmCommandOutput, } from "./commands/BatchAcknowledgeAlarmCommand"; +import { + BatchDeleteDetectorCommand, + BatchDeleteDetectorCommandInput, + BatchDeleteDetectorCommandOutput, +} from "./commands/BatchDeleteDetectorCommand"; import { BatchDisableAlarmCommand, BatchDisableAlarmCommandInput, @@ -95,6 +100,38 @@ export class IoTEventsData extends IoTEventsDataClient { } } + /** + *

Deletes one or more detectors that were created. When a detector is deleted, its state will be cleared and the detector will be removed from the list of detectors. The deleted detector will no longer appear if referenced in the ListDetectors API call.

+ */ + public batchDeleteDetector( + args: BatchDeleteDetectorCommandInput, + options?: __HttpHandlerOptions + ): Promise; + public batchDeleteDetector( + args: BatchDeleteDetectorCommandInput, + cb: (err: any, data?: BatchDeleteDetectorCommandOutput) => void + ): void; + public batchDeleteDetector( + args: BatchDeleteDetectorCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: BatchDeleteDetectorCommandOutput) => void + ): void; + public batchDeleteDetector( + args: BatchDeleteDetectorCommandInput, + optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: BatchDeleteDetectorCommandOutput) => void), + cb?: (err: any, data?: BatchDeleteDetectorCommandOutput) => void + ): Promise | void { + const command = new BatchDeleteDetectorCommand(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); + } + } + /** *

Disables one or more alarms. The alarms change to the DISABLED state after * you disable them.

diff --git a/clients/client-iot-events-data/src/IoTEventsDataClient.ts b/clients/client-iot-events-data/src/IoTEventsDataClient.ts index b8e82ad15632..fd73feb52595 100644 --- a/clients/client-iot-events-data/src/IoTEventsDataClient.ts +++ b/clients/client-iot-events-data/src/IoTEventsDataClient.ts @@ -56,6 +56,10 @@ import { BatchAcknowledgeAlarmCommandInput, BatchAcknowledgeAlarmCommandOutput, } from "./commands/BatchAcknowledgeAlarmCommand"; +import { + BatchDeleteDetectorCommandInput, + BatchDeleteDetectorCommandOutput, +} from "./commands/BatchDeleteDetectorCommand"; import { BatchDisableAlarmCommandInput, BatchDisableAlarmCommandOutput } from "./commands/BatchDisableAlarmCommand"; import { BatchEnableAlarmCommandInput, BatchEnableAlarmCommandOutput } from "./commands/BatchEnableAlarmCommand"; import { BatchPutMessageCommandInput, BatchPutMessageCommandOutput } from "./commands/BatchPutMessageCommand"; @@ -73,6 +77,7 @@ import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; export type ServiceInputTypes = | BatchAcknowledgeAlarmCommandInput + | BatchDeleteDetectorCommandInput | BatchDisableAlarmCommandInput | BatchEnableAlarmCommandInput | BatchPutMessageCommandInput @@ -86,6 +91,7 @@ export type ServiceInputTypes = export type ServiceOutputTypes = | BatchAcknowledgeAlarmCommandOutput + | BatchDeleteDetectorCommandOutput | BatchDisableAlarmCommandOutput | BatchEnableAlarmCommandOutput | BatchPutMessageCommandOutput diff --git a/clients/client-iot-events-data/src/commands/BatchDeleteDetectorCommand.ts b/clients/client-iot-events-data/src/commands/BatchDeleteDetectorCommand.ts new file mode 100644 index 000000000000..4b2844752eb1 --- /dev/null +++ b/clients/client-iot-events-data/src/commands/BatchDeleteDetectorCommand.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 { IoTEventsDataClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../IoTEventsDataClient"; +import { BatchDeleteDetectorRequest, BatchDeleteDetectorResponse } from "../models/models_0"; +import { + deserializeAws_restJson1BatchDeleteDetectorCommand, + serializeAws_restJson1BatchDeleteDetectorCommand, +} from "../protocols/Aws_restJson1"; + +export interface BatchDeleteDetectorCommandInput extends BatchDeleteDetectorRequest {} +export interface BatchDeleteDetectorCommandOutput extends BatchDeleteDetectorResponse, __MetadataBearer {} + +/** + *

Deletes one or more detectors that were created. When a detector is deleted, its state will be cleared and the detector will be removed from the list of detectors. The deleted detector will no longer appear if referenced in the ListDetectors API call.

+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { IoTEventsDataClient, BatchDeleteDetectorCommand } from "@aws-sdk/client-iot-events-data"; // ES Modules import + * // const { IoTEventsDataClient, BatchDeleteDetectorCommand } = require("@aws-sdk/client-iot-events-data"); // CommonJS import + * const client = new IoTEventsDataClient(config); + * const command = new BatchDeleteDetectorCommand(input); + * const response = await client.send(command); + * ``` + * + * @see {@link BatchDeleteDetectorCommandInput} for command's `input` shape. + * @see {@link BatchDeleteDetectorCommandOutput} for command's `response` shape. + * @see {@link IoTEventsDataClientResolvedConfig | config} for IoTEventsDataClient's `config` shape. + * + */ +export class BatchDeleteDetectorCommand extends $Command< + BatchDeleteDetectorCommandInput, + BatchDeleteDetectorCommandOutput, + IoTEventsDataClientResolvedConfig +> { + // Start section: command_properties + // End section: command_properties + + constructor(readonly input: BatchDeleteDetectorCommandInput) { + // Start section: command_constructor + super(); + // End section: command_constructor + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: IoTEventsDataClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "IoTEventsDataClient"; + const commandName = "BatchDeleteDetectorCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: BatchDeleteDetectorRequest.filterSensitiveLog, + outputFilterSensitiveLog: BatchDeleteDetectorResponse.filterSensitiveLog, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + private serialize(input: BatchDeleteDetectorCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return serializeAws_restJson1BatchDeleteDetectorCommand(input, context); + } + + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return deserializeAws_restJson1BatchDeleteDetectorCommand(output, context); + } + + // Start section: command_body_extra + // End section: command_body_extra +} diff --git a/clients/client-iot-events-data/src/commands/index.ts b/clients/client-iot-events-data/src/commands/index.ts index c2751f0600c8..63c146333eaf 100644 --- a/clients/client-iot-events-data/src/commands/index.ts +++ b/clients/client-iot-events-data/src/commands/index.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code export * from "./BatchAcknowledgeAlarmCommand"; +export * from "./BatchDeleteDetectorCommand"; export * from "./BatchDisableAlarmCommand"; export * from "./BatchEnableAlarmCommand"; export * from "./BatchPutMessageCommand"; diff --git a/clients/client-iot-events-data/src/models/models_0.ts b/clients/client-iot-events-data/src/models/models_0.ts index f87a4e3eb96f..ecdc95912cc9 100644 --- a/clients/client-iot-events-data/src/models/models_0.ts +++ b/clients/client-iot-events-data/src/models/models_0.ts @@ -705,6 +705,96 @@ export class ThrottlingException extends __BaseException { } } +/** + *

Information used to delete the detector model.

+ */ +export interface DeleteDetectorRequest { + /** + *

The ID to assign to the DeleteDetectorRequest. Each "messageId" must be unique within each batch sent.

+ */ + messageId: string | undefined; + + /** + *

The name of the detector model that was used to create the detector instance.

+ */ + detectorModelName: string | undefined; + + /** + *

The value of the key used to identify the detector.

+ */ + keyValue?: string; +} + +export namespace DeleteDetectorRequest { + /** + * @internal + */ + export const filterSensitiveLog = (obj: DeleteDetectorRequest): any => ({ + ...obj, + }); +} + +export interface BatchDeleteDetectorRequest { + /** + *

The list of one or more detectors to be deleted.

+ */ + detectors: DeleteDetectorRequest[] | undefined; +} + +export namespace BatchDeleteDetectorRequest { + /** + * @internal + */ + export const filterSensitiveLog = (obj: BatchDeleteDetectorRequest): any => ({ + ...obj, + }); +} + +/** + *

Contains error messages associated with the deletion request.

+ */ +export interface BatchDeleteDetectorErrorEntry { + /** + *

The ID of the message that caused the error. (See the value of the "messageId" in the detectors object of the DeleteDetectorRequest.)

+ */ + messageId?: string; + + /** + *

The error code.

+ */ + errorCode?: ErrorCode | string; + + /** + *

A message that describes the error.

+ */ + errorMessage?: string; +} + +export namespace BatchDeleteDetectorErrorEntry { + /** + * @internal + */ + export const filterSensitiveLog = (obj: BatchDeleteDetectorErrorEntry): any => ({ + ...obj, + }); +} + +export interface BatchDeleteDetectorResponse { + /** + *

A list of errors associated with the request, or an empty array ([]) if there are no errors. Each error entry contains a messageId that helps you identify the entry that failed.

+ */ + batchDeleteDetectorErrorEntries?: BatchDeleteDetectorErrorEntry[]; +} + +export namespace BatchDeleteDetectorResponse { + /** + * @internal + */ + export const filterSensitiveLog = (obj: BatchDeleteDetectorResponse): any => ({ + ...obj, + }); +} + /** *

Information used to disable the alarm.

*/ diff --git a/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts b/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts index 9217add09270..4a538fd060f2 100644 --- a/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts @@ -20,6 +20,10 @@ import { BatchAcknowledgeAlarmCommandInput, BatchAcknowledgeAlarmCommandOutput, } from "../commands/BatchAcknowledgeAlarmCommand"; +import { + BatchDeleteDetectorCommandInput, + BatchDeleteDetectorCommandOutput, +} from "../commands/BatchDeleteDetectorCommand"; import { BatchDisableAlarmCommandInput, BatchDisableAlarmCommandOutput } from "../commands/BatchDisableAlarmCommand"; import { BatchEnableAlarmCommandInput, BatchEnableAlarmCommandOutput } from "../commands/BatchEnableAlarmCommand"; import { BatchPutMessageCommandInput, BatchPutMessageCommandOutput } from "../commands/BatchPutMessageCommand"; @@ -41,9 +45,11 @@ import { AlarmState, AlarmSummary, BatchAlarmActionErrorEntry, + BatchDeleteDetectorErrorEntry, BatchPutMessageErrorEntry, BatchUpdateDetectorErrorEntry, CustomerAction, + DeleteDetectorRequest, Detector, DetectorState, DetectorStateDefinition, @@ -105,6 +111,33 @@ export const serializeAws_restJson1BatchAcknowledgeAlarmCommand = async ( }); }; +export const serializeAws_restJson1BatchDeleteDetectorCommand = async ( + input: BatchDeleteDetectorCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/detectors/delete"; + let body: any; + body = JSON.stringify({ + ...(input.detectors !== undefined && + input.detectors !== null && { + detectors: serializeAws_restJson1DeleteDetectorRequests(input.detectors, context), + }), + }); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "POST", + headers, + path: resolvedPath, + body, + }); +}; + export const serializeAws_restJson1BatchDisableAlarmCommand = async ( input: BatchDisableAlarmCommandInput, context: __SerdeContext @@ -452,6 +485,62 @@ const deserializeAws_restJson1BatchAcknowledgeAlarmCommandError = async ( } }; +export const deserializeAws_restJson1BatchDeleteDetectorCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return deserializeAws_restJson1BatchDeleteDetectorCommandError(output, context); + } + const contents: BatchDeleteDetectorCommandOutput = { + $metadata: deserializeMetadata(output), + batchDeleteDetectorErrorEntries: undefined, + }; + const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + if (data.batchDeleteDetectorErrorEntries !== undefined && data.batchDeleteDetectorErrorEntries !== null) { + contents.batchDeleteDetectorErrorEntries = deserializeAws_restJson1BatchDeleteDetectorErrorEntries( + data.batchDeleteDetectorErrorEntries, + context + ); + } + return Promise.resolve(contents); +}; + +const deserializeAws_restJson1BatchDeleteDetectorCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + let response: __BaseException; + let errorCode = "UnknownError"; + errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "InternalFailureException": + case "com.amazonaws.ioteventsdata#InternalFailureException": + throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context); + case "InvalidRequestException": + case "com.amazonaws.ioteventsdata#InvalidRequestException": + throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); + case "ServiceUnavailableException": + case "com.amazonaws.ioteventsdata#ServiceUnavailableException": + throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); + case "ThrottlingException": + case "com.amazonaws.ioteventsdata#ThrottlingException": + throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); + default: + const parsedBody = parsedOutput.body; + response = new __BaseException({ + name: parsedBody.code || parsedBody.Code || errorCode, + $fault: "client", + $metadata: deserializeMetadata(output), + }); + throw __decorateServiceException(response, parsedBody); + } +}; + export const deserializeAws_restJson1BatchDisableAlarmCommand = async ( output: __HttpResponse, context: __SerdeContext @@ -1115,6 +1204,26 @@ const serializeAws_restJson1AcknowledgeAlarmActionRequests = ( }); }; +const serializeAws_restJson1DeleteDetectorRequest = (input: DeleteDetectorRequest, context: __SerdeContext): any => { + return { + ...(input.detectorModelName !== undefined && + input.detectorModelName !== null && { detectorModelName: input.detectorModelName }), + ...(input.keyValue !== undefined && input.keyValue !== null && { keyValue: input.keyValue }), + ...(input.messageId !== undefined && input.messageId !== null && { messageId: input.messageId }), + }; +}; + +const serializeAws_restJson1DeleteDetectorRequests = (input: DeleteDetectorRequest[], context: __SerdeContext): any => { + return input + .filter((e: any) => e != null) + .map((entry) => { + if (entry === null) { + return null as any; + } + return serializeAws_restJson1DeleteDetectorRequest(entry, context); + }); +}; + const serializeAws_restJson1DetectorStateDefinition = ( input: DetectorStateDefinition, context: __SerdeContext @@ -1426,6 +1535,32 @@ const deserializeAws_restJson1BatchAlarmActionErrorEntry = ( } as any; }; +const deserializeAws_restJson1BatchDeleteDetectorErrorEntries = ( + output: any, + context: __SerdeContext +): BatchDeleteDetectorErrorEntry[] => { + const retVal = (output || []) + .filter((e: any) => e != null) + .map((entry: any) => { + if (entry === null) { + return null as any; + } + return deserializeAws_restJson1BatchDeleteDetectorErrorEntry(entry, context); + }); + return retVal; +}; + +const deserializeAws_restJson1BatchDeleteDetectorErrorEntry = ( + output: any, + context: __SerdeContext +): BatchDeleteDetectorErrorEntry => { + return { + errorCode: __expectString(output.errorCode), + errorMessage: __expectString(output.errorMessage), + messageId: __expectString(output.messageId), + } as any; +}; + const deserializeAws_restJson1BatchPutMessageErrorEntries = ( output: any, context: __SerdeContext diff --git a/codegen/sdk-codegen/aws-models/iot-events-data.json b/codegen/sdk-codegen/aws-models/iot-events-data.json index 00c21babc53c..30ee5344f73a 100644 --- a/codegen/sdk-codegen/aws-models/iot-events-data.json +++ b/codegen/sdk-codegen/aws-models/iot-events-data.json @@ -356,6 +356,92 @@ "smithy.api#documentation": "

Contains error messages associated with one of the following requests:

\n " } }, + "com.amazonaws.ioteventsdata#BatchDeleteDetector": { + "type": "operation", + "input": { + "target": "com.amazonaws.ioteventsdata#BatchDeleteDetectorRequest" + }, + "output": { + "target": "com.amazonaws.ioteventsdata#BatchDeleteDetectorResponse" + }, + "errors": [ + { + "target": "com.amazonaws.ioteventsdata#InternalFailureException" + }, + { + "target": "com.amazonaws.ioteventsdata#InvalidRequestException" + }, + { + "target": "com.amazonaws.ioteventsdata#ServiceUnavailableException" + }, + { + "target": "com.amazonaws.ioteventsdata#ThrottlingException" + } + ], + "traits": { + "smithy.api#documentation": "

Deletes one or more detectors that were created. When a detector is deleted, its state will be cleared and the detector will be removed from the list of detectors. The deleted detector will no longer appear if referenced in the ListDetectors API call.

", + "smithy.api#http": { + "method": "POST", + "uri": "/detectors/delete", + "code": 200 + } + } + }, + "com.amazonaws.ioteventsdata#BatchDeleteDetectorErrorEntries": { + "type": "list", + "member": { + "target": "com.amazonaws.ioteventsdata#BatchDeleteDetectorErrorEntry" + } + }, + "com.amazonaws.ioteventsdata#BatchDeleteDetectorErrorEntry": { + "type": "structure", + "members": { + "messageId": { + "target": "com.amazonaws.ioteventsdata#MessageId", + "traits": { + "smithy.api#documentation": "

The ID of the message that caused the error. (See the value of the \"messageId\" in the detectors object of the DeleteDetectorRequest.)

" + } + }, + "errorCode": { + "target": "com.amazonaws.ioteventsdata#ErrorCode", + "traits": { + "smithy.api#documentation": "

The error code.

" + } + }, + "errorMessage": { + "target": "com.amazonaws.ioteventsdata#ErrorMessage", + "traits": { + "smithy.api#documentation": "

A message that describes the error.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Contains error messages associated with the deletion request.

" + } + }, + "com.amazonaws.ioteventsdata#BatchDeleteDetectorRequest": { + "type": "structure", + "members": { + "detectors": { + "target": "com.amazonaws.ioteventsdata#DeleteDetectorRequests", + "traits": { + "smithy.api#documentation": "

The list of one or more detectors to be deleted.

", + "smithy.api#required": {} + } + } + } + }, + "com.amazonaws.ioteventsdata#BatchDeleteDetectorResponse": { + "type": "structure", + "members": { + "batchDeleteDetectorErrorEntries": { + "target": "com.amazonaws.ioteventsdata#BatchDeleteDetectorErrorEntries", + "traits": { + "smithy.api#documentation": "

A list of errors associated with the request, or an empty array ([]) if there are no errors. Each error entry contains a messageId that helps you identify the entry that failed.

" + } + } + } + }, "com.amazonaws.ioteventsdata#BatchDisableAlarm": { "type": "operation", "input": { @@ -846,6 +932,45 @@ ] } }, + "com.amazonaws.ioteventsdata#DeleteDetectorRequest": { + "type": "structure", + "members": { + "messageId": { + "target": "com.amazonaws.ioteventsdata#MessageId", + "traits": { + "smithy.api#documentation": "

The ID to assign to the DeleteDetectorRequest. Each \"messageId\" must be unique within each batch sent.

", + "smithy.api#required": {} + } + }, + "detectorModelName": { + "target": "com.amazonaws.ioteventsdata#DetectorModelName", + "traits": { + "smithy.api#documentation": "

The name of the detector model that was used to create the detector instance.

", + "smithy.api#required": {} + } + }, + "keyValue": { + "target": "com.amazonaws.ioteventsdata#KeyValue", + "traits": { + "smithy.api#documentation": "

The value of the key used to identify the detector.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Information used to delete the detector model.

" + } + }, + "com.amazonaws.ioteventsdata#DeleteDetectorRequests": { + "type": "list", + "member": { + "target": "com.amazonaws.ioteventsdata#DeleteDetectorRequest" + }, + "traits": { + "smithy.api#length": { + "min": 1 + } + } + }, "com.amazonaws.ioteventsdata#DescribeAlarm": { "type": "operation", "input": { @@ -1397,6 +1522,9 @@ { "target": "com.amazonaws.ioteventsdata#BatchAcknowledgeAlarm" }, + { + "target": "com.amazonaws.ioteventsdata#BatchDeleteDetector" + }, { "target": "com.amazonaws.ioteventsdata#BatchDisableAlarm" },