AWS code-library documentation change
Summary
Added JavaScript SDK v3 example for listing geofence collections in AWS Location Service
Security assessment
The change adds a routine code example for geofence management without any security-specific context. No evidence of security vulnerability fixes or security feature documentation.
Diff
diff --git a/code-library/latest/ug/location_code_examples.md b/code-library/latest/ug/location_code_examples.md index 32c8c39ce..307d1e692 100644 --- a//code-library/latest/ug/location_code_examples.md +++ b//code-library/latest/ug/location_code_examples.md @@ -138,0 +139,53 @@ There's more on GitHub. Find the complete example and learn how to set up and ru +JavaScript + + +**SDK for JavaScript (v3)** + + +###### Note + +There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/location/#code-examples). + + + import { fileURLToPath } from "node:url"; + import { + LocationClient, + ListGeofenceCollectionsCommand, + } from "@aws-sdk/client-location"; + + /** + * Lists geofences from a specified geofence collection asynchronously. + */ + export const main = async () => { + const region = "eu-west-1"; + const locationClient = new LocationClient({ region: region }); + const listGeofenceCollParams = { + MaxResults: 100, + }; + try { + const command = new ListGeofenceCollectionsCommand(listGeofenceCollParams); + const response = await locationClient.send(command); + const geofenceEntries = response.Entries; + if (geofenceEntries.length === 0) { + console.log("No Geofences were found in the collection."); + } else { + for (const geofenceEntry of geofenceEntries) { + console.log(`Geofence ID: ${geofenceEntry.CollectionName}`); + } + } + } catch (error) { + console.error( + `A validation error occurred while creating geofence: ${error} \n Exiting program.`, + ); + return; + } + }; + + + + + * For API details, see [ListGeofencesPaginator](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/location/command/ListGeofencesPaginatorCommand) in _AWS SDK for JavaScript API Reference_. + + + +