Usar DeleteRouteCalculator 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 DeleteRouteCalculator com um SDK da AWS

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

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 route calculator from the system. * * @param calcName the name of the route calculator to delete * @return a {@link CompletableFuture} that completes when the route calculator has been deleted * @throws CompletionException if an error occurs while deleting the route calculator * - If the route calculator was not found, a {@link ResourceNotFoundException} will be thrown * - If any other error occurs, a generic {@link CompletionException} will be thrown */ public CompletableFuture<Void> deleteRouteCalculator(String calcName) { DeleteRouteCalculatorRequest calculatorRequest = DeleteRouteCalculatorRequest.builder() .calculatorName(calcName) .build(); return getClient().deleteRouteCalculator(calculatorRequest) .whenComplete((response, exception) -> { if (exception != null) { Throwable cause = exception.getCause(); if (cause instanceof ResourceNotFoundException) { throw new CompletionException("The route calculator was not found.", cause); } throw new CompletionException("Failed to delete the route calculator: " + exception.getMessage(), exception); } logger.info("The route calculator {} was deleted.", calcName); }) .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 { DeleteRouteCalculatorCommand, 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 deleteRouteCalculatorParams = { CalculatorName: `${data.inputs.calculatorName}`, }; try { const locationClient = new LocationClient({ region: region }); const command = new DeleteRouteCalculatorCommand( deleteRouteCalculatorParams, ); const response = await locationClient.send(command); console.log("Route calculator deleted."); } catch (caught) { if (caught instanceof ResourceNotFoundException) { console.error( `${data.inputs.calculatorName} route calculator 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 route calculator from the system. * @param calcName the name of the route calculator to delete */ suspend fun deleteRouteCalculator(calcName: String) { val calculatorRequest = DeleteRouteCalculatorRequest { this.calculatorName = calcName } LocationClient.fromEnvironment { region = "us-east-1" }.use { client -> client.deleteRouteCalculator(calculatorRequest) println("The route calculator $calcName was deleted.") } }