Weitere AWS SDK-Beispiele sind im Repo AWS Doc SDK Examples
Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
TagResource
Mit einem AWS SDK verwenden
Die folgenden Code-Beispiele zeigen, wie TagResource
verwendet wird.
- Java
-
- SDK für Java 2.x
-
Anmerkung
Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. /** * Tags the specified schema mapping ARN. * * @param schemaMappingARN the ARN of the schema mapping to tag */ public CompletableFuture<TagResourceResponse> tagEntityResource(String schemaMappingARN) { Map<String, String> tags = new HashMap<>(); tags.put("tag1", "tag1Value"); tags.put("tag2", "tag2Value"); TagResourceRequest request = TagResourceRequest.builder() .resourceArn(schemaMappingARN) .tags(tags) .build(); return getResolutionAsyncClient().tagResource(request) .whenComplete((response, exception) -> { if (response != null) { // Successfully tagged the resource, log the success message. logger.info("Successfully tagged the resource."); } else { if (exception == null) { throw new CompletionException("An unknown error occurred while tagging the resource.", null); } Throwable cause = exception.getCause(); if (cause instanceof ResourceNotFoundException) { throw new CompletionException("The resource to tag was not found.", cause); } throw new CompletionException("Failed to tag the resource: " + exception.getMessage(), exception); } }); }
-
Einzelheiten zur API finden Sie TagResourcein der AWS SDK for Java 2.x API-Referenz.
-
- JavaScript
-
- SDK für JavaScript (v3)
-
Anmerkung
Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel-
einrichten und ausführen. //The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { TagResourceCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const tagResourceCommandParams = { resourceArn: `${data.inputs.schemaArn}`, tags: { tag1: "tag1Value", tag2: "tag2Value", }, }; try { const command = new TagResourceCommand(tagResourceCommandParams); const response = await erClient.send(command); console.log("Successfully tagged the resource."); } catch (caught) { console.error(caught.message); throw caught; } };
-
Einzelheiten zur API finden Sie TagResourcein der AWS SDK für JavaScript API-Referenz.
-