Class GenAiTuningServiceClient (3.53.0)

GitHub RepositoryProduct ReferenceREST DocumentationRPC Documentation

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 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED, and 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. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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_DENIEDerrors.

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.

Inheritance

java.lang.Object > GenAiTuningServiceClient

Static Methods

create()

public static final GenAiTuningServiceClient create()

Constructs an instance of GenAiTuningServiceClient with default settings.

Returns
Type Description
GenAiTuningServiceClient
Exceptions
Type Description
IOException

create(GenAiTuningServiceSettings settings)

public static final GenAiTuningServiceClient create(GenAiTuningServiceSettings settings)

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.

Parameter
Name Description
settings GenAiTuningServiceSettings
Returns
Type Description
GenAiTuningServiceClient
Exceptions
Type Description
IOException

create(GenAiTuningServiceStub stub)

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

Parameter
Name Description
stub GenAiTuningServiceStub
Returns
Type Description
GenAiTuningServiceClient

Constructors

GenAiTuningServiceClient(GenAiTuningServiceSettings settings)

protected GenAiTuningServiceClient(GenAiTuningServiceSettings settings)

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.

Parameter
Name Description
settings GenAiTuningServiceSettings

GenAiTuningServiceClient(GenAiTuningServiceStub stub)

protected GenAiTuningServiceClient(GenAiTuningServiceStub stub)
Parameter
Name Description
stub GenAiTuningServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

cancelTuningJob(CancelTuningJobRequest request)

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 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED, and 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);
 }
 
Parameter
Name Description
request CancelTuningJobRequest

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

cancelTuningJob(TuningJobName name)

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 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED, and 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);
 }
 
Parameter
Name Description
name TuningJobName

Required. The name of the TuningJob to cancel. Format: projects/{project}/locations/{location}/tuningJobs/{tuning_job}

cancelTuningJob(String name)

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 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED, and 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);
 }
 
Parameter
Name Description
name String

Required. The name of the TuningJob to cancel. Format: projects/{project}/locations/{location}/tuningJobs/{tuning_job}

cancelTuningJobCallable()

public final UnaryCallable<CancelTuningJobRequest,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 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED, and 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();
 }
 
Returns
Type Description
UnaryCallable<CancelTuningJobRequest,Empty>

close()

public final void close()

createTuningJob(CreateTuningJobRequest request)

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);
 }
 
Parameter
Name Description
request CreateTuningJobRequest

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

Returns
Type Description
TuningJob

createTuningJob(LocationName parent, TuningJob tuningJob)

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
Name Description
parent LocationName

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

tuningJob TuningJob

Required. The TuningJob to create.

Returns
Type Description
TuningJob

createTuningJob(String parent, TuningJob tuningJob)

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
Name Description
parent String

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

tuningJob TuningJob

Required. The TuningJob to create.

Returns
Type Description
TuningJob

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();
 }
 
Returns
Type Description
UnaryCallable<CreateTuningJobRequest,TuningJob>

getIamPolicy(GetIamPolicyRequest request)

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);
 }
 
Parameter
Name Description
request com.google.iam.v1.GetIamPolicyRequest

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

Returns
Type Description
com.google.iam.v1.Policy

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();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getLocation(GetLocationRequest request)

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);
 }
 
Parameter
Name Description
request com.google.cloud.location.GetLocationRequest

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

Returns
Type Description
com.google.cloud.location.Location

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();
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location>

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.

Returns
Type Description
OperationsClient

getSettings()

public final GenAiTuningServiceSettings getSettings()
Returns
Type Description
GenAiTuningServiceSettings

getStub()

public GenAiTuningServiceStub getStub()
Returns
Type Description
GenAiTuningServiceStub

getTuningJob(GetTuningJobRequest request)

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);
 }
 
Parameter
Name Description
request GetTuningJobRequest

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

Returns
Type Description
TuningJob

getTuningJob(TuningJobName name)

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);
 }
 
Parameter
Name Description
name TuningJobName

Required. The name of the TuningJob resource. Format: projects/{project}/locations/{location}/tuningJobs/{tuning_job}

Returns
Type Description
TuningJob

getTuningJob(String name)

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);
 }
 
Parameter
Name Description
name String

Required. The name of the TuningJob resource. Format: projects/{project}/locations/{location}/tuningJobs/{tuning_job}

Returns
Type Description
TuningJob

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();
 }
 
Returns
Type Description
UnaryCallable<GetTuningJobRequest,TuningJob>

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listLocations(ListLocationsRequest request)

public final GenAiTuningServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request)

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);
   }
 }
 
Parameter
Name Description
request com.google.cloud.location.ListLocationsRequest

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

Returns
Type Description
GenAiTuningServiceClient.ListLocationsPagedResponse

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;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

public final UnaryCallable<ListLocationsRequest,GenAiTuningServiceClient.ListLocationsPagedResponse> 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);
   }
 }
 
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

listTuningJobs(ListTuningJobsRequest request)

public final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(ListTuningJobsRequest request)

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);
   }
 }
 
Parameter
Name Description
request ListTuningJobsRequest

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

Returns
Type Description
GenAiTuningServiceClient.ListTuningJobsPagedResponse

listTuningJobs(LocationName parent)

public final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(LocationName 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()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (TuningJob element : genAiTuningServiceClient.listTuningJobs(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent LocationName

Required. The resource name of the Location to list the TuningJobs from. Format: projects/{project}/locations/{location}

Returns
Type Description
GenAiTuningServiceClient.ListTuningJobsPagedResponse

listTuningJobs(String parent)

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);
   }
 }
 
Parameter
Name Description
parent String

Required. The resource name of the Location to list the TuningJobs from. Format: projects/{project}/locations/{location}

Returns
Type Description
GenAiTuningServiceClient.ListTuningJobsPagedResponse

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;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListTuningJobsRequest,ListTuningJobsResponse>

listTuningJobsPagedCallable()

public final UnaryCallable<ListTuningJobsRequest,GenAiTuningServiceClient.ListTuningJobsPagedResponse> 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);
   }
 }
 
Returns
Type Description
UnaryCallable<ListTuningJobsRequest,ListTuningJobsPagedResponse>

rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef)

public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef)

Rebase a TunedModel. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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
Name Description
parent LocationName

Required. The resource name of the Location into which to rebase the Model. Format: projects/{project}/locations/{location}

tunedModelRef TunedModelRef

Required. TunedModel reference to retrieve the legacy model information.

Returns
Type Description
OperationFuture<TuningJob,RebaseTunedModelOperationMetadata>

rebaseTunedModelAsync(RebaseTunedModelRequest request)

public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(RebaseTunedModelRequest request)

Rebase a TunedModel. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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();
 }
 
Parameter
Name Description
request RebaseTunedModelRequest

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

Returns
Type Description
OperationFuture<TuningJob,RebaseTunedModelOperationMetadata>

rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef)

public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef)

Rebase a TunedModel. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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
Name Description
parent String

Required. The resource name of the Location into which to rebase the Model. Format: projects/{project}/locations/{location}

tunedModelRef TunedModelRef

Required. TunedModel reference to retrieve the legacy model information.

Returns
Type Description
OperationFuture<TuningJob,RebaseTunedModelOperationMetadata>

rebaseTunedModelCallable()

public final UnaryCallable<RebaseTunedModelRequest,Operation> rebaseTunedModelCallable()

Rebase a TunedModel. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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();
 }
 
Returns
Type Description
UnaryCallable<RebaseTunedModelRequest,Operation>

rebaseTunedModelOperationCallable()

public final OperationCallable<RebaseTunedModelRequest,TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelOperationCallable()

Rebase a TunedModel. Creates a LongRunningOperation that takes a legacy Tuned GenAI model Reference and creates a TuningJob based on newly available model.

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();
 }
 
Returns
Type Description
OperationCallable<RebaseTunedModelRequest,TuningJob,RebaseTunedModelOperationMetadata>

setIamPolicy(SetIamPolicyRequest request)

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_DENIEDerrors.

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);
 }
 
Parameter
Name Description
request com.google.iam.v1.SetIamPolicyRequest

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

Returns
Type Description
com.google.iam.v1.Policy

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_DENIEDerrors.

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();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(TestIamPermissionsRequest request)

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);
 }
 
Parameter
Name Description
request com.google.iam.v1.TestIamPermissionsRequest

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

Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

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();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>