Class GenAiTuningServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of GenAiTuningServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidcancelTuningJob(CancelTuningJobRequest request) Cancels a TuningJob.final voidcancelTuningJob(TuningJobName name) Cancels a TuningJob.final voidcancelTuningJob(String name) Cancels a TuningJob.final UnaryCallable<CancelTuningJobRequest,com.google.protobuf.Empty> Cancels a TuningJob.final voidclose()static final GenAiTuningServiceClientcreate()Constructs an instance of GenAiTuningServiceClient with default settings.static final GenAiTuningServiceClientcreate(GenAiTuningServiceSettings settings) Constructs an instance of GenAiTuningServiceClient, using the given settings.static final GenAiTuningServiceClientcreate(GenAiTuningServiceStub stub) Constructs an instance of GenAiTuningServiceClient, using the given stub for making calls.final TuningJobcreateTuningJob(CreateTuningJobRequest request) Creates a TuningJob.final TuningJobcreateTuningJob(LocationName parent, TuningJob tuningJob) Creates a TuningJob.final TuningJobcreateTuningJob(String parent, TuningJob tuningJob) Creates a TuningJob.Creates a TuningJob.final PolicygetIamPolicy(GetIamPolicyRequest request) Gets the access control policy for a resource.Gets the access control policy for a resource.final LocationgetLocation(GetLocationRequest request) Gets information about a location.Gets information about a location.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.getStub()final TuningJobgetTuningJob(GetTuningJobRequest request) Gets a TuningJob.final TuningJobgetTuningJob(TuningJobName name) Gets a TuningJob.final TuningJobgetTuningJob(String name) Gets a TuningJob.Gets a TuningJob.booleanbooleanlistLocations(ListLocationsRequest request) Lists information about the supported locations for this service.Lists information about the supported locations for this service.Lists information about the supported locations for this service.listTuningJobs(ListTuningJobsRequest request) Lists TuningJobs in a Location.listTuningJobs(LocationName parent) Lists TuningJobs in a Location.listTuningJobs(String parent) Lists TuningJobs in a Location.Lists TuningJobs in a Location.Lists TuningJobs in a Location.rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef) Rebase a TunedModel.Rebase a TunedModel.rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef) Rebase a TunedModel.Rebase a TunedModel.Rebase a TunedModel.final PolicysetIamPolicy(SetIamPolicyRequest request) Sets the access control policy on the specified resource.Sets the access control policy on the specified resource.voidshutdown()voidReturns permissions that a caller has on the specified resource.Returns permissions that a caller has on the specified resource.
-
Constructor Details
-
GenAiTuningServiceClient
Constructs an instance of GenAiTuningServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
GenAiTuningServiceClient
-
-
Method Details
-
create
Constructs an instance of GenAiTuningServiceClient with default settings.- Throws:
IOException
-
create
public static final GenAiTuningServiceClient create(GenAiTuningServiceSettings settings) throws IOException Constructs an instance of GenAiTuningServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of GenAiTuningServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(GenAiTuningServiceSettings). -
getSettings
-
getStub
-
getOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
createTuningJob
Creates a TuningJob. A created TuningJob right away will be attempted to be run.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); TuningJob tuningJob = TuningJob.newBuilder().build(); TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob); }- Parameters:
parent- Required. The resource name of the Location to create the TuningJob in. Format: `projects/{project}/locations/{location}`tuningJob- Required. The TuningJob to create.- Throws:
ApiException- if the remote call fails
-
createTuningJob
Creates a TuningJob. A created TuningJob right away will be attempted to be run.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); TuningJob tuningJob = TuningJob.newBuilder().build(); TuningJob response = genAiTuningServiceClient.createTuningJob(parent, tuningJob); }- Parameters:
parent- Required. The resource name of the Location to create the TuningJob in. Format: `projects/{project}/locations/{location}`tuningJob- Required. The TuningJob to create.- Throws:
ApiException- if the remote call fails
-
createTuningJob
Creates a TuningJob. A created TuningJob right away will be attempted to be run.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { CreateTuningJobRequest request = CreateTuningJobRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setTuningJob(TuningJob.newBuilder().build()) .build(); TuningJob response = genAiTuningServiceClient.createTuningJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createTuningJobCallable
Creates a TuningJob. A created TuningJob right away will be attempted to be run.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { CreateTuningJobRequest request = CreateTuningJobRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setTuningJob(TuningJob.newBuilder().build()) .build(); ApiFuture<TuningJob> future = genAiTuningServiceClient.createTuningJobCallable().futureCall(request); // Do something. TuningJob response = future.get(); } -
getTuningJob
Gets a TuningJob.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { TuningJobName name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]"); TuningJob response = genAiTuningServiceClient.getTuningJob(name); }- Parameters:
name- Required. The name of the TuningJob resource. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`- Throws:
ApiException- if the remote call fails
-
getTuningJob
Gets a TuningJob.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { String name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString(); TuningJob response = genAiTuningServiceClient.getTuningJob(name); }- Parameters:
name- Required. The name of the TuningJob resource. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`- Throws:
ApiException- if the remote call fails
-
getTuningJob
Gets a TuningJob.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetTuningJobRequest request = GetTuningJobRequest.newBuilder() .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString()) .build(); TuningJob response = genAiTuningServiceClient.getTuningJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getTuningJobCallable
Gets a TuningJob.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetTuningJobRequest request = GetTuningJobRequest.newBuilder() .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString()) .build(); ApiFuture<TuningJob> future = genAiTuningServiceClient.getTuningJobCallable().futureCall(request); // Do something. TuningJob response = future.get(); } -
listTuningJobs
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); } }- Parameters:
parent- Required. The resource name of the Location to list the TuningJobs from. Format: `projects/{project}/locations/{location}`- Throws:
ApiException- if the remote call fails
-
listTuningJobs
Lists TuningJobs in a Location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); for (TuningJob element : genAiTuningServiceClient.listTuningJobs(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The resource name of the Location to list the TuningJobs from. Format: `projects/{project}/locations/{location}`- Throws:
ApiException- if the remote call fails
-
listTuningJobs
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); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
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); } } -
listTuningJobsCallable
Lists TuningJobs in a Location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { ListTuningJobsRequest request = ListTuningJobsRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListTuningJobsResponse response = genAiTuningServiceClient.listTuningJobsCallable().call(request); for (TuningJob element : response.getTuningJobsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
cancelTuningJob
Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { TuningJobName name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]"); genAiTuningServiceClient.cancelTuningJob(name); }- Parameters:
name- Required. The name of the TuningJob to cancel. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`- Throws:
ApiException- if the remote call fails
-
cancelTuningJob
Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { String name = TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString(); genAiTuningServiceClient.cancelTuningJob(name); }- Parameters:
name- Required. The name of the TuningJob to cancel. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`- Throws:
ApiException- if the remote call fails
-
cancelTuningJob
Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { CancelTuningJobRequest request = CancelTuningJobRequest.newBuilder() .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString()) .build(); genAiTuningServiceClient.cancelTuningJob(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
cancelTuningJobCallable
public final UnaryCallable<CancelTuningJobRequest,com.google.protobuf.Empty> cancelTuningJobCallable()Cancels a TuningJob. Starts asynchronous cancellation on the TuningJob. The server makes a best effort to cancel the job, but success is not guaranteed. Clients can use [GenAiTuningService.GetTuningJob][google.cloud.aiplatform.v1.GenAiTuningService.GetTuningJob] or other methods to check whether the cancellation succeeded or whether the job completed despite cancellation. On successful cancellation, the TuningJob is not deleted; instead it becomes a job with a [TuningJob.error][google.cloud.aiplatform.v1.TuningJob.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`, and [TuningJob.state][google.cloud.aiplatform.v1.TuningJob.state] is set to `CANCELLED`.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { CancelTuningJobRequest request = CancelTuningJobRequest.newBuilder() .setName(TuningJobName.of("[PROJECT]", "[LOCATION]", "[TUNING_JOB]").toString()) .build(); ApiFuture<Empty> future = genAiTuningServiceClient.cancelTuningJobCallable().futureCall(request); // Do something. future.get(); } -
rebaseTunedModelAsync
public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(LocationName parent, TunedModelRef tunedModelRef) Rebase a TunedModel.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); TunedModelRef tunedModelRef = TunedModelRef.newBuilder().build(); TuningJob response = genAiTuningServiceClient.rebaseTunedModelAsync(parent, tunedModelRef).get(); }- Parameters:
parent- Required. The resource name of the Location into which to rebase the Model. Format: `projects/{project}/locations/{location}`tunedModelRef- Required. TunedModel reference to retrieve the legacy model information.- Throws:
ApiException- if the remote call fails
-
rebaseTunedModelAsync
public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(String parent, TunedModelRef tunedModelRef) Rebase a TunedModel.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); TunedModelRef tunedModelRef = TunedModelRef.newBuilder().build(); TuningJob response = genAiTuningServiceClient.rebaseTunedModelAsync(parent, tunedModelRef).get(); }- Parameters:
parent- Required. The resource name of the Location into which to rebase the Model. Format: `projects/{project}/locations/{location}`tunedModelRef- Required. TunedModel reference to retrieve the legacy model information.- Throws:
ApiException- if the remote call fails
-
rebaseTunedModelAsync
public final OperationFuture<TuningJob,RebaseTunedModelOperationMetadata> rebaseTunedModelAsync(RebaseTunedModelRequest request) Rebase a TunedModel.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { RebaseTunedModelRequest request = RebaseTunedModelRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setTunedModelRef(TunedModelRef.newBuilder().build()) .setTuningJob(TuningJob.newBuilder().build()) .setArtifactDestination(GcsDestination.newBuilder().build()) .setDeployToSameEndpoint(true) .build(); TuningJob response = genAiTuningServiceClient.rebaseTunedModelAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
rebaseTunedModelOperationCallable
public final OperationCallable<RebaseTunedModelRequest,TuningJob, rebaseTunedModelOperationCallable()RebaseTunedModelOperationMetadata> Rebase a TunedModel.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { RebaseTunedModelRequest request = RebaseTunedModelRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setTunedModelRef(TunedModelRef.newBuilder().build()) .setTuningJob(TuningJob.newBuilder().build()) .setArtifactDestination(GcsDestination.newBuilder().build()) .setDeployToSameEndpoint(true) .build(); OperationFuture<TuningJob, RebaseTunedModelOperationMetadata> future = genAiTuningServiceClient.rebaseTunedModelOperationCallable().futureCall(request); // Do something. TuningJob response = future.get(); } -
rebaseTunedModelCallable
Rebase a TunedModel.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { RebaseTunedModelRequest request = RebaseTunedModelRequest.newBuilder() .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) .setTunedModelRef(TunedModelRef.newBuilder().build()) .setTuningJob(TuningJob.newBuilder().build()) .setArtifactDestination(GcsDestination.newBuilder().build()) .setDeployToSameEndpoint(true) .build(); ApiFuture<Operation> future = genAiTuningServiceClient.rebaseTunedModelCallable().futureCall(request); // Do something. Operation response = future.get(); } -
listLocations
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); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
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); } } -
listLocationsCallable
Lists information about the supported locations for this service.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListLocationsResponse response = genAiTuningServiceClient.listLocationsCallable().call(request); for (Location element : response.getLocationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getLocation
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); Location response = genAiTuningServiceClient.getLocation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getLocationCallable
Gets information about a location.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); ApiFuture<Location> future = genAiTuningServiceClient.getLocationCallable().futureCall(request); // Do something. Location response = future.get(); } -
setIamPolicy
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = genAiTuningServiceClient.setIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
setIamPolicyCallable
Sets the access control policy on the specified resource. Replacesany existing policy.Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = genAiTuningServiceClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
getIamPolicy
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = genAiTuningServiceClient.getIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getIamPolicyCallable
Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = genAiTuningServiceClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
testIamPermissions
Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = genAiTuningServiceClient.testIamPermissions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
testIamPermissionsCallable
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (GenAiTuningServiceClient genAiTuningServiceClient = GenAiTuningServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource( EndpointName.ofProjectLocationEndpointName( "[PROJECT]", "[LOCATION]", "[ENDPOINT]") .toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = genAiTuningServiceClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-