use of com.google.cloud.notebooks.v1beta1.StartInstanceRequest in project java-notebooks by googleapis.
the class ITNotebookServiceClientTest method startInstance.
private String startInstance() throws ExecutionException, InterruptedException {
StartInstanceRequest request = StartInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
Instance response = client.startInstanceAsync(request).get();
return response.getState().name();
}
use of com.google.cloud.notebooks.v1beta1.StartInstanceRequest in project java-docs-samples by GoogleCloudPlatform.
the class StartInstance method startInstance.
// Starts a stopped Google Compute Engine instance (with unencrypted disks).
public static void startInstance(String project, String zone, String instanceName) throws IOException, ExecutionException, InterruptedException {
/* Initialize client that will be used to send requests. This client only needs to be created
once, and can be reused for multiple requests. After completing all of your requests, call
the `instancesClient.close()` method on the client to safely
clean up any remaining background resources. */
try (InstancesClient instancesClient = InstancesClient.create()) {
// Create the request.
StartInstanceRequest startInstanceRequest = StartInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).build();
OperationFuture<Operation, Operation> operation = instancesClient.startAsync(startInstanceRequest);
// Wait for the operation to complete.
Operation response = operation.get();
if (response.getStatus() == Status.DONE) {
System.out.println("Instance started successfully ! ");
}
}
}
Aggregations