Class ModelServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
This service allows you to do the following:
- Initiate training of a model.
- Pause training of an existing model.
- List all the available models along with their metadata.
- Control their tuning schedule.
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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]");
Model response = modelServiceClient.getModel(name);
}
Note: close() needs to be called on the ModelServiceClient 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 |
|---|---|---|
CreateModel |
Creates a new model. |
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.
|
GetModel |
Gets a model. |
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.
|
PauseModel |
Pauses the training of an existing model. |
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.
|
ResumeModel |
Resumes the training of an existing model. |
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.
|
DeleteModel |
Deletes an existing model. |
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.
|
ListModels |
Lists all the models linked to this event store. |
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.
|
UpdateModel |
Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them. |
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.
|
TuneModel |
Tunes an existing model. |
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.
|
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 ModelServiceSettings 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
ModelServiceSettings modelServiceSettings =
ModelServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings);
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
ModelServiceSettings modelServiceSettings =
ModelServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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
ModelServiceSettings modelServiceSettings = ModelServiceSettings.newHttpJsonBuilder().build();
ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedModelServiceClient(ModelServiceSettings settings) Constructs an instance of ModelServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final ModelServiceClientcreate()Constructs an instance of ModelServiceClient with default settings.static final ModelServiceClientcreate(ModelServiceSettings settings) Constructs an instance of ModelServiceClient, using the given settings.static final ModelServiceClientcreate(ModelServiceStub stub) Constructs an instance of ModelServiceClient, using the given stub for making calls.createModelAsync(CatalogName parent, Model model) Creates a new model.createModelAsync(CreateModelRequest request) Creates a new model.createModelAsync(String parent, Model model) Creates a new model.Creates a new model.Creates a new model.final voiddeleteModel(DeleteModelRequest request) Deletes an existing model.final voiddeleteModel(ModelName name) Deletes an existing model.final voiddeleteModel(String name) Deletes an existing model.final UnaryCallable<DeleteModelRequest,com.google.protobuf.Empty> Deletes an existing model.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final ModelgetModel(GetModelRequest request) Gets a model.final ModelGets a model.final ModelGets a model.final UnaryCallable<GetModelRequest,Model> Gets a model.final OperationsClientReturns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.final ModelServiceSettingsgetStub()booleanbooleanlistModels(CatalogName parent) Lists all the models linked to this event store.listModels(ListModelsRequest request) Lists all the models linked to this event store.listModels(String parent) Lists all the models linked to this event store.Lists all the models linked to this event store.Lists all the models linked to this event store.final ModelpauseModel(ModelName name) Pauses the training of an existing model.final ModelpauseModel(PauseModelRequest request) Pauses the training of an existing model.final ModelpauseModel(String name) Pauses the training of an existing model.final UnaryCallable<PauseModelRequest,Model> Pauses the training of an existing model.final ModelresumeModel(ResumeModelRequest request) Resumes the training of an existing model.final ModelresumeModel(String name) Resumes the training of an existing model.final UnaryCallable<ResumeModelRequest,Model> Resumes the training of an existing model.voidshutdown()voidtuneModelAsync(ModelName name) Tunes an existing model.tuneModelAsync(TuneModelRequest request) Tunes an existing model.tuneModelAsync(String name) Tunes an existing model.Tunes an existing model.Tunes an existing model.final ModelupdateModel(Model model, com.google.protobuf.FieldMask updateMask) Update of model metadata.final ModelupdateModel(UpdateModelRequest request) Update of model metadata.final UnaryCallable<UpdateModelRequest,Model> Update of model metadata.
-
Constructor Details
-
ModelServiceClient
Constructs an instance of ModelServiceClient, 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
-
ModelServiceClient
-
-
Method Details
-
create
Constructs an instance of ModelServiceClient with default settings.- Throws:
IOException
-
create
Constructs an instance of ModelServiceClient, 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 ModelServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ModelServiceSettings). -
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. -
getHttpJsonOperationsClient
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call. -
createModelAsync
public final OperationFuture<Model,CreateModelMetadata> createModelAsync(CatalogName parent, Model model) Creates a new model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); Model model = Model.newBuilder().build(); Model response = modelServiceClient.createModelAsync(parent, model).get(); }- Parameters:
parent- Required. The parent resource under which to create the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`model- Required. The payload of the [Model][google.cloud.retail.v2alpha.Model] to create.- Throws:
ApiException- if the remote call fails
-
createModelAsync
public final OperationFuture<Model,CreateModelMetadata> createModelAsync(String parent, Model model) Creates a new model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); Model model = Model.newBuilder().build(); Model response = modelServiceClient.createModelAsync(parent, model).get(); }- Parameters:
parent- Required. The parent resource under which to create the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`model- Required. The payload of the [Model][google.cloud.retail.v2alpha.Model] to create.- Throws:
ApiException- if the remote call fails
-
createModelAsync
public final OperationFuture<Model,CreateModelMetadata> createModelAsync(CreateModelRequest request) Creates a new model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { CreateModelRequest request = CreateModelRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setModel(Model.newBuilder().build()) .setDryRun(true) .build(); Model response = modelServiceClient.createModelAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createModelOperationCallable
public final OperationCallable<CreateModelRequest,Model, createModelOperationCallable()CreateModelMetadata> Creates a new model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { CreateModelRequest request = CreateModelRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setModel(Model.newBuilder().build()) .setDryRun(true) .build(); OperationFuture<Model, CreateModelMetadata> future = modelServiceClient.createModelOperationCallable().futureCall(request); // Do something. Model response = future.get(); } -
createModelCallable
Creates a new model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { CreateModelRequest request = CreateModelRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setModel(Model.newBuilder().build()) .setDryRun(true) .build(); ApiFuture<Operation> future = modelServiceClient.createModelCallable().futureCall(request); // Do something. Operation response = future.get(); } -
getModel
Gets a model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]"); Model response = modelServiceClient.getModel(name); }- Parameters:
name- Required. The resource name of the [Model][google.cloud.retail.v2alpha.Model] to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
getModel
Gets a model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString(); Model response = modelServiceClient.getModel(name); }- Parameters:
name- Required. The resource name of the [Model][google.cloud.retail.v2alpha.Model] to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
getModel
Gets a model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { GetModelRequest request = GetModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); Model response = modelServiceClient.getModel(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getModelCallable
Gets a model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { GetModelRequest request = GetModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); ApiFuture<Model> future = modelServiceClient.getModelCallable().futureCall(request); // Do something. Model response = future.get(); } -
pauseModel
Pauses the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]"); Model response = modelServiceClient.pauseModel(name); }- Parameters:
name- Required. The name of the model to pause. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
pauseModel
Pauses the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString(); Model response = modelServiceClient.pauseModel(name); }- Parameters:
name- Required. The name of the model to pause. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
pauseModel
Pauses the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { PauseModelRequest request = PauseModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); Model response = modelServiceClient.pauseModel(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
pauseModelCallable
Pauses the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { PauseModelRequest request = PauseModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); ApiFuture<Model> future = modelServiceClient.pauseModelCallable().futureCall(request); // Do something. Model response = future.get(); } -
resumeModel
Resumes the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String name = "name3373707"; Model response = modelServiceClient.resumeModel(name); }- Parameters:
name- Required. The name of the model to resume. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
resumeModel
Resumes the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ResumeModelRequest request = ResumeModelRequest.newBuilder().setName("name3373707").build(); Model response = modelServiceClient.resumeModel(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
resumeModelCallable
Resumes the training of an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ResumeModelRequest request = ResumeModelRequest.newBuilder().setName("name3373707").build(); ApiFuture<Model> future = modelServiceClient.resumeModelCallable().futureCall(request); // Do something. Model response = future.get(); } -
deleteModel
Deletes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]"); modelServiceClient.deleteModel(name); }- Parameters:
name- Required. The resource name of the [Model][google.cloud.retail.v2alpha.Model] to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
deleteModel
Deletes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString(); modelServiceClient.deleteModel(name); }- Parameters:
name- Required. The resource name of the [Model][google.cloud.retail.v2alpha.Model] to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
deleteModel
Deletes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { DeleteModelRequest request = DeleteModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); modelServiceClient.deleteModel(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteModelCallable
Deletes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { DeleteModelRequest request = DeleteModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); ApiFuture<Empty> future = modelServiceClient.deleteModelCallable().futureCall(request); // Do something. future.get(); } -
listModels
Lists all the models linked to this event store.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]"); for (Model element : modelServiceClient.listModels(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent for which to list models. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`- Throws:
ApiException- if the remote call fails
-
listModels
Lists all the models linked to this event store.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString(); for (Model element : modelServiceClient.listModels(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent for which to list models. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`- Throws:
ApiException- if the remote call fails
-
listModels
Lists all the models linked to this event store.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ListModelsRequest request = ListModelsRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Model element : modelServiceClient.listModels(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
-
listModelsPagedCallable
public final UnaryCallable<ListModelsRequest,ModelServiceClient.ListModelsPagedResponse> listModelsPagedCallable()Lists all the models linked to this event store.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ListModelsRequest request = ListModelsRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Model> future = modelServiceClient.listModelsPagedCallable().futureCall(request); // Do something. for (Model element : future.get().iterateAll()) { // doThingsWith(element); } } -
listModelsCallable
Lists all the models linked to this event store.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ListModelsRequest request = ListModelsRequest.newBuilder() .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListModelsResponse response = modelServiceClient.listModelsCallable().call(request); for (Model element : response.getModelsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
updateModel
Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { Model model = Model.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Model response = modelServiceClient.updateModel(model, updateMask); }- Parameters:
model- Required. The body of the updated [Model][google.cloud.retail.v2alpha.Model].updateMask- Optional. Indicates which fields in the provided 'model' to update. If not set, by default updates all fields.- Throws:
ApiException- if the remote call fails
-
updateModel
Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { UpdateModelRequest request = UpdateModelRequest.newBuilder() .setModel(Model.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Model response = modelServiceClient.updateModel(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateModelCallable
Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.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 (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { UpdateModelRequest request = UpdateModelRequest.newBuilder() .setModel(Model.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Model> future = modelServiceClient.updateModelCallable().futureCall(request); // Do something. Model response = future.get(); } -
tuneModelAsync
Tunes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]"); TuneModelResponse response = modelServiceClient.tuneModelAsync(name).get(); }- Parameters:
name- Required. The resource name of the model to tune. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
tuneModelAsync
Tunes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { String name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString(); TuneModelResponse response = modelServiceClient.tuneModelAsync(name).get(); }- Parameters:
name- Required. The resource name of the model to tune. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`- Throws:
ApiException- if the remote call fails
-
tuneModelAsync
public final OperationFuture<TuneModelResponse,TuneModelMetadata> tuneModelAsync(TuneModelRequest request) Tunes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { TuneModelRequest request = TuneModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); TuneModelResponse response = modelServiceClient.tuneModelAsync(request).get(); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
tuneModelOperationCallable
public final OperationCallable<TuneModelRequest,TuneModelResponse, tuneModelOperationCallable()TuneModelMetadata> Tunes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { TuneModelRequest request = TuneModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); OperationFuture<TuneModelResponse, TuneModelMetadata> future = modelServiceClient.tuneModelOperationCallable().futureCall(request); // Do something. TuneModelResponse response = future.get(); } -
tuneModelCallable
Tunes an existing model.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) { TuneModelRequest request = TuneModelRequest.newBuilder() .setName(ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]").toString()) .build(); ApiFuture<Operation> future = modelServiceClient.tuneModelCallable().futureCall(request); // Do something. Operation 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
-