Class ManagedNotebookServiceClient (1.4.0)

Stay organized with collections Save and categorize content based on your preferences.
public class ManagedNotebookServiceClient implements BackgroundResource

Service Description: API v1 service for Managed Notebooks.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   RuntimeName name = RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]");
   Runtime response = managedNotebookServiceClient.getRuntime(name);
 }
 

Note: close() needs to be called on the ManagedNotebookServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ManagedNotebookServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ManagedNotebookServiceSettings managedNotebookServiceSettings =
     ManagedNotebookServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create(managedNotebookServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ManagedNotebookServiceSettings managedNotebookServiceSettings =
     ManagedNotebookServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create(managedNotebookServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ManagedNotebookServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final ManagedNotebookServiceClient create()

Constructs an instance of ManagedNotebookServiceClient with default settings.

Returns
TypeDescription
ManagedNotebookServiceClient
Exceptions
TypeDescription
IOException

create(ManagedNotebookServiceSettings settings)

public static final ManagedNotebookServiceClient create(ManagedNotebookServiceSettings settings)

Constructs an instance of ManagedNotebookServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsManagedNotebookServiceSettings
Returns
TypeDescription
ManagedNotebookServiceClient
Exceptions
TypeDescription
IOException

create(ManagedNotebookServiceStub stub)

public static final ManagedNotebookServiceClient create(ManagedNotebookServiceStub stub)

Constructs an instance of ManagedNotebookServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ManagedNotebookServiceSettings).

Parameter
NameDescription
stubManagedNotebookServiceStub
Returns
TypeDescription
ManagedNotebookServiceClient

Constructors

ManagedNotebookServiceClient(ManagedNotebookServiceSettings settings)

protected ManagedNotebookServiceClient(ManagedNotebookServiceSettings settings)

Constructs an instance of ManagedNotebookServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsManagedNotebookServiceSettings

ManagedNotebookServiceClient(ManagedNotebookServiceStub stub)

protected ManagedNotebookServiceClient(ManagedNotebookServiceStub stub)
Parameter
NameDescription
stubManagedNotebookServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createRuntimeAsync(CreateRuntimeRequest request)

public final OperationFuture<Runtime,OperationMetadata> createRuntimeAsync(CreateRuntimeRequest request)

Creates a new Runtime in a given project and location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   CreateRuntimeRequest request =
       CreateRuntimeRequest.newBuilder()
           .setParent(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRuntimeId("runtimeId121455379")
           .setRuntime(Runtime.newBuilder().build())
           .setRequestId("requestId693933066")
           .build();
   Runtime response = managedNotebookServiceClient.createRuntimeAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateRuntimeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Runtime,OperationMetadata>

createRuntimeAsync(RuntimeName parent, String runtimeId, Runtime runtime)

public final OperationFuture<Runtime,OperationMetadata> createRuntimeAsync(RuntimeName parent, String runtimeId, Runtime runtime)

Creates a new Runtime in a given project and location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   RuntimeName parent = RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]");
   String runtimeId = "runtimeId121455379";
   Runtime runtime = Runtime.newBuilder().build();
   Runtime response =
       managedNotebookServiceClient.createRuntimeAsync(parent, runtimeId, runtime).get();
 }
 
Parameters
NameDescription
parentRuntimeName

Required. Format: parent=projects/{project_id}/locations/{location}

runtimeIdString

Required. User-defined unique ID of this Runtime.

runtimeRuntime

Required. The Runtime to be created.

Returns
TypeDescription
OperationFuture<Runtime,OperationMetadata>

createRuntimeAsync(String parent, String runtimeId, Runtime runtime)

public final OperationFuture<Runtime,OperationMetadata> createRuntimeAsync(String parent, String runtimeId, Runtime runtime)

Creates a new Runtime in a given project and location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   String parent = RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString();
   String runtimeId = "runtimeId121455379";
   Runtime runtime = Runtime.newBuilder().build();
   Runtime response =
       managedNotebookServiceClient.createRuntimeAsync(parent, runtimeId, runtime).get();
 }
 
Parameters
NameDescription
parentString

Required. Format: parent=projects/{project_id}/locations/{location}

runtimeIdString

Required. User-defined unique ID of this Runtime.

runtimeRuntime

Required. The Runtime to be created.

Returns
TypeDescription
OperationFuture<Runtime,OperationMetadata>

createRuntimeCallable()

public final UnaryCallable<CreateRuntimeRequest,Operation> createRuntimeCallable()

Creates a new Runtime in a given project and location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   CreateRuntimeRequest request =
       CreateRuntimeRequest.newBuilder()
           .setParent(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRuntimeId("runtimeId121455379")
           .setRuntime(Runtime.newBuilder().build())
           .setRequestId("requestId693933066")
           .build();
   ApiFuture<Operation> future =
       managedNotebookServiceClient.createRuntimeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateRuntimeRequest,Operation>

createRuntimeOperationCallable()

public final OperationCallable<CreateRuntimeRequest,Runtime,OperationMetadata> createRuntimeOperationCallable()

Creates a new Runtime in a given project and location.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   CreateRuntimeRequest request =
       CreateRuntimeRequest.newBuilder()
           .setParent(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRuntimeId("runtimeId121455379")
           .setRuntime(Runtime.newBuilder().build())
           .setRequestId("requestId693933066")
           .build();
   OperationFuture<Runtime, OperationMetadata> future =
       managedNotebookServiceClient.createRuntimeOperationCallable().futureCall(request);
   // Do something.
   Runtime response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateRuntimeRequest,Runtime,OperationMetadata>

deleteRuntimeAsync(DeleteRuntimeRequest request)

public final OperationFuture<Empty,OperationMetadata> deleteRuntimeAsync(DeleteRuntimeRequest request)

Deletes a single Runtime.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   DeleteRuntimeRequest request =
       DeleteRuntimeRequest.newBuilder()
           .setName(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRequestId("requestId693933066")
           .build();
   managedNotebookServiceClient.deleteRuntimeAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteRuntimeRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteRuntimeAsync(RuntimeName name)

public final OperationFuture<Empty,OperationMetadata> deleteRuntimeAsync(RuntimeName name)

Deletes a single Runtime.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   RuntimeName name = RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]");
   managedNotebookServiceClient.deleteRuntimeAsync(name).get();
 }
 
Parameter
NameDescription
nameRuntimeName

Required. Format: projects/{project_id}/locations/{location}/runtimes/{runtime_id}

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteRuntimeAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deleteRuntimeAsync(String name)

Deletes a single Runtime.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   String name = RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString();
   managedNotebookServiceClient.deleteRuntimeAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. Format: projects/{project_id}/locations/{location}/runtimes/{runtime_id}

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteRuntimeCallable()

public final UnaryCallable<DeleteRuntimeRequest,Operation> deleteRuntimeCallable()

Deletes a single Runtime.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   DeleteRuntimeRequest request =
       DeleteRuntimeRequest.newBuilder()
           .setName(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRequestId("requestId693933066")
           .build();
   ApiFuture<Operation> future =
       managedNotebookServiceClient.deleteRuntimeCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteRuntimeRequest,Operation>

deleteRuntimeOperationCallable()

public final OperationCallable<DeleteRuntimeRequest,Empty,OperationMetadata> deleteRuntimeOperationCallable()

Deletes a single Runtime.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ManagedNotebookServiceClient managedNotebookServiceClient =
     ManagedNotebookServiceClient.create()) {
   DeleteRuntimeRequest request =
       DeleteRuntimeRequest.newBuilder()
           .setName(RuntimeName.of("[PROJECT]", "[LOCATION]", "[RUNTIME]").toString())
           .setRequestId("requestId693933066")
           .build();
   OperationFuture<Empty, OperationMetadata> future =
       managedNotebookServiceClient.deleteRuntimeOperationCallable().futureCall(request);
   // Do something.