Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc. GitHub
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DeleteMatchingWorkflow dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanDeleteMatchingWorkflow.
Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:
- Java
-
- SDK untuk Java 2.x
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.
/**
* Asynchronously deletes a workflow with the specified name.
*
* @param workflowName the name of the workflow to be deleted
* @return a {@link CompletableFuture} that completes when the workflow has been deleted
* @throws RuntimeException if the deletion of the workflow fails
*/
public CompletableFuture<DeleteMatchingWorkflowResponse> deleteMatchingWorkflowAsync(String workflowName) {
DeleteMatchingWorkflowRequest request = DeleteMatchingWorkflowRequest.builder()
.workflowName(workflowName)
.build();
return getResolutionAsyncClient().deleteMatchingWorkflow(request)
.whenComplete((response, exception) -> {
if (response != null) {
logger.info("{} was deleted", workflowName );
} else {
if (exception == null) {
throw new CompletionException("An unknown error occurred while deleting the workflow.", null);
}
Throwable cause = exception.getCause();
if (cause instanceof ResourceNotFoundException) {
throw new CompletionException("The workflow to delete was not found.", cause);
}
// Wrap other AWS exceptions in a CompletionException.
throw new CompletionException("Failed to delete workflow: " + exception.getMessage(), exception);
}
});
}
- JavaScript
-
- SDK untuk JavaScript (v3)
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.
//The default inputs for this demo are read from the ../inputs.json.
import { fileURLToPath } from "node:url";
import {
DeleteMatchingWorkflowCommand,
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 () => {
try {
const deleteWorkflowParams = {
workflowName: `${data.inputs.workflowName}`,
};
const command = new DeleteMatchingWorkflowCommand(deleteWorkflowParams);
const response = await erClient.send(command);
console.log("Workflow deleted successfully!", response);
} catch (error) {
console.log("error ", error);
}
};