forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete-gateway.js
More file actions
46 lines (44 loc) · 1.3 KB
/
delete-gateway.js
File metadata and controls
46 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[iotsitewise.JavaScript.Basics.deleteGateway]
import {
DeleteGatewayCommand,
IoTSiteWiseClient,
} from "@aws-sdk/client-iotsitewise";
import { parseArgs } from "node:util";
/**
* Create an SSM document.
* @param {{ content: string, name: string, documentType?: DocumentType }}
*/
export const main = async ({ gatewayId }) => {
const client = new IoTSiteWiseClient({});
try {
await client.send(
new DeleteGatewayCommand({
gatewayId: gatewayId, // The ID of the Gateway to describe.
}),
);
console.log("Gateway deleted successfully.");
return { gatewayDeleted: true };
} catch (caught) {
if (caught instanceof Error && caught.name === "ResourceNotFound") {
console.warn(
`${caught.message}. The Gateway could not be found. Please check the Gateway Id.`,
);
} else {
throw caught;
}
}
};
// snippet-end:[iotsitewise.JavaScript.Basics.deleteGateway]
import { fileURLToPath } from "node:url";
// Call function if run directly
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const options = {
gatewayId: {
type: "string",
},
};
const { values } = parseArgs({ options });
main(values);
}