@Generated(value="by gapic-generator-java") public class ModelServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[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().
The surface of this class includes several types of Java methods for each of the API's methods:
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:
ModelServiceSettings modelServiceSettings =
ModelServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings);
To customize the endpoint:
ModelServiceSettings modelServiceSettings =
ModelServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
ModelServiceClient.ListModelEvaluationsFixedSizeCollection |
static class |
ModelServiceClient.ListModelEvaluationSlicesFixedSizeCollection |
static class |
ModelServiceClient.ListModelEvaluationSlicesPage |
static class |
ModelServiceClient.ListModelEvaluationSlicesPagedResponse |
static class |
ModelServiceClient.ListModelEvaluationsPage |
static class |
ModelServiceClient.ListModelEvaluationsPagedResponse |
static class |
ModelServiceClient.ListModelsFixedSizeCollection |
static class |
ModelServiceClient.ListModelsPage |
static class |
ModelServiceClient.ListModelsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ModelServiceClient(ModelServiceSettings settings)
Constructs an instance of ModelServiceClient, using the given settings.
|
protected |
ModelServiceClient(ModelServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ModelServiceClient |
create()
Constructs an instance of ModelServiceClient with default settings.
|
static ModelServiceClient |
create(ModelServiceSettings settings)
Constructs an instance of ModelServiceClient, using the given settings.
|
static ModelServiceClient |
create(ModelServiceStub stub)
Constructs an instance of ModelServiceClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> |
deleteModelAsync(DeleteModelRequest request)
Deletes a Model.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> |
deleteModelAsync(ModelName name)
Deletes a Model.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> |
deleteModelAsync(String name)
Deletes a Model.
|
com.google.api.gax.rpc.UnaryCallable<DeleteModelRequest,com.google.longrunning.Operation> |
deleteModelCallable()
Deletes a Model.
|
com.google.api.gax.rpc.OperationCallable<DeleteModelRequest,com.google.protobuf.Empty,DeleteOperationMetadata> |
deleteModelOperationCallable()
Deletes a Model.
|
com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> |
exportModelAsync(ExportModelRequest request)
Exports a trained, exportable, Model to a location specified by the user.
|
com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> |
exportModelAsync(ModelName name,
ExportModelRequest.OutputConfig outputConfig)
Exports a trained, exportable, Model to a location specified by the user.
|
com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> |
exportModelAsync(String name,
ExportModelRequest.OutputConfig outputConfig)
Exports a trained, exportable, Model to a location specified by the user.
|
com.google.api.gax.rpc.UnaryCallable<ExportModelRequest,com.google.longrunning.Operation> |
exportModelCallable()
Exports a trained, exportable, Model to a location specified by the user.
|
com.google.api.gax.rpc.OperationCallable<ExportModelRequest,ExportModelResponse,ExportModelOperationMetadata> |
exportModelOperationCallable()
Exports a trained, exportable, Model to a location specified by the user.
|
Model |
getModel(GetModelRequest request)
Gets a Model.
|
Model |
getModel(ModelName name)
Gets a Model.
|
Model |
getModel(String name)
Gets a Model.
|
com.google.api.gax.rpc.UnaryCallable<GetModelRequest,Model> |
getModelCallable()
Gets a Model.
|
ModelEvaluation |
getModelEvaluation(GetModelEvaluationRequest request)
Gets a ModelEvaluation.
|
ModelEvaluation |
getModelEvaluation(ModelEvaluationName name)
Gets a ModelEvaluation.
|
ModelEvaluation |
getModelEvaluation(String name)
Gets a ModelEvaluation.
|
com.google.api.gax.rpc.UnaryCallable<GetModelEvaluationRequest,ModelEvaluation> |
getModelEvaluationCallable()
Gets a ModelEvaluation.
|
ModelEvaluationSlice |
getModelEvaluationSlice(GetModelEvaluationSliceRequest request)
Gets a ModelEvaluationSlice.
|
ModelEvaluationSlice |
getModelEvaluationSlice(ModelEvaluationSliceName name)
Gets a ModelEvaluationSlice.
|
ModelEvaluationSlice |
getModelEvaluationSlice(String name)
Gets a ModelEvaluationSlice.
|
com.google.api.gax.rpc.UnaryCallable<GetModelEvaluationSliceRequest,ModelEvaluationSlice> |
getModelEvaluationSliceCallable()
Gets a ModelEvaluationSlice.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
ModelServiceSettings |
getSettings() |
ModelServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ModelServiceClient.ListModelEvaluationsPagedResponse |
listModelEvaluations(ListModelEvaluationsRequest request)
Lists ModelEvaluations in a Model.
|
ModelServiceClient.ListModelEvaluationsPagedResponse |
listModelEvaluations(ModelName parent)
Lists ModelEvaluations in a Model.
|
ModelServiceClient.ListModelEvaluationsPagedResponse |
listModelEvaluations(String parent)
Lists ModelEvaluations in a Model.
|
com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationsRequest,ListModelEvaluationsResponse> |
listModelEvaluationsCallable()
Lists ModelEvaluations in a Model.
|
ModelServiceClient.ListModelEvaluationSlicesPagedResponse |
listModelEvaluationSlices(ListModelEvaluationSlicesRequest request)
Lists ModelEvaluationSlices in a ModelEvaluation.
|
ModelServiceClient.ListModelEvaluationSlicesPagedResponse |
listModelEvaluationSlices(ModelEvaluationName parent)
Lists ModelEvaluationSlices in a ModelEvaluation.
|
ModelServiceClient.ListModelEvaluationSlicesPagedResponse |
listModelEvaluationSlices(String parent)
Lists ModelEvaluationSlices in a ModelEvaluation.
|
com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationSlicesRequest,ListModelEvaluationSlicesResponse> |
listModelEvaluationSlicesCallable()
Lists ModelEvaluationSlices in a ModelEvaluation.
|
com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationSlicesRequest,ModelServiceClient.ListModelEvaluationSlicesPagedResponse> |
listModelEvaluationSlicesPagedCallable()
Lists ModelEvaluationSlices in a ModelEvaluation.
|
com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationsRequest,ModelServiceClient.ListModelEvaluationsPagedResponse> |
listModelEvaluationsPagedCallable()
Lists ModelEvaluations in a Model.
|
ModelServiceClient.ListModelsPagedResponse |
listModels(ListModelsRequest request)
Lists Models in a Location.
|
ModelServiceClient.ListModelsPagedResponse |
listModels(LocationName parent)
Lists Models in a Location.
|
ModelServiceClient.ListModelsPagedResponse |
listModels(String parent)
Lists Models in a Location.
|
com.google.api.gax.rpc.UnaryCallable<ListModelsRequest,ListModelsResponse> |
listModelsCallable()
Lists Models in a Location.
|
com.google.api.gax.rpc.UnaryCallable<ListModelsRequest,ModelServiceClient.ListModelsPagedResponse> |
listModelsPagedCallable()
Lists Models in a Location.
|
void |
shutdown() |
void |
shutdownNow() |
Model |
updateModel(Model model,
com.google.protobuf.FieldMask updateMask)
Updates a Model.
|
Model |
updateModel(UpdateModelRequest request)
Updates a Model.
|
com.google.api.gax.rpc.UnaryCallable<UpdateModelRequest,Model> |
updateModelCallable()
Updates a Model.
|
com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> |
uploadModelAsync(LocationName parent,
Model model)
Uploads a Model artifact into Vertex AI.
|
com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> |
uploadModelAsync(String parent,
Model model)
Uploads a Model artifact into Vertex AI.
|
com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> |
uploadModelAsync(UploadModelRequest request)
Uploads a Model artifact into Vertex AI.
|
com.google.api.gax.rpc.UnaryCallable<UploadModelRequest,com.google.longrunning.Operation> |
uploadModelCallable()
Uploads a Model artifact into Vertex AI.
|
com.google.api.gax.rpc.OperationCallable<UploadModelRequest,UploadModelResponse,UploadModelOperationMetadata> |
uploadModelOperationCallable()
Uploads a Model artifact into Vertex AI.
|
protected ModelServiceClient(ModelServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ModelServiceClient(ModelServiceStub stub)
public static final ModelServiceClient create() throws IOException
IOException
public static final ModelServiceClient create(ModelServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ModelServiceClient create(ModelServiceStub stub)
public final ModelServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ModelServiceStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> uploadModelAsync(LocationName parent, Model model)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Model model = Model.newBuilder().build();
UploadModelResponse response = modelServiceClient.uploadModelAsync(parent, model).get();
}
parent
- Required. The resource name of the Location into which to upload the Model.
Format: `projects/{project}/locations/{location}`model
- Required. The Model to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> uploadModelAsync(String parent, Model model)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Model model = Model.newBuilder().build();
UploadModelResponse response = modelServiceClient.uploadModelAsync(parent, model).get();
}
parent
- Required. The resource name of the Location into which to upload the Model.
Format: `projects/{project}/locations/{location}`model
- Required. The Model to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<UploadModelResponse,UploadModelOperationMetadata> uploadModelAsync(UploadModelRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
UploadModelRequest request =
UploadModelRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setModel(Model.newBuilder().build())
.build();
UploadModelResponse response = modelServiceClient.uploadModelAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<UploadModelRequest,UploadModelResponse,UploadModelOperationMetadata> uploadModelOperationCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
UploadModelRequest request =
UploadModelRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setModel(Model.newBuilder().build())
.build();
OperationFuture<UploadModelResponse, UploadModelOperationMetadata> future =
modelServiceClient.uploadModelOperationCallable().futureCall(request);
// Do something.
UploadModelResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UploadModelRequest,com.google.longrunning.Operation> uploadModelCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
UploadModelRequest request =
UploadModelRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setModel(Model.newBuilder().build())
.build();
ApiFuture<Operation> future = modelServiceClient.uploadModelCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final Model getModel(ModelName name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
Model response = modelServiceClient.getModel(name);
}
name
- Required. The name of the Model resource. Format:
`projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Model getModel(String name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString();
Model response = modelServiceClient.getModel(name);
}
name
- Required. The name of the Model resource. Format:
`projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Model getModel(GetModelRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelRequest request =
GetModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.build();
Model response = modelServiceClient.getModel(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetModelRequest,Model> getModelCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelRequest request =
GetModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.build();
ApiFuture<Model> future = modelServiceClient.getModelCallable().futureCall(request);
// Do something.
Model response = future.get();
}
public final ModelServiceClient.ListModelsPagedResponse listModels(LocationName parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Model element : modelServiceClient.listModels(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the Location to list the Models from. Format:
`projects/{project}/locations/{location}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelsPagedResponse listModels(String parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Model element : modelServiceClient.listModels(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the Location to list the Models from. Format:
`projects/{project}/locations/{location}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelsPagedResponse listModels(ListModelsRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelsRequest request =
ListModelsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.setOrderBy("orderBy-1207110587")
.build();
for (Model element : modelServiceClient.listModels(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListModelsRequest,ModelServiceClient.ListModelsPagedResponse> listModelsPagedCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelsRequest request =
ListModelsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.setOrderBy("orderBy-1207110587")
.build();
ApiFuture<Model> future = modelServiceClient.listModelsPagedCallable().futureCall(request);
// Do something.
for (Model element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListModelsRequest,ListModelsResponse> listModelsCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelsRequest request =
ListModelsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.setOrderBy("orderBy-1207110587")
.build();
while (true) {
ListModelsResponse response = modelServiceClient.listModelsCallable().call(request);
for (Model element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Model updateModel(Model model, com.google.protobuf.FieldMask updateMask)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
Model model = Model.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Model response = modelServiceClient.updateModel(model, updateMask);
}
model
- Required. The Model which replaces the resource on the server.updateMask
- Required. The update mask applies to the resource. For the `FieldMask`
definition, see [google.protobuf.FieldMask][google.protobuf.FieldMask].com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Model updateModel(UpdateModelRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
UpdateModelRequest request =
UpdateModelRequest.newBuilder()
.setModel(Model.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Model response = modelServiceClient.updateModel(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateModelRequest,Model> updateModelCallable()
Sample code:
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();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> deleteModelAsync(ModelName name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
modelServiceClient.deleteModelAsync(name).get();
}
name
- Required. The name of the Model resource to be deleted. Format:
`projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> deleteModelAsync(String name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString();
modelServiceClient.deleteModelAsync(name).get();
}
name
- Required. The name of the Model resource to be deleted. Format:
`projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteOperationMetadata> deleteModelAsync(DeleteModelRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
DeleteModelRequest request =
DeleteModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.build();
modelServiceClient.deleteModelAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<DeleteModelRequest,com.google.protobuf.Empty,DeleteOperationMetadata> deleteModelOperationCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
DeleteModelRequest request =
DeleteModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.build();
OperationFuture<Empty, DeleteOperationMetadata> future =
modelServiceClient.deleteModelOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteModelRequest,com.google.longrunning.Operation> deleteModelCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
DeleteModelRequest request =
DeleteModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.build();
ApiFuture<Operation> future = modelServiceClient.deleteModelCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> exportModelAsync(ModelName name, ExportModelRequest.OutputConfig outputConfig)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
ExportModelRequest.OutputConfig outputConfig =
ExportModelRequest.OutputConfig.newBuilder().build();
ExportModelResponse response = modelServiceClient.exportModelAsync(name, outputConfig).get();
}
name
- Required. The resource name of the Model to export. Format:
`projects/{project}/locations/{location}/models/{model}`outputConfig
- Required. The desired output location and configuration.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> exportModelAsync(String name, ExportModelRequest.OutputConfig outputConfig)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String name = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString();
ExportModelRequest.OutputConfig outputConfig =
ExportModelRequest.OutputConfig.newBuilder().build();
ExportModelResponse response = modelServiceClient.exportModelAsync(name, outputConfig).get();
}
name
- Required. The resource name of the Model to export. Format:
`projects/{project}/locations/{location}/models/{model}`outputConfig
- Required. The desired output location and configuration.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<ExportModelResponse,ExportModelOperationMetadata> exportModelAsync(ExportModelRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ExportModelRequest request =
ExportModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setOutputConfig(ExportModelRequest.OutputConfig.newBuilder().build())
.build();
ExportModelResponse response = modelServiceClient.exportModelAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<ExportModelRequest,ExportModelResponse,ExportModelOperationMetadata> exportModelOperationCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ExportModelRequest request =
ExportModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setOutputConfig(ExportModelRequest.OutputConfig.newBuilder().build())
.build();
OperationFuture<ExportModelResponse, ExportModelOperationMetadata> future =
modelServiceClient.exportModelOperationCallable().futureCall(request);
// Do something.
ExportModelResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ExportModelRequest,com.google.longrunning.Operation> exportModelCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ExportModelRequest request =
ExportModelRequest.newBuilder()
.setName(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setOutputConfig(ExportModelRequest.OutputConfig.newBuilder().build())
.build();
ApiFuture<Operation> future = modelServiceClient.exportModelCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final ModelEvaluation getModelEvaluation(ModelEvaluationName name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelEvaluationName name =
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]");
ModelEvaluation response = modelServiceClient.getModelEvaluation(name);
}
name
- Required. The name of the ModelEvaluation resource. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelEvaluation getModelEvaluation(String name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String name =
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]").toString();
ModelEvaluation response = modelServiceClient.getModelEvaluation(name);
}
name
- Required. The name of the ModelEvaluation resource. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelEvaluation getModelEvaluation(GetModelEvaluationRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelEvaluationRequest request =
GetModelEvaluationRequest.newBuilder()
.setName(
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]")
.toString())
.build();
ModelEvaluation response = modelServiceClient.getModelEvaluation(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetModelEvaluationRequest,ModelEvaluation> getModelEvaluationCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelEvaluationRequest request =
GetModelEvaluationRequest.newBuilder()
.setName(
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]")
.toString())
.build();
ApiFuture<ModelEvaluation> future =
modelServiceClient.getModelEvaluationCallable().futureCall(request);
// Do something.
ModelEvaluation response = future.get();
}
public final ModelServiceClient.ListModelEvaluationsPagedResponse listModelEvaluations(ModelName parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]");
for (ModelEvaluation element : modelServiceClient.listModelEvaluations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the Model to list the ModelEvaluations from.
Format: `projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelEvaluationsPagedResponse listModelEvaluations(String parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String parent = ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString();
for (ModelEvaluation element : modelServiceClient.listModelEvaluations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the Model to list the ModelEvaluations from.
Format: `projects/{project}/locations/{location}/models/{model}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelEvaluationsPagedResponse listModelEvaluations(ListModelEvaluationsRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationsRequest request =
ListModelEvaluationsRequest.newBuilder()
.setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
for (ModelEvaluation element :
modelServiceClient.listModelEvaluations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationsRequest,ModelServiceClient.ListModelEvaluationsPagedResponse> listModelEvaluationsPagedCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationsRequest request =
ListModelEvaluationsRequest.newBuilder()
.setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
ApiFuture<ModelEvaluation> future =
modelServiceClient.listModelEvaluationsPagedCallable().futureCall(request);
// Do something.
for (ModelEvaluation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationsRequest,ListModelEvaluationsResponse> listModelEvaluationsCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationsRequest request =
ListModelEvaluationsRequest.newBuilder()
.setParent(ModelName.of("[PROJECT]", "[LOCATION]", "[MODEL]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
while (true) {
ListModelEvaluationsResponse response =
modelServiceClient.listModelEvaluationsCallable().call(request);
for (ModelEvaluation element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final ModelEvaluationSlice getModelEvaluationSlice(ModelEvaluationSliceName name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelEvaluationSliceName name =
ModelEvaluationSliceName.of(
"[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]", "[SLICE]");
ModelEvaluationSlice response = modelServiceClient.getModelEvaluationSlice(name);
}
name
- Required. The name of the ModelEvaluationSlice resource. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelEvaluationSlice getModelEvaluationSlice(String name)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String name =
ModelEvaluationSliceName.of(
"[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]", "[SLICE]")
.toString();
ModelEvaluationSlice response = modelServiceClient.getModelEvaluationSlice(name);
}
name
- Required. The name of the ModelEvaluationSlice resource. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelEvaluationSlice getModelEvaluationSlice(GetModelEvaluationSliceRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelEvaluationSliceRequest request =
GetModelEvaluationSliceRequest.newBuilder()
.setName(
ModelEvaluationSliceName.of(
"[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]", "[SLICE]")
.toString())
.build();
ModelEvaluationSlice response = modelServiceClient.getModelEvaluationSlice(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetModelEvaluationSliceRequest,ModelEvaluationSlice> getModelEvaluationSliceCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
GetModelEvaluationSliceRequest request =
GetModelEvaluationSliceRequest.newBuilder()
.setName(
ModelEvaluationSliceName.of(
"[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]", "[SLICE]")
.toString())
.build();
ApiFuture<ModelEvaluationSlice> future =
modelServiceClient.getModelEvaluationSliceCallable().futureCall(request);
// Do something.
ModelEvaluationSlice response = future.get();
}
public final ModelServiceClient.ListModelEvaluationSlicesPagedResponse listModelEvaluationSlices(ModelEvaluationName parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelEvaluationName parent =
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]");
for (ModelEvaluationSlice element :
modelServiceClient.listModelEvaluationSlices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the ModelEvaluation to list the
ModelEvaluationSlices from. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelEvaluationSlicesPagedResponse listModelEvaluationSlices(String parent)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
String parent =
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]").toString();
for (ModelEvaluationSlice element :
modelServiceClient.listModelEvaluationSlices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the ModelEvaluation to list the
ModelEvaluationSlices from. Format:
`projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final ModelServiceClient.ListModelEvaluationSlicesPagedResponse listModelEvaluationSlices(ListModelEvaluationSlicesRequest request)
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationSlicesRequest request =
ListModelEvaluationSlicesRequest.newBuilder()
.setParent(
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
for (ModelEvaluationSlice element :
modelServiceClient.listModelEvaluationSlices(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationSlicesRequest,ModelServiceClient.ListModelEvaluationSlicesPagedResponse> listModelEvaluationSlicesPagedCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationSlicesRequest request =
ListModelEvaluationSlicesRequest.newBuilder()
.setParent(
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
ApiFuture<ModelEvaluationSlice> future =
modelServiceClient.listModelEvaluationSlicesPagedCallable().futureCall(request);
// Do something.
for (ModelEvaluationSlice element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListModelEvaluationSlicesRequest,ListModelEvaluationSlicesResponse> listModelEvaluationSlicesCallable()
Sample code:
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ListModelEvaluationSlicesRequest request =
ListModelEvaluationSlicesRequest.newBuilder()
.setParent(
ModelEvaluationName.of("[PROJECT]", "[LOCATION]", "[MODEL]", "[EVALUATION]")
.toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setReadMask(FieldMask.newBuilder().build())
.build();
while (true) {
ListModelEvaluationSlicesResponse response =
modelServiceClient.listModelEvaluationSlicesCallable().call(request);
for (ModelEvaluationSlice element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2021 Google LLC. All rights reserved.