Usar DeleteGeofenceCollection com um SDK da AWS - Exemplos de código do AWS SDK

Há mais exemplos do AWS SDK disponíveis no repositório do GitHub Documento de Exemplos do AWS SDK.

Usar DeleteGeofenceCollection com um SDK da AWS

Os exemplos de código a seguir mostram como usar o DeleteGeofenceCollection.

Java
SDK para Java 2.x
nota

Há mais no GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

/** * Deletes a geofence collection asynchronously. * * @param collectionName the name of the geofence collection to be deleted * @return a {@link CompletableFuture} that completes when the geofence collection has been deleted */ public CompletableFuture<Void> deleteGeofenceCollectionAsync(String collectionName) { DeleteGeofenceCollectionRequest collectionRequest = DeleteGeofenceCollectionRequest.builder() .collectionName(collectionName) .build(); return getClient().deleteGeofenceCollection(collectionRequest) .whenComplete((response, exception) -> { if (exception != null) { Throwable cause = exception.getCause(); if (cause instanceof ResourceNotFoundException) { throw new CompletionException("The requested geofence collection was not found.", cause); } throw new CompletionException("Failed to delete geofence collection: " + exception.getMessage(), exception); } logger.info("The geofence collection {} was deleted.", collectionName); }) .thenApply(response -> null); }
JavaScript
SDK para JavaScript (v3)
nota

Há mais no GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

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; } } };
Kotlin
SDK para Kotlin
nota

Há mais no GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

/** * Deletes a geofence collection. * * @param collectionName the name of the geofence collection to be deleted * @return a {@link CompletableFuture} that completes when the geofence collection has been deleted */ suspend fun deleteGeofenceCollection(collectionName: String) { val collectionRequest = DeleteGeofenceCollectionRequest { this.collectionName = collectionName } LocationClient.fromEnvironment { region = "us-east-1" }.use { client -> client.deleteGeofenceCollection(collectionRequest) println("The geofence collection $collectionName was deleted.") } }