use of com.google.cloud.automl.v1.AutoMlClient in project java-automl by googleapis.
the class DeleteDataset method deleteDataset.
// Delete a dataset
static void deleteDataset(String projectId, String datasetId) throws IOException, ExecutionException, InterruptedException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// Get the full path of the dataset.
DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
Empty response = client.deleteDatasetAsync(datasetFullId).get();
System.out.format("Dataset deleted. %s%n", response);
}
}
use of com.google.cloud.automl.v1.AutoMlClient in project java-automl by googleapis.
the class GetModel method getModel.
// Get a model
static void getModel(String projectId, String modelId) throws IOException, StatusRuntimeException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// Get the full path of the model.
ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
Model model = client.getModel(modelFullId);
// Display the model information.
System.out.format("Model name: %s%n", model.getName());
// To get the model id, you have to parse it out of the `name` field. As models Ids are
// required for other methods.
// Name Format: `projects/{project_id}/locations/{location_id}/models/{model_id}`
String[] names = model.getName().split("/");
String retrievedModelId = names[names.length - 1];
System.out.format("Model id: %s%n", retrievedModelId);
System.out.format("Model display name: %s%n", model.getDisplayName());
System.out.println("Model create time:");
System.out.format("\tseconds: %s%n", model.getCreateTime().getSeconds());
System.out.format("\tnanos: %s%n", model.getCreateTime().getNanos());
System.out.format("Model deployment state: %s%n", model.getDeploymentState());
}
}
Aggregations