Class DatasetServiceClient (3.32.0)

GitHub RepositoryProduct ReferenceREST DocumentationRPC Documentation

Service Description: The service that manages Vertex AI Dataset and its child resources.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   Dataset response = datasetServiceClient.getDataset(name);
 }
 

Note: close() needs to be called on the DatasetServiceClient 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 DatasetServiceSettings 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
 DatasetServiceSettings datasetServiceSettings =
     DatasetServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings);
 

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
 DatasetServiceSettings datasetServiceSettings =
     DatasetServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings);
 

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

Inheritance

java.lang.Object > DatasetServiceClient

Static Methods

create()

public static final DatasetServiceClient create()

Constructs an instance of DatasetServiceClient with default settings.

Returns
TypeDescription
DatasetServiceClient
Exceptions
TypeDescription
IOException

create(DatasetServiceSettings settings)

public static final DatasetServiceClient create(DatasetServiceSettings settings)

Constructs an instance of DatasetServiceClient, 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
settingsDatasetServiceSettings
Returns
TypeDescription
DatasetServiceClient
Exceptions
TypeDescription
IOException

create(DatasetServiceStub stub)

public static final DatasetServiceClient create(DatasetServiceStub stub)

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

Parameter
NameDescription
stubDatasetServiceStub
Returns
TypeDescription
DatasetServiceClient

Constructors

DatasetServiceClient(DatasetServiceSettings settings)

protected DatasetServiceClient(DatasetServiceSettings settings)

Constructs an instance of DatasetServiceClient, 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
settingsDatasetServiceSettings

DatasetServiceClient(DatasetServiceStub stub)

protected DatasetServiceClient(DatasetServiceStub stub)
Parameter
NameDescription
stubDatasetServiceStub

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()

createDatasetAsync(CreateDatasetRequest request)

public final OperationFuture<Dataset,CreateDatasetOperationMetadata> createDatasetAsync(CreateDatasetRequest request)

Creates a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetRequest request =
       CreateDatasetRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDataset(Dataset.newBuilder().build())
           .build();
   Dataset response = datasetServiceClient.createDatasetAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateDatasetRequest

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

Returns
TypeDescription
OperationFuture<Dataset,CreateDatasetOperationMetadata>

createDatasetAsync(LocationName parent, Dataset dataset)

public final OperationFuture<Dataset,CreateDatasetOperationMetadata> createDatasetAsync(LocationName parent, Dataset dataset)

Creates a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Dataset dataset = Dataset.newBuilder().build();
   Dataset response = datasetServiceClient.createDatasetAsync(parent, dataset).get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The resource name of the Location to create the Dataset in. Format: projects/{project}/locations/{location}

datasetDataset

Required. The Dataset to create.

Returns
TypeDescription
OperationFuture<Dataset,CreateDatasetOperationMetadata>

createDatasetAsync(String parent, Dataset dataset)

public final OperationFuture<Dataset,CreateDatasetOperationMetadata> createDatasetAsync(String parent, Dataset dataset)

Creates a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Dataset dataset = Dataset.newBuilder().build();
   Dataset response = datasetServiceClient.createDatasetAsync(parent, dataset).get();
 }
 
Parameters
NameDescription
parentString

Required. The resource name of the Location to create the Dataset in. Format: projects/{project}/locations/{location}

datasetDataset

Required. The Dataset to create.

Returns
TypeDescription
OperationFuture<Dataset,CreateDatasetOperationMetadata>

createDatasetCallable()

public final UnaryCallable<CreateDatasetRequest,Operation> createDatasetCallable()

Creates a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetRequest request =
       CreateDatasetRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDataset(Dataset.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       datasetServiceClient.createDatasetCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateDatasetRequest,Operation>

createDatasetOperationCallable()

public final OperationCallable<CreateDatasetRequest,Dataset,CreateDatasetOperationMetadata> createDatasetOperationCallable()

Creates a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetRequest request =
       CreateDatasetRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDataset(Dataset.newBuilder().build())
           .build();
   OperationFuture<Dataset, CreateDatasetOperationMetadata> future =
       datasetServiceClient.createDatasetOperationCallable().futureCall(request);
   // Do something.
   Dataset response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateDatasetRequest,Dataset,CreateDatasetOperationMetadata>

createDatasetVersionAsync(CreateDatasetVersionRequest request)

public final OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata> createDatasetVersionAsync(CreateDatasetVersionRequest request)

Create a version from a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetVersionRequest request =
       CreateDatasetVersionRequest.newBuilder()
           .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setDatasetVersion(DatasetVersion.newBuilder().build())
           .build();
   DatasetVersion response = datasetServiceClient.createDatasetVersionAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateDatasetVersionRequest

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

Returns
TypeDescription
OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata>

createDatasetVersionAsync(DatasetName parent, DatasetVersion datasetVersion)

public final OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata> createDatasetVersionAsync(DatasetName parent, DatasetVersion datasetVersion)

Create a version from a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DatasetName parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   DatasetVersion datasetVersion = DatasetVersion.newBuilder().build();
   DatasetVersion response =
       datasetServiceClient.createDatasetVersionAsync(parent, datasetVersion).get();
 }
 
Parameters
NameDescription
parentDatasetName

Required. The name of the Dataset resource. Format: projects/{project}/locations/{location}/datasets/{dataset}

datasetVersionDatasetVersion

Required. The version to be created. The same CMEK policies with the original Dataset will be applied the dataset version. So here we don't need to specify the EncryptionSpecType here.

Returns
TypeDescription
OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata>

createDatasetVersionAsync(String parent, DatasetVersion datasetVersion)

public final OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata> createDatasetVersionAsync(String parent, DatasetVersion datasetVersion)

Create a version from a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   String parent = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   DatasetVersion datasetVersion = DatasetVersion.newBuilder().build();
   DatasetVersion response =
       datasetServiceClient.createDatasetVersionAsync(parent, datasetVersion).get();
 }
 
Parameters
NameDescription
parentString

Required. The name of the Dataset resource. Format: projects/{project}/locations/{location}/datasets/{dataset}

datasetVersionDatasetVersion

Required. The version to be created. The same CMEK policies with the original Dataset will be applied the dataset version. So here we don't need to specify the EncryptionSpecType here.

Returns
TypeDescription
OperationFuture<DatasetVersion,CreateDatasetVersionOperationMetadata>

createDatasetVersionCallable()

public final UnaryCallable<CreateDatasetVersionRequest,Operation> createDatasetVersionCallable()

Create a version from a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetVersionRequest request =
       CreateDatasetVersionRequest.newBuilder()
           .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setDatasetVersion(DatasetVersion.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       datasetServiceClient.createDatasetVersionCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateDatasetVersionRequest,Operation>

createDatasetVersionOperationCallable()

public final OperationCallable<CreateDatasetVersionRequest,DatasetVersion,CreateDatasetVersionOperationMetadata> createDatasetVersionOperationCallable()

Create a version from a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   CreateDatasetVersionRequest request =
       CreateDatasetVersionRequest.newBuilder()
           .setParent(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setDatasetVersion(DatasetVersion.newBuilder().build())
           .build();
   OperationFuture<DatasetVersion, CreateDatasetVersionOperationMetadata> future =
       datasetServiceClient.createDatasetVersionOperationCallable().futureCall(request);
   // Do something.
   DatasetVersion response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateDatasetVersionRequest,DatasetVersion,CreateDatasetVersionOperationMetadata>

deleteDatasetAsync(DatasetName name)

public final OperationFuture<Empty,DeleteOperationMetadata> deleteDatasetAsync(DatasetName name)

Deletes a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DatasetName name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   datasetServiceClient.deleteDatasetAsync(name).get();
 }
 
Parameter
NameDescription
nameDatasetName

Required. The resource name of the Dataset to delete. Format: projects/{project}/locations/{location}/datasets/{dataset}

Returns
TypeDescription
OperationFuture<Empty,DeleteOperationMetadata>

deleteDatasetAsync(DeleteDatasetRequest request)

public final OperationFuture<Empty,DeleteOperationMetadata> deleteDatasetAsync(DeleteDatasetRequest request)

Deletes a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DeleteDatasetRequest request =
       DeleteDatasetRequest.newBuilder()
           .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   datasetServiceClient.deleteDatasetAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteDatasetRequest

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

Returns
TypeDescription
OperationFuture<Empty,DeleteOperationMetadata>

deleteDatasetAsync(String name)

public final OperationFuture<Empty,DeleteOperationMetadata> deleteDatasetAsync(String name)

Deletes a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   String name = DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   datasetServiceClient.deleteDatasetAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the Dataset to delete. Format: projects/{project}/locations/{location}/datasets/{dataset}

Returns
TypeDescription
OperationFuture<Empty,DeleteOperationMetadata>

deleteDatasetCallable()

public final UnaryCallable<DeleteDatasetRequest,Operation> deleteDatasetCallable()

Deletes a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DeleteDatasetRequest request =
       DeleteDatasetRequest.newBuilder()
           .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   ApiFuture<Operation> future =
       datasetServiceClient.deleteDatasetCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteDatasetRequest,Operation>

deleteDatasetOperationCallable()

public final OperationCallable<DeleteDatasetRequest,Empty,DeleteOperationMetadata> deleteDatasetOperationCallable()

Deletes a Dataset.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DeleteDatasetRequest request =
       DeleteDatasetRequest.newBuilder()
           .setName(DatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   OperationFuture<Empty, DeleteOperationMetadata> future =
       datasetServiceClient.deleteDatasetOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteDatasetRequest,Empty,DeleteOperationMetadata>

deleteDatasetVersionAsync(DatasetVersionName name)

public final OperationFuture<Empty,DeleteOperationMetadata> deleteDatasetVersionAsync(DatasetVersionName name)

Deletes a Dataset version.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DatasetVersionName name =
       DatasetVersionName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[DATASET_VERSION]");
   datasetServiceClient.deleteDatasetVersionAsync(name).get();
 }
 
Parameter
NameDescription
nameDatasetVersionName

Required. The resource name of the Dataset version to delete. Format: projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}

Returns
TypeDescription
OperationFuture<Empty,DeleteOperationMetadata>

deleteDatasetVersionAsync(DeleteDatasetVersionRequest request)

public final OperationFuture<Empty,DeleteOperationMetadata> deleteDatasetVersionAsync(DeleteDatasetVersionRequest request)

Deletes a Dataset version.

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 (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create()) {
   DeleteDatasetVersionRequest request =
       DeleteDatasetVersionRequest.newBuilder()
           .setName(
               DatasetVersionName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[DATASET_VERSION]")
                   .toString())
           .build();
   datasetServiceClient.deleteDatasetVersionAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteDatasetVersionRequest

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

Returns
TypeDescription