AWS code-library documentation change
Summary
Added Kotlin SDK example for Amazon Location Service geofence listing
Security assessment
Routine code example expansion showing service usage patterns, no security-specific content added
Diff
diff --git a/code-library/latest/ug/location_code_examples.md b/code-library/latest/ug/location_code_examples.md index aae4e1dbf..32c8c39ce 100644 --- a//code-library/latest/ug/location_code_examples.md +++ b//code-library/latest/ug/location_code_examples.md @@ -30 +30 @@ _Actions_ are code excerpts from larger programs and must be run in context. Whi -The following code example shows how to get started using Amazon Location Service. +The following code examples show how to get started using Amazon Location Service. @@ -138,0 +139,72 @@ There's more on GitHub. Find the complete example and learn how to set up and ru +Kotlin + + +**SDK for Kotlin** + + +###### 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/kotlin/services/location#code-examples). + + + /** + Before running this Kotlin code example, set up your development environment, + including your credentials. + + For more information, see the following documentation topic: + https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html + + In addition, you need to create a collection using the AWS Management + console. For information, see the following documentation. + + https://docs.aws.amazon.com/location/latest/developerguide/geofence-gs.html + + */ + suspend fun main(args: Array<String>) { + val usage = """ + + Usage: + <colletionName> + + Where: + colletionName - The Amazon location collection name. + """ + + if (args.size != 1) { + println(usage) + exitProcess(0) + } + val colletionName = args[0] + listGeofences(colletionName) + } + + /** + * Lists the geofences for the specified collection name. + * + * @param collectionName the name of the geofence collection + */ + suspend fun listGeofences(collectionName: String) { + val request = ListGeofencesRequest { + this.collectionName = collectionName + } + + LocationClient { region = "us-east-1" }.use { client -> + val response = client.listGeofences(request) + val geofences = response.entries + if (geofences.isNullOrEmpty()) { + println("No Geofences found") + } else { + geofences.forEach { geofence -> + println("Geofence ID: ${geofence.geofenceId}") + } + } + } + } + + + + * For API details, see [ListGeofencesPaginator](https://sdk.amazonaws.com/kotlin/api/latest/index.html) in _AWS SDK for Kotlin API reference_. + + + +