@Generated(value="by gapic-generator-java") public class GenAiTuningServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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().
| 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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetTuningJob |
Gets a TuningJob. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListTuningJobs |
Lists TuningJobs in a Location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RebaseTunedModel |
Rebase a TunedModel. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
GenAiTuningServiceClient.ListLocationsFixedSizeCollection |
static class |
GenAiTuningServiceClient.ListLocationsPage |
static class |
GenAiTuningServiceClient.ListLocationsPagedResponse |
static class |
GenAiTuningServiceClient.ListTuningJobsFixedSizeCollection |
static class |
GenAiTuningServiceClient.ListTuningJobsPage |
static class |
GenAiTuningServiceClient.ListTuningJobsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
GenAiTuningServiceClient(GenAiTuningServiceSettings settings)
Constructs an instance of GenAiTuningServiceClient, using the given settings.
|
protected |
GenAiTuningServiceClient(GenAiTuningServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
cancelTuningJob(CancelTuningJobRequest request)
Cancels a TuningJob.
|
void |
cancelTuningJob(String name)
Cancels a TuningJob.
|
void |
cancelTuningJob(TuningJobName name)
Cancels a TuningJob.
|
com.google.api.gax.rpc.UnaryCallable<CancelTuningJobRequest,com.google.protobuf.Empty> |
cancelTuningJobCallable()
Cancels a TuningJob.
|
void |
close() |
static GenAiTuningServiceClient |
create()
Constructs an instance of GenAiTuningServiceClient with default settings.
|
static GenAiTuningServiceClient |
create(GenAiTuningServiceSettings settings)
Constructs an instance of GenAiTuningServiceClient, using the given settings.
|
static GenAiTuningServiceClient |
create(GenAiTuningServiceStub stub)
Constructs an instance of GenAiTuningServiceClient, using the given stub for making calls.
|
TuningJob |
createTuningJob(CreateTuningJobRequest request)
Creates a TuningJob.
|
TuningJob |
createTuningJob(LocationName parent,
TuningJob tuningJob)
Creates a TuningJob.
|
TuningJob |
createTuningJob(String parent,
TuningJob tuningJob)
Creates a TuningJob.
|
com.google.api.gax.rpc.UnaryCallable<CreateTuningJobRequest,TuningJob> |
createTuningJobCallable()
Creates a TuningJob.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a resource.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
GenAiTuningServiceSettings |
getSettings() |
GenAiTuningServiceStub |
getStub() |
TuningJob |
getTuningJob(GetTuningJobRequest request)
Gets a TuningJob.
|
TuningJob |
getTuningJob(String name)
Gets a TuningJob.
|
TuningJob |
getTuningJob(TuningJobName name)
Gets a TuningJob.
|
com.google.api.gax.rpc.UnaryCallable<GetTuningJobRequest,TuningJob> |
getTuningJobCallable()
Gets a TuningJob.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
GenAiTuningServiceClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,GenAiTuningServiceClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
GenAiTuningServiceClient.ListTuningJobsPagedResponse |
listTuningJobs(ListTuningJobsRequest request)
Lists TuningJobs in a Location.
|
GenAiTuningServiceClient.ListTuningJobsPagedResponse |
listTuningJobs(LocationName parent)
Lists TuningJobs in a Location.
|
GenAiTuningServiceClient.ListTuningJobsPagedResponse |
listTuningJobs(String parent)
Lists TuningJobs in a Location.
|
com.google.api.gax.rpc.UnaryCallable<ListTuningJobsRequest,ListTuningJobsResponse> |
listTuningJobsCallable()
Lists TuningJobs in a Location.
|
com.google.api.gax.rpc.UnaryCallable<ListTuningJobsRequest,GenAiTuningServiceClient.ListTuningJobsPagedResponse> |
listTuningJobsPagedCallable()
Lists TuningJobs in a Location.
|
com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> |
rebaseTunedModelAsync(LocationName parent,
TunedModelRef tunedModelRef)
Rebase a TunedModel.
|
com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> |
rebaseTunedModelAsync(RebaseTunedModelRequest request)
Rebase a TunedModel.
|
com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> |
rebaseTunedModelAsync(String parent,
TunedModelRef tunedModelRef)
Rebase a TunedModel.
|
com.google.api.gax.rpc.UnaryCallable<RebaseTunedModelRequest,com.google.longrunning.Operation> |
rebaseTunedModelCallable()
Rebase a TunedModel.
|
com.google.api.gax.rpc.OperationCallable<RebaseTunedModelRequest,TuningJob,RebaseTunedModelOperationMetadata> |
rebaseTunedModelOperationCallable()
Rebase a TunedModel.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
|
protected GenAiTuningServiceClient(GenAiTuningServiceSettings settings) throws IOException
IOExceptionprotected GenAiTuningServiceClient(GenAiTuningServiceStub stub)
public static final GenAiTuningServiceClient create() throws IOException
IOExceptionpublic static final GenAiTuningServiceClient create(GenAiTuningServiceSettings settings) throws IOException
IOExceptionpublic static final GenAiTuningServiceClient create(GenAiTuningServiceStub stub)
public final GenAiTuningServiceSettings getSettings()
public GenAiTuningServiceStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
public final TuningJob createTuningJob(LocationName parent, TuningJob 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()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
TuningJob tuningJob = TuningJob.newBuilder().build();
TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob);
}
parent - Required. The resource name of the Location to create the TuningJob in. Format:
`projects/{project}/locations/{location}`tuningJob - Required. The TuningJob to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final TuningJob createTuningJob(String parent, TuningJob 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 parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
TuningJob tuningJob = TuningJob.newBuilder().build();
TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob);
}
parent - Required. The resource name of the Location to create the TuningJob in. Format:
`projects/{project}/locations/{location}`tuningJob - Required. The TuningJob to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final TuningJob createTuningJob(CreateTuningJobRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateTuningJobRequest,TuningJob> createTuningJobCallable()
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();
}
public final TuningJob getTuningJob(TuningJobName name)
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);
}
name - Required. The name of the TuningJob resource. Format:
`projects/{project}/locations/{location}/tuningJobs/{tuning_job}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final TuningJob getTuningJob(String name)
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);
}
name - Required. The name of the TuningJob resource. Format:
`projects/{project}/locations/{location}/tuningJobs/{tuning_job}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final TuningJob getTuningJob(GetTuningJobRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetTuningJobRequest,TuningJob> getTuningJobCallable()
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();
}
public final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(LocationName parent)
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);
}
}
parent - Required. The resource name of the Location to list the TuningJobs from. Format:
`projects/{project}/locations/{location}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(String parent)
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);
}
}
parent - Required. The resource name of the Location to list the TuningJobs from. Format:
`projects/{project}/locations/{location}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final GenAiTuningServiceClient.ListTuningJobsPagedResponse listTuningJobs(ListTuningJobsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListTuningJobsRequest,GenAiTuningServiceClient.ListTuningJobsPagedResponse> listTuningJobsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListTuningJobsRequest,ListTuningJobsResponse> listTuningJobsCallable()
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;
}
}
}
public final void cancelTuningJob(TuningJobName name)
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);
}
name - Required. The name of the TuningJob to cancel. Format:
`projects/{project}/locations/{location}/tuningJobs/{tuning_job}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void cancelTuningJob(String name)
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);
}
name - Required. The name of the TuningJob to cancel. Format:
`projects/{project}/locations/{location}/tuningJobs/{tuning_job}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void cancelTuningJob(CancelTuningJobRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CancelTuningJobRequest,com.google.protobuf.Empty> cancelTuningJobCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef)
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();
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef)
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();
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(RebaseTunedModelRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<RebaseTunedModelRequest,TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<RebaseTunedModelRequest,com.google.longrunning.Operation> rebaseTunedModelCallable()
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();
}
public final GenAiTuningServiceClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,GenAiTuningServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
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;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
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();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
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();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
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();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
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();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.