use of com.google.cloud.translate.v3.DeleteGlossaryRequest in project java-translate by googleapis.
the class DeleteGlossary method deleteGlossary.
// Delete a specific glossary based on the glossary ID
public static void deleteGlossary(String projectId, String glossaryId) throws InterruptedException, ExecutionException, IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TranslationServiceClient client = TranslationServiceClient.create()) {
// Supported Locations: `global`, [glossary location], or [model location]
// Glossaries must be hosted in `us-central1`
// Custom Models must use the same location as your model. (us-central1)
GlossaryName glossaryName = GlossaryName.of(projectId, "us-central1", glossaryId);
DeleteGlossaryRequest request = DeleteGlossaryRequest.newBuilder().setName(glossaryName.toString()).build();
// Start an asynchronous request
OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> future = client.deleteGlossaryAsync(request);
System.out.println("Waiting for operation to complete...");
DeleteGlossaryResponse response = future.get();
System.out.format("Deleted Glossary: %s\n", response.getName());
}
}
Aggregations