Class GenAiTuningServiceClient

java.lang.Object
com.google.cloud.aiplatform.v1.GenAiTuningServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@Generated("by gapic-generator-java") public class GenAiTuningServiceClient extends Object implements BackgroundResource
Service Description: A service for creating and managing GenAI Tuning Jobs.

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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   TuningJob tuningJob = TuningJob.newBuilder().build();
   TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob);
 }
 

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

Methods
Method Description Method Variants

CreateTuningJob

Creates a TuningJob. A created TuningJob right away will be attempted to be run.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createTuningJob(CreateTuningJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createTuningJob(LocationName parent, TuningJob tuningJob)

  • createTuningJob(String parent, TuningJob tuningJob)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createTuningJobCallable()

GetTuningJob

Gets a TuningJob.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getTuningJob(GetTuningJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getTuningJob(TuningJobName name)

  • getTuningJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getTuningJobCallable()

ListTuningJobs

Lists TuningJobs in a Location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listTuningJobs(ListTuningJobsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listTuningJobs(LocationName parent)

  • listTuningJobs(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listTuningJobsPagedCallable()

  • listTuningJobsCallable()

CancelTuningJob

Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • cancelTuningJob(CancelTuningJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • cancelTuningJob(TuningJobName name)

  • cancelTuningJob(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • cancelTuningJobCallable()

RebaseTunedModel

Rebase a TunedModel.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • rebaseTunedModelAsync(RebaseTunedModelRequest request)

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

  • rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef)

  • rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • rebaseTunedModelOperationCallable()

  • rebaseTunedModelCallable()

ListLocations

Lists information about the supported locations for this service.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLocations(ListLocationsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLocation(GetLocationRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLocationCallable()

SetIamPolicy

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setIamPolicy(SetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setIamPolicyCallable()

GetIamPolicy

Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getIamPolicy(GetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getIamPolicyCallable()

TestIamPermissions

Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • testIamPermissions(TestIamPermissionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • testIamPermissionsCallable()

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 GenAiTuningServiceSettings 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
 GenAiTuningServiceSettings genAiTuningServiceSettings =
     GenAiTuningServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 GenAiTuningServiceClient genAiTuningServiceClient =
     GenAiTuningServiceClient.create(genAiTuningServiceSettings);
 

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
 GenAiTuningServiceSettings genAiTuningServiceSettings =
     GenAiTuningServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 GenAiTuningServiceClient genAiTuningServiceClient =
     GenAiTuningServiceClient.create(genAiTuningServiceSettings);
 

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

  • Constructor Details

    • GenAiTuningServiceClient

      protected GenAiTuningServiceClient(GenAiTuningServiceSettings settings) throws IOException
      Constructs an instance of GenAiTuningServiceClient, 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.
      Throws:
      IOException
    • GenAiTuningServiceClient

      protected GenAiTuningServiceClient(GenAiTuningServiceStub stub)
  • Method Details

    • create

      public static final GenAiTuningServiceClient create() throws IOException
      Constructs an instance of GenAiTuningServiceClient with default settings.
      Throws:
      IOException
    • create

      public static final GenAiTuningServiceClient create(GenAiTuningServiceSettings settings) throws IOException
      Constructs an instance of GenAiTuningServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
      Throws:
      IOException
    • create

      public static final GenAiTuningServiceClient create(GenAiTuningServiceStub stub)
      Constructs an instance of GenAiTuningServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(GenAiTuningServiceSettings).
    • getSettings

      public final GenAiTuningServiceSettings getSettings()
    • getStub

      public GenAiTuningServiceStub getStub()
    • getOperationsClient

      public final OperationsClient getOperationsClient()
      Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
    • createTuningJob

      public final TuningJob createTuningJob(LocationName parent, TuningJob tuningJob)
      Creates a TuningJob. A created TuningJob right away will be attempted to be run.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         TuningJob tuningJob = TuningJob.newBuilder().build();
         TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob);
       }
       
      Parameters:
      parent - Required. The resource name of the Location to create the TuningJob in. Format: `projects/{project}/locations/{location}`
      tuningJob - Required. The TuningJob to create.
      Throws:
      ApiException - if the remote call fails
    • createTuningJob

      public final TuningJob createTuningJob(String parent, TuningJob tuningJob)
      Creates a TuningJob. A created TuningJob right away will be attempted to be run.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         TuningJob tuningJob = TuningJob.newBuilder().build();
         TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob);
       }
       
      Parameters:
      parent - Required. The resource name of the Location to create the TuningJob in. Format: `projects/{project}/locations/{location}`
      tuningJob - Required. The TuningJob to create.
      Throws:
      ApiException - if the remote call fails
    • createTuningJob

      public final TuningJob createTuningJob(CreateTuningJobRequest request)
      Creates a TuningJob. A created TuningJob right away will be attempted to be run.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         CreateTuningJobRequest request =
             CreateTuningJobRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setTuningJob(TuningJob.newBuilder().build())
                 .build();
         TuningJob response = genAiTuningServiceClient.createTuningJob(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • createTuningJobCallable

      public final UnaryCallable<CreateTuningJobRequest,TuningJob> createTuningJobCallable()
      Creates a TuningJob. A created TuningJob right away will be attempted to be run.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         CreateTuningJobRequest request =
             CreateTuningJobRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setTuningJob(TuningJob.newBuilder().build())
                 .build();
         ApiFuture<TuningJob> future =
             genAiTuningServiceClient.createTuningJobCallable().futureCall(request);
         // Do something.
         TuningJob response = future.get();
       }
       
    • getTuningJob

      public final TuningJob getTuningJob(TuningJobName name)
      Gets a TuningJob.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         TuningJobName name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]");
         TuningJob response = genAiTuningServiceClient.getTuningJob(name);
       }
       
      Parameters:
      name - Required. The name of the TuningJob resource. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`
      Throws:
      ApiException - if the remote call fails
    • getTuningJob

      public final TuningJob getTuningJob(String name)
      Gets a TuningJob.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         String name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString();
         TuningJob response = genAiTuningServiceClient.getTuningJob(name);
       }
       
      Parameters:
      name - Required. The name of the TuningJob resource. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`
      Throws:
      ApiException - if the remote call fails
    • getTuningJob

      public final TuningJob getTuningJob(GetTuningJobRequest request)
      Gets a TuningJob.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetTuningJobRequest request =
             GetTuningJobRequest.newBuilder()
                 .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString())
                 .build();
         TuningJob response = genAiTuningServiceClient.getTuningJob(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getTuningJobCallable

      public final UnaryCallable<GetTuningJobRequest,TuningJob> getTuningJobCallable()
      Gets a TuningJob.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetTuningJobRequest request =
             GetTuningJobRequest.newBuilder()
                 .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString())
                 .build();
         ApiFuture<TuningJob> future =
             genAiTuningServiceClient.getTuningJobCallable().futureCall(request);
         // Do something.
         TuningJob response = future.get();
       }
       
    • listTuningJobs

      Lists TuningJobs in a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         for (TuningJob element : genAiTuningServiceClient.listTuningJobs(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The resource name of the Location to list the TuningJobs from. Format: `projects/{project}/locations/{location}`
      Throws:
      ApiException - if the remote call fails
    • listTuningJobs

      public final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(String parent)
      Lists TuningJobs in a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         for (TuningJob element : genAiTuningServiceClient.listTuningJobs(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The resource name of the Location to list the TuningJobs from. Format: `projects/{project}/locations/{location}`
      Throws:
      ApiException - if the remote call fails
    • listTuningJobs

      Lists TuningJobs in a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListTuningJobsRequest request =
             ListTuningJobsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (TuningJob element : genAiTuningServiceClient.listTuningJobs(request).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • listTuningJobsPagedCallable

      Lists TuningJobs in a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListTuningJobsRequest request =
             ListTuningJobsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<TuningJob> future =
             genAiTuningServiceClient.listTuningJobsPagedCallable().futureCall(request);
         // Do something.
         for (TuningJob element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listTuningJobsCallable

      public final UnaryCallable<ListTuningJobsRequest,ListTuningJobsResponse> listTuningJobsCallable()
      Lists TuningJobs in a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListTuningJobsRequest request =
             ListTuningJobsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListTuningJobsResponse response =
               genAiTuningServiceClient.listTuningJobsCallable().call(request);
           for (TuningJob element : response.getTuningJobsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • cancelTuningJob

      public final void cancelTuningJob(TuningJobName name)
      Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         TuningJobName name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]");
         genAiTuningServiceClient.cancelTuningJob(name);
       }
       
      Parameters:
      name - Required. The name of the TuningJob to cancel. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`
      Throws:
      ApiException - if the remote call fails
    • cancelTuningJob

      public final void cancelTuningJob(String name)
      Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         String name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString();
         genAiTuningServiceClient.cancelTuningJob(name);
       }
       
      Parameters:
      name - Required. The name of the TuningJob to cancel. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`
      Throws:
      ApiException - if the remote call fails
    • cancelTuningJob

      public final void cancelTuningJob(CancelTuningJobRequest request)
      Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         CancelTuningJobRequest request =
             CancelTuningJobRequest.newBuilder()
                 .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString())
                 .build();
         genAiTuningServiceClient.cancelTuningJob(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • cancelTuningJobCallable

      public final UnaryCallable<CancelTuningJobRequest,com.google.protobuf.Empty> cancelTuningJobCallable()
      Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         CancelTuningJobRequest request =
             CancelTuningJobRequest.newBuilder()
                 .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString())
                 .build();
         ApiFuture<Empty> future =
             genAiTuningServiceClient.cancelTuningJobCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • rebaseTunedModelAsync

      public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef)
      Rebase a TunedModel.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         TunedModelRef tunedModelRef = TunedModelRef.newBuilder().build();
         TuningJob response =
             genAiTuningServiceClient.rebaseTunedModelAsync(parent, tunedModelRef).get();
       }
       
      Parameters:
      parent - Required. The resource name of the Location into which to rebase the Model. Format: `projects/{project}/locations/{location}`
      tunedModelRef - Required. TunedModel reference to retrieve the legacy model information.
      Throws:
      ApiException - if the remote call fails
    • rebaseTunedModelAsync

      public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef)
      Rebase a TunedModel.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         TunedModelRef tunedModelRef = TunedModelRef.newBuilder().build();
         TuningJob response =
             genAiTuningServiceClient.rebaseTunedModelAsync(parent, tunedModelRef).get();
       }
       
      Parameters:
      parent - Required. The resource name of the Location into which to rebase the Model. Format: `projects/{project}/locations/{location}`
      tunedModelRef - Required. TunedModel reference to retrieve the legacy model information.
      Throws:
      ApiException - if the remote call fails
    • rebaseTunedModelAsync

      Rebase a TunedModel.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         RebaseTunedModelRequest request =
             RebaseTunedModelRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setTunedModelRef(TunedModelRef.newBuilder().build())
                 .setTuningJob(TuningJob.newBuilder().build())
                 .setArtifactDestination(GcsDestination.newBuilder().build())
                 .setDeployToSameEndpoint(true)
                 .build();
         TuningJob response = genAiTuningServiceClient.rebaseTunedModelAsync(request).get();
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • rebaseTunedModelOperationCallable

      public final OperationCallable<RebaseTunedModelRequest,TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelOperationCallable()
      Rebase a TunedModel.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         RebaseTunedModelRequest request =
             RebaseTunedModelRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setTunedModelRef(TunedModelRef.newBuilder().build())
                 .setTuningJob(TuningJob.newBuilder().build())
                 .setArtifactDestination(GcsDestination.newBuilder().build())
                 .setDeployToSameEndpoint(true)
                 .build();
         OperationFuture<TuningJob, RebaseTunedModelOperationMetadata> future =
             genAiTuningServiceClient.rebaseTunedModelOperationCallable().futureCall(request);
         // Do something.
         TuningJob response = future.get();
       }
       
    • rebaseTunedModelCallable

      public final UnaryCallable<RebaseTunedModelRequest,Operation> rebaseTunedModelCallable()
      Rebase a TunedModel.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         RebaseTunedModelRequest request =
             RebaseTunedModelRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setTunedModelRef(TunedModelRef.newBuilder().build())
                 .setTuningJob(TuningJob.newBuilder().build())
                 .setArtifactDestination(GcsDestination.newBuilder().build())
                 .setDeployToSameEndpoint(true)
                 .build();
         ApiFuture<Operation> future =
             genAiTuningServiceClient.rebaseTunedModelCallable().futureCall(request);
         // Do something.
         Operation response = future.get();
       }
       
    • listLocations

      Lists information about the supported locations for this service.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (Location element : genAiTuningServiceClient.listLocations(request).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • listLocationsPagedCallable

      Lists information about the supported locations for this service.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<Location> future =
             genAiTuningServiceClient.listLocationsPagedCallable().futureCall(request);
         // Do something.
         for (Location element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listLocationsCallable

      public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()
      Lists information about the supported locations for this service.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListLocationsResponse response =
               genAiTuningServiceClient.listLocationsCallable().call(request);
           for (Location element : response.getLocationsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • getLocation

      public final Location getLocation(GetLocationRequest request)
      Gets information about a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
         Location response = genAiTuningServiceClient.getLocation(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getLocationCallable

      public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()
      Gets information about a 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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
         ApiFuture<Location> future =
             genAiTuningServiceClient.getLocationCallable().futureCall(request);
         // Do something.
         Location response = future.get();
       }
       
    • setIamPolicy

      public final Policy setIamPolicy(SetIamPolicyRequest request)
      Sets the access control policy on the specified resource. Replacesany existing policy.

      Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         Policy response = genAiTuningServiceClient.setIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • setIamPolicyCallable

      public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
      Sets the access control policy on the specified resource. Replacesany existing policy.

      Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         ApiFuture<Policy> future =
             genAiTuningServiceClient.setIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • getIamPolicy

      public final Policy getIamPolicy(GetIamPolicyRequest request)
      Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         Policy response = genAiTuningServiceClient.getIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getIamPolicyCallable

      public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()
      Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         ApiFuture<Policy> future =
             genAiTuningServiceClient.getIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • testIamPermissions

      public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
      Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

      Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         TestIamPermissionsResponse response = genAiTuningServiceClient.testIamPermissions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • testIamPermissionsCallable

      public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()
      Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

      Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

      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 (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(
                     EndpointName.ofProjectLocationEndpointName(
                             "[PROJECT]", "[LOCATION]", "[ENDPOINT]")
                         .toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         ApiFuture<TestIamPermissionsResponse> future =
             genAiTuningServiceClient.testIamPermissionsCallable().futureCall(request);
         // Do something.
         TestIamPermissionsResponse response = future.get();
       }
       
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException