-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathdelete-geofence-collection.js
More file actions
41 lines (36 loc) · 1.19 KB
/
delete-geofence-collection.js
File metadata and controls
41 lines (36 loc) · 1.19 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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[location.JavaScript.geofence.deleteCollectionV3]
import { fileURLToPath } from "node:url";
import {
DeleteGeofenceCollectionCommand,
LocationClient,
ResourceNotFoundException,
} from "@aws-sdk/client-location";
import data from "./inputs.json" with { type: "json" };
const region = "eu-west-1";
export const main = async () => {
const deleteGeofenceCollParams = {
CollectionName: `${data.inputs.collectionName}`,
};
const locationClient = new LocationClient({ region: region });
try {
const command = new DeleteGeofenceCollectionCommand(
deleteGeofenceCollParams,
);
const response = await locationClient.send(command);
console.log("Collection deleted.");
} catch (caught) {
if (caught instanceof ResourceNotFoundException) {
console.error(
`${data.inputs.collectionName} Geofence collection not found.`,
);
return;
}
}
};
// snippet-end:[location.JavaScript.geofence.deleteCollectionV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}