• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.automl.v1.stub;
18 
19 import static com.google.cloud.automl.v1.AutoMlClient.ListDatasetsPagedResponse;
20 import static com.google.cloud.automl.v1.AutoMlClient.ListModelEvaluationsPagedResponse;
21 import static com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse;
22 
23 import com.google.api.gax.core.BackgroundResource;
24 import com.google.api.gax.core.BackgroundResourceAggregation;
25 import com.google.api.gax.grpc.GrpcCallSettings;
26 import com.google.api.gax.grpc.GrpcStubCallableFactory;
27 import com.google.api.gax.rpc.ClientContext;
28 import com.google.api.gax.rpc.OperationCallable;
29 import com.google.api.gax.rpc.UnaryCallable;
30 import com.google.cloud.automl.v1.AnnotationSpec;
31 import com.google.cloud.automl.v1.CreateDatasetRequest;
32 import com.google.cloud.automl.v1.CreateModelRequest;
33 import com.google.cloud.automl.v1.Dataset;
34 import com.google.cloud.automl.v1.DeleteDatasetRequest;
35 import com.google.cloud.automl.v1.DeleteModelRequest;
36 import com.google.cloud.automl.v1.DeployModelRequest;
37 import com.google.cloud.automl.v1.ExportDataRequest;
38 import com.google.cloud.automl.v1.ExportModelRequest;
39 import com.google.cloud.automl.v1.GetAnnotationSpecRequest;
40 import com.google.cloud.automl.v1.GetDatasetRequest;
41 import com.google.cloud.automl.v1.GetModelEvaluationRequest;
42 import com.google.cloud.automl.v1.GetModelRequest;
43 import com.google.cloud.automl.v1.ImportDataRequest;
44 import com.google.cloud.automl.v1.ListDatasetsRequest;
45 import com.google.cloud.automl.v1.ListDatasetsResponse;
46 import com.google.cloud.automl.v1.ListModelEvaluationsRequest;
47 import com.google.cloud.automl.v1.ListModelEvaluationsResponse;
48 import com.google.cloud.automl.v1.ListModelsRequest;
49 import com.google.cloud.automl.v1.ListModelsResponse;
50 import com.google.cloud.automl.v1.Model;
51 import com.google.cloud.automl.v1.ModelEvaluation;
52 import com.google.cloud.automl.v1.OperationMetadata;
53 import com.google.cloud.automl.v1.UndeployModelRequest;
54 import com.google.cloud.automl.v1.UpdateDatasetRequest;
55 import com.google.cloud.automl.v1.UpdateModelRequest;
56 import com.google.common.collect.ImmutableMap;
57 import com.google.longrunning.Operation;
58 import com.google.longrunning.stub.GrpcOperationsStub;
59 import com.google.protobuf.Empty;
60 import io.grpc.MethodDescriptor;
61 import io.grpc.protobuf.ProtoUtils;
62 import java.io.IOException;
63 import java.util.concurrent.TimeUnit;
64 import javax.annotation.Generated;
65 
66 // AUTO-GENERATED DOCUMENTATION AND CLASS.
67 /**
68  * gRPC stub implementation for the AutoMl service API.
69  *
70  * <p>This class is for advanced usage and reflects the underlying API directly.
71  */
72 @Generated("by gapic-generator-java")
73 public class GrpcAutoMlStub extends AutoMlStub {
74   private static final MethodDescriptor<CreateDatasetRequest, Operation>
75       createDatasetMethodDescriptor =
76           MethodDescriptor.<CreateDatasetRequest, Operation>newBuilder()
77               .setType(MethodDescriptor.MethodType.UNARY)
78               .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateDataset")
79               .setRequestMarshaller(
80                   ProtoUtils.marshaller(CreateDatasetRequest.getDefaultInstance()))
81               .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
82               .build();
83 
84   private static final MethodDescriptor<GetDatasetRequest, Dataset> getDatasetMethodDescriptor =
85       MethodDescriptor.<GetDatasetRequest, Dataset>newBuilder()
86           .setType(MethodDescriptor.MethodType.UNARY)
87           .setFullMethodName("google.cloud.automl.v1.AutoMl/GetDataset")
88           .setRequestMarshaller(ProtoUtils.marshaller(GetDatasetRequest.getDefaultInstance()))
89           .setResponseMarshaller(ProtoUtils.marshaller(Dataset.getDefaultInstance()))
90           .build();
91 
92   private static final MethodDescriptor<ListDatasetsRequest, ListDatasetsResponse>
93       listDatasetsMethodDescriptor =
94           MethodDescriptor.<ListDatasetsRequest, ListDatasetsResponse>newBuilder()
95               .setType(MethodDescriptor.MethodType.UNARY)
96               .setFullMethodName("google.cloud.automl.v1.AutoMl/ListDatasets")
97               .setRequestMarshaller(ProtoUtils.marshaller(ListDatasetsRequest.getDefaultInstance()))
98               .setResponseMarshaller(
99                   ProtoUtils.marshaller(ListDatasetsResponse.getDefaultInstance()))
100               .build();
101 
102   private static final MethodDescriptor<UpdateDatasetRequest, Dataset>
103       updateDatasetMethodDescriptor =
104           MethodDescriptor.<UpdateDatasetRequest, Dataset>newBuilder()
105               .setType(MethodDescriptor.MethodType.UNARY)
106               .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateDataset")
107               .setRequestMarshaller(
108                   ProtoUtils.marshaller(UpdateDatasetRequest.getDefaultInstance()))
109               .setResponseMarshaller(ProtoUtils.marshaller(Dataset.getDefaultInstance()))
110               .build();
111 
112   private static final MethodDescriptor<DeleteDatasetRequest, Operation>
113       deleteDatasetMethodDescriptor =
114           MethodDescriptor.<DeleteDatasetRequest, Operation>newBuilder()
115               .setType(MethodDescriptor.MethodType.UNARY)
116               .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteDataset")
117               .setRequestMarshaller(
118                   ProtoUtils.marshaller(DeleteDatasetRequest.getDefaultInstance()))
119               .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
120               .build();
121 
122   private static final MethodDescriptor<ImportDataRequest, Operation> importDataMethodDescriptor =
123       MethodDescriptor.<ImportDataRequest, Operation>newBuilder()
124           .setType(MethodDescriptor.MethodType.UNARY)
125           .setFullMethodName("google.cloud.automl.v1.AutoMl/ImportData")
126           .setRequestMarshaller(ProtoUtils.marshaller(ImportDataRequest.getDefaultInstance()))
127           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
128           .build();
129 
130   private static final MethodDescriptor<ExportDataRequest, Operation> exportDataMethodDescriptor =
131       MethodDescriptor.<ExportDataRequest, Operation>newBuilder()
132           .setType(MethodDescriptor.MethodType.UNARY)
133           .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportData")
134           .setRequestMarshaller(ProtoUtils.marshaller(ExportDataRequest.getDefaultInstance()))
135           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
136           .build();
137 
138   private static final MethodDescriptor<GetAnnotationSpecRequest, AnnotationSpec>
139       getAnnotationSpecMethodDescriptor =
140           MethodDescriptor.<GetAnnotationSpecRequest, AnnotationSpec>newBuilder()
141               .setType(MethodDescriptor.MethodType.UNARY)
142               .setFullMethodName("google.cloud.automl.v1.AutoMl/GetAnnotationSpec")
143               .setRequestMarshaller(
144                   ProtoUtils.marshaller(GetAnnotationSpecRequest.getDefaultInstance()))
145               .setResponseMarshaller(ProtoUtils.marshaller(AnnotationSpec.getDefaultInstance()))
146               .build();
147 
148   private static final MethodDescriptor<CreateModelRequest, Operation> createModelMethodDescriptor =
149       MethodDescriptor.<CreateModelRequest, Operation>newBuilder()
150           .setType(MethodDescriptor.MethodType.UNARY)
151           .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateModel")
152           .setRequestMarshaller(ProtoUtils.marshaller(CreateModelRequest.getDefaultInstance()))
153           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
154           .build();
155 
156   private static final MethodDescriptor<GetModelRequest, Model> getModelMethodDescriptor =
157       MethodDescriptor.<GetModelRequest, Model>newBuilder()
158           .setType(MethodDescriptor.MethodType.UNARY)
159           .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModel")
160           .setRequestMarshaller(ProtoUtils.marshaller(GetModelRequest.getDefaultInstance()))
161           .setResponseMarshaller(ProtoUtils.marshaller(Model.getDefaultInstance()))
162           .build();
163 
164   private static final MethodDescriptor<ListModelsRequest, ListModelsResponse>
165       listModelsMethodDescriptor =
166           MethodDescriptor.<ListModelsRequest, ListModelsResponse>newBuilder()
167               .setType(MethodDescriptor.MethodType.UNARY)
168               .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModels")
169               .setRequestMarshaller(ProtoUtils.marshaller(ListModelsRequest.getDefaultInstance()))
170               .setResponseMarshaller(ProtoUtils.marshaller(ListModelsResponse.getDefaultInstance()))
171               .build();
172 
173   private static final MethodDescriptor<DeleteModelRequest, Operation> deleteModelMethodDescriptor =
174       MethodDescriptor.<DeleteModelRequest, Operation>newBuilder()
175           .setType(MethodDescriptor.MethodType.UNARY)
176           .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteModel")
177           .setRequestMarshaller(ProtoUtils.marshaller(DeleteModelRequest.getDefaultInstance()))
178           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
179           .build();
180 
181   private static final MethodDescriptor<UpdateModelRequest, Model> updateModelMethodDescriptor =
182       MethodDescriptor.<UpdateModelRequest, Model>newBuilder()
183           .setType(MethodDescriptor.MethodType.UNARY)
184           .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateModel")
185           .setRequestMarshaller(ProtoUtils.marshaller(UpdateModelRequest.getDefaultInstance()))
186           .setResponseMarshaller(ProtoUtils.marshaller(Model.getDefaultInstance()))
187           .build();
188 
189   private static final MethodDescriptor<DeployModelRequest, Operation> deployModelMethodDescriptor =
190       MethodDescriptor.<DeployModelRequest, Operation>newBuilder()
191           .setType(MethodDescriptor.MethodType.UNARY)
192           .setFullMethodName("google.cloud.automl.v1.AutoMl/DeployModel")
193           .setRequestMarshaller(ProtoUtils.marshaller(DeployModelRequest.getDefaultInstance()))
194           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
195           .build();
196 
197   private static final MethodDescriptor<UndeployModelRequest, Operation>
198       undeployModelMethodDescriptor =
199           MethodDescriptor.<UndeployModelRequest, Operation>newBuilder()
200               .setType(MethodDescriptor.MethodType.UNARY)
201               .setFullMethodName("google.cloud.automl.v1.AutoMl/UndeployModel")
202               .setRequestMarshaller(
203                   ProtoUtils.marshaller(UndeployModelRequest.getDefaultInstance()))
204               .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
205               .build();
206 
207   private static final MethodDescriptor<ExportModelRequest, Operation> exportModelMethodDescriptor =
208       MethodDescriptor.<ExportModelRequest, Operation>newBuilder()
209           .setType(MethodDescriptor.MethodType.UNARY)
210           .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportModel")
211           .setRequestMarshaller(ProtoUtils.marshaller(ExportModelRequest.getDefaultInstance()))
212           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
213           .build();
214 
215   private static final MethodDescriptor<GetModelEvaluationRequest, ModelEvaluation>
216       getModelEvaluationMethodDescriptor =
217           MethodDescriptor.<GetModelEvaluationRequest, ModelEvaluation>newBuilder()
218               .setType(MethodDescriptor.MethodType.UNARY)
219               .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModelEvaluation")
220               .setRequestMarshaller(
221                   ProtoUtils.marshaller(GetModelEvaluationRequest.getDefaultInstance()))
222               .setResponseMarshaller(ProtoUtils.marshaller(ModelEvaluation.getDefaultInstance()))
223               .build();
224 
225   private static final MethodDescriptor<ListModelEvaluationsRequest, ListModelEvaluationsResponse>
226       listModelEvaluationsMethodDescriptor =
227           MethodDescriptor.<ListModelEvaluationsRequest, ListModelEvaluationsResponse>newBuilder()
228               .setType(MethodDescriptor.MethodType.UNARY)
229               .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModelEvaluations")
230               .setRequestMarshaller(
231                   ProtoUtils.marshaller(ListModelEvaluationsRequest.getDefaultInstance()))
232               .setResponseMarshaller(
233                   ProtoUtils.marshaller(ListModelEvaluationsResponse.getDefaultInstance()))
234               .build();
235 
236   private final UnaryCallable<CreateDatasetRequest, Operation> createDatasetCallable;
237   private final OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
238       createDatasetOperationCallable;
239   private final UnaryCallable<GetDatasetRequest, Dataset> getDatasetCallable;
240   private final UnaryCallable<ListDatasetsRequest, ListDatasetsResponse> listDatasetsCallable;
241   private final UnaryCallable<ListDatasetsRequest, ListDatasetsPagedResponse>
242       listDatasetsPagedCallable;
243   private final UnaryCallable<UpdateDatasetRequest, Dataset> updateDatasetCallable;
244   private final UnaryCallable<DeleteDatasetRequest, Operation> deleteDatasetCallable;
245   private final OperationCallable<DeleteDatasetRequest, Empty, OperationMetadata>
246       deleteDatasetOperationCallable;
247   private final UnaryCallable<ImportDataRequest, Operation> importDataCallable;
248   private final OperationCallable<ImportDataRequest, Empty, OperationMetadata>
249       importDataOperationCallable;
250   private final UnaryCallable<ExportDataRequest, Operation> exportDataCallable;
251   private final OperationCallable<ExportDataRequest, Empty, OperationMetadata>
252       exportDataOperationCallable;
253   private final UnaryCallable<GetAnnotationSpecRequest, AnnotationSpec> getAnnotationSpecCallable;
254   private final UnaryCallable<CreateModelRequest, Operation> createModelCallable;
255   private final OperationCallable<CreateModelRequest, Model, OperationMetadata>
256       createModelOperationCallable;
257   private final UnaryCallable<GetModelRequest, Model> getModelCallable;
258   private final UnaryCallable<ListModelsRequest, ListModelsResponse> listModelsCallable;
259   private final UnaryCallable<ListModelsRequest, ListModelsPagedResponse> listModelsPagedCallable;
260   private final UnaryCallable<DeleteModelRequest, Operation> deleteModelCallable;
261   private final OperationCallable<DeleteModelRequest, Empty, OperationMetadata>
262       deleteModelOperationCallable;
263   private final UnaryCallable<UpdateModelRequest, Model> updateModelCallable;
264   private final UnaryCallable<DeployModelRequest, Operation> deployModelCallable;
265   private final OperationCallable<DeployModelRequest, Empty, OperationMetadata>
266       deployModelOperationCallable;
267   private final UnaryCallable<UndeployModelRequest, Operation> undeployModelCallable;
268   private final OperationCallable<UndeployModelRequest, Empty, OperationMetadata>
269       undeployModelOperationCallable;
270   private final UnaryCallable<ExportModelRequest, Operation> exportModelCallable;
271   private final OperationCallable<ExportModelRequest, Empty, OperationMetadata>
272       exportModelOperationCallable;
273   private final UnaryCallable<GetModelEvaluationRequest, ModelEvaluation>
274       getModelEvaluationCallable;
275   private final UnaryCallable<ListModelEvaluationsRequest, ListModelEvaluationsResponse>
276       listModelEvaluationsCallable;
277   private final UnaryCallable<ListModelEvaluationsRequest, ListModelEvaluationsPagedResponse>
278       listModelEvaluationsPagedCallable;
279 
280   private final BackgroundResource backgroundResources;
281   private final GrpcOperationsStub operationsStub;
282   private final GrpcStubCallableFactory callableFactory;
283 
create(AutoMlStubSettings settings)284   public static final GrpcAutoMlStub create(AutoMlStubSettings settings) throws IOException {
285     return new GrpcAutoMlStub(settings, ClientContext.create(settings));
286   }
287 
create(ClientContext clientContext)288   public static final GrpcAutoMlStub create(ClientContext clientContext) throws IOException {
289     return new GrpcAutoMlStub(AutoMlStubSettings.newBuilder().build(), clientContext);
290   }
291 
create( ClientContext clientContext, GrpcStubCallableFactory callableFactory)292   public static final GrpcAutoMlStub create(
293       ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
294     return new GrpcAutoMlStub(
295         AutoMlStubSettings.newBuilder().build(), clientContext, callableFactory);
296   }
297 
298   /**
299    * Constructs an instance of GrpcAutoMlStub, using the given settings. This is protected so that
300    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
301    */
GrpcAutoMlStub(AutoMlStubSettings settings, ClientContext clientContext)302   protected GrpcAutoMlStub(AutoMlStubSettings settings, ClientContext clientContext)
303       throws IOException {
304     this(settings, clientContext, new GrpcAutoMlCallableFactory());
305   }
306 
307   /**
308    * Constructs an instance of GrpcAutoMlStub, using the given settings. This is protected so that
309    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
310    */
GrpcAutoMlStub( AutoMlStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory)311   protected GrpcAutoMlStub(
312       AutoMlStubSettings settings,
313       ClientContext clientContext,
314       GrpcStubCallableFactory callableFactory)
315       throws IOException {
316     this.callableFactory = callableFactory;
317     this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
318 
319     GrpcCallSettings<CreateDatasetRequest, Operation> createDatasetTransportSettings =
320         GrpcCallSettings.<CreateDatasetRequest, Operation>newBuilder()
321             .setMethodDescriptor(createDatasetMethodDescriptor)
322             .setParamsExtractor(
323                 request -> {
324                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
325                   params.put("parent", String.valueOf(request.getParent()));
326                   return params.build();
327                 })
328             .build();
329     GrpcCallSettings<GetDatasetRequest, Dataset> getDatasetTransportSettings =
330         GrpcCallSettings.<GetDatasetRequest, Dataset>newBuilder()
331             .setMethodDescriptor(getDatasetMethodDescriptor)
332             .setParamsExtractor(
333                 request -> {
334                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
335                   params.put("name", String.valueOf(request.getName()));
336                   return params.build();
337                 })
338             .build();
339     GrpcCallSettings<ListDatasetsRequest, ListDatasetsResponse> listDatasetsTransportSettings =
340         GrpcCallSettings.<ListDatasetsRequest, ListDatasetsResponse>newBuilder()
341             .setMethodDescriptor(listDatasetsMethodDescriptor)
342             .setParamsExtractor(
343                 request -> {
344                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
345                   params.put("parent", String.valueOf(request.getParent()));
346                   return params.build();
347                 })
348             .build();
349     GrpcCallSettings<UpdateDatasetRequest, Dataset> updateDatasetTransportSettings =
350         GrpcCallSettings.<UpdateDatasetRequest, Dataset>newBuilder()
351             .setMethodDescriptor(updateDatasetMethodDescriptor)
352             .setParamsExtractor(
353                 request -> {
354                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
355                   params.put("dataset.name", String.valueOf(request.getDataset().getName()));
356                   return params.build();
357                 })
358             .build();
359     GrpcCallSettings<DeleteDatasetRequest, Operation> deleteDatasetTransportSettings =
360         GrpcCallSettings.<DeleteDatasetRequest, Operation>newBuilder()
361             .setMethodDescriptor(deleteDatasetMethodDescriptor)
362             .setParamsExtractor(
363                 request -> {
364                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
365                   params.put("name", String.valueOf(request.getName()));
366                   return params.build();
367                 })
368             .build();
369     GrpcCallSettings<ImportDataRequest, Operation> importDataTransportSettings =
370         GrpcCallSettings.<ImportDataRequest, Operation>newBuilder()
371             .setMethodDescriptor(importDataMethodDescriptor)
372             .setParamsExtractor(
373                 request -> {
374                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
375                   params.put("name", String.valueOf(request.getName()));
376                   return params.build();
377                 })
378             .build();
379     GrpcCallSettings<ExportDataRequest, Operation> exportDataTransportSettings =
380         GrpcCallSettings.<ExportDataRequest, Operation>newBuilder()
381             .setMethodDescriptor(exportDataMethodDescriptor)
382             .setParamsExtractor(
383                 request -> {
384                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
385                   params.put("name", String.valueOf(request.getName()));
386                   return params.build();
387                 })
388             .build();
389     GrpcCallSettings<GetAnnotationSpecRequest, AnnotationSpec> getAnnotationSpecTransportSettings =
390         GrpcCallSettings.<GetAnnotationSpecRequest, AnnotationSpec>newBuilder()
391             .setMethodDescriptor(getAnnotationSpecMethodDescriptor)
392             .setParamsExtractor(
393                 request -> {
394                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
395                   params.put("name", String.valueOf(request.getName()));
396                   return params.build();
397                 })
398             .build();
399     GrpcCallSettings<CreateModelRequest, Operation> createModelTransportSettings =
400         GrpcCallSettings.<CreateModelRequest, Operation>newBuilder()
401             .setMethodDescriptor(createModelMethodDescriptor)
402             .setParamsExtractor(
403                 request -> {
404                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
405                   params.put("parent", String.valueOf(request.getParent()));
406                   return params.build();
407                 })
408             .build();
409     GrpcCallSettings<GetModelRequest, Model> getModelTransportSettings =
410         GrpcCallSettings.<GetModelRequest, Model>newBuilder()
411             .setMethodDescriptor(getModelMethodDescriptor)
412             .setParamsExtractor(
413                 request -> {
414                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
415                   params.put("name", String.valueOf(request.getName()));
416                   return params.build();
417                 })
418             .build();
419     GrpcCallSettings<ListModelsRequest, ListModelsResponse> listModelsTransportSettings =
420         GrpcCallSettings.<ListModelsRequest, ListModelsResponse>newBuilder()
421             .setMethodDescriptor(listModelsMethodDescriptor)
422             .setParamsExtractor(
423                 request -> {
424                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
425                   params.put("parent", String.valueOf(request.getParent()));
426                   return params.build();
427                 })
428             .build();
429     GrpcCallSettings<DeleteModelRequest, Operation> deleteModelTransportSettings =
430         GrpcCallSettings.<DeleteModelRequest, Operation>newBuilder()
431             .setMethodDescriptor(deleteModelMethodDescriptor)
432             .setParamsExtractor(
433                 request -> {
434                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
435                   params.put("name", String.valueOf(request.getName()));
436                   return params.build();
437                 })
438             .build();
439     GrpcCallSettings<UpdateModelRequest, Model> updateModelTransportSettings =
440         GrpcCallSettings.<UpdateModelRequest, Model>newBuilder()
441             .setMethodDescriptor(updateModelMethodDescriptor)
442             .setParamsExtractor(
443                 request -> {
444                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
445                   params.put("model.name", String.valueOf(request.getModel().getName()));
446                   return params.build();
447                 })
448             .build();
449     GrpcCallSettings<DeployModelRequest, Operation> deployModelTransportSettings =
450         GrpcCallSettings.<DeployModelRequest, Operation>newBuilder()
451             .setMethodDescriptor(deployModelMethodDescriptor)
452             .setParamsExtractor(
453                 request -> {
454                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
455                   params.put("name", String.valueOf(request.getName()));
456                   return params.build();
457                 })
458             .build();
459     GrpcCallSettings<UndeployModelRequest, Operation> undeployModelTransportSettings =
460         GrpcCallSettings.<UndeployModelRequest, Operation>newBuilder()
461             .setMethodDescriptor(undeployModelMethodDescriptor)
462             .setParamsExtractor(
463                 request -> {
464                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
465                   params.put("name", String.valueOf(request.getName()));
466                   return params.build();
467                 })
468             .build();
469     GrpcCallSettings<ExportModelRequest, Operation> exportModelTransportSettings =
470         GrpcCallSettings.<ExportModelRequest, Operation>newBuilder()
471             .setMethodDescriptor(exportModelMethodDescriptor)
472             .setParamsExtractor(
473                 request -> {
474                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
475                   params.put("name", String.valueOf(request.getName()));
476                   return params.build();
477                 })
478             .build();
479     GrpcCallSettings<GetModelEvaluationRequest, ModelEvaluation>
480         getModelEvaluationTransportSettings =
481             GrpcCallSettings.<GetModelEvaluationRequest, ModelEvaluation>newBuilder()
482                 .setMethodDescriptor(getModelEvaluationMethodDescriptor)
483                 .setParamsExtractor(
484                     request -> {
485                       ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
486                       params.put("name", String.valueOf(request.getName()));
487                       return params.build();
488                     })
489                 .build();
490     GrpcCallSettings<ListModelEvaluationsRequest, ListModelEvaluationsResponse>
491         listModelEvaluationsTransportSettings =
492             GrpcCallSettings.<ListModelEvaluationsRequest, ListModelEvaluationsResponse>newBuilder()
493                 .setMethodDescriptor(listModelEvaluationsMethodDescriptor)
494                 .setParamsExtractor(
495                     request -> {
496                       ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
497                       params.put("parent", String.valueOf(request.getParent()));
498                       return params.build();
499                     })
500                 .build();
501 
502     this.createDatasetCallable =
503         callableFactory.createUnaryCallable(
504             createDatasetTransportSettings, settings.createDatasetSettings(), clientContext);
505     this.createDatasetOperationCallable =
506         callableFactory.createOperationCallable(
507             createDatasetTransportSettings,
508             settings.createDatasetOperationSettings(),
509             clientContext,
510             operationsStub);
511     this.getDatasetCallable =
512         callableFactory.createUnaryCallable(
513             getDatasetTransportSettings, settings.getDatasetSettings(), clientContext);
514     this.listDatasetsCallable =
515         callableFactory.createUnaryCallable(
516             listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext);
517     this.listDatasetsPagedCallable =
518         callableFactory.createPagedCallable(
519             listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext);
520     this.updateDatasetCallable =
521         callableFactory.createUnaryCallable(
522             updateDatasetTransportSettings, settings.updateDatasetSettings(), clientContext);
523     this.deleteDatasetCallable =
524         callableFactory.createUnaryCallable(
525             deleteDatasetTransportSettings, settings.deleteDatasetSettings(), clientContext);
526     this.deleteDatasetOperationCallable =
527         callableFactory.createOperationCallable(
528             deleteDatasetTransportSettings,
529             settings.deleteDatasetOperationSettings(),
530             clientContext,
531             operationsStub);
532     this.importDataCallable =
533         callableFactory.createUnaryCallable(
534             importDataTransportSettings, settings.importDataSettings(), clientContext);
535     this.importDataOperationCallable =
536         callableFactory.createOperationCallable(
537             importDataTransportSettings,
538             settings.importDataOperationSettings(),
539             clientContext,
540             operationsStub);
541     this.exportDataCallable =
542         callableFactory.createUnaryCallable(
543             exportDataTransportSettings, settings.exportDataSettings(), clientContext);
544     this.exportDataOperationCallable =
545         callableFactory.createOperationCallable(
546             exportDataTransportSettings,
547             settings.exportDataOperationSettings(),
548             clientContext,
549             operationsStub);
550     this.getAnnotationSpecCallable =
551         callableFactory.createUnaryCallable(
552             getAnnotationSpecTransportSettings,
553             settings.getAnnotationSpecSettings(),
554             clientContext);
555     this.createModelCallable =
556         callableFactory.createUnaryCallable(
557             createModelTransportSettings, settings.createModelSettings(), clientContext);
558     this.createModelOperationCallable =
559         callableFactory.createOperationCallable(
560             createModelTransportSettings,
561             settings.createModelOperationSettings(),
562             clientContext,
563             operationsStub);
564     this.getModelCallable =
565         callableFactory.createUnaryCallable(
566             getModelTransportSettings, settings.getModelSettings(), clientContext);
567     this.listModelsCallable =
568         callableFactory.createUnaryCallable(
569             listModelsTransportSettings, settings.listModelsSettings(), clientContext);
570     this.listModelsPagedCallable =
571         callableFactory.createPagedCallable(
572             listModelsTransportSettings, settings.listModelsSettings(), clientContext);
573     this.deleteModelCallable =
574         callableFactory.createUnaryCallable(
575             deleteModelTransportSettings, settings.deleteModelSettings(), clientContext);
576     this.deleteModelOperationCallable =
577         callableFactory.createOperationCallable(
578             deleteModelTransportSettings,
579             settings.deleteModelOperationSettings(),
580             clientContext,
581             operationsStub);
582     this.updateModelCallable =
583         callableFactory.createUnaryCallable(
584             updateModelTransportSettings, settings.updateModelSettings(), clientContext);
585     this.deployModelCallable =
586         callableFactory.createUnaryCallable(
587             deployModelTransportSettings, settings.deployModelSettings(), clientContext);
588     this.deployModelOperationCallable =
589         callableFactory.createOperationCallable(
590             deployModelTransportSettings,
591             settings.deployModelOperationSettings(),
592             clientContext,
593             operationsStub);
594     this.undeployModelCallable =
595         callableFactory.createUnaryCallable(
596             undeployModelTransportSettings, settings.undeployModelSettings(), clientContext);
597     this.undeployModelOperationCallable =
598         callableFactory.createOperationCallable(
599             undeployModelTransportSettings,
600             settings.undeployModelOperationSettings(),
601             clientContext,
602             operationsStub);
603     this.exportModelCallable =
604         callableFactory.createUnaryCallable(
605             exportModelTransportSettings, settings.exportModelSettings(), clientContext);
606     this.exportModelOperationCallable =
607         callableFactory.createOperationCallable(
608             exportModelTransportSettings,
609             settings.exportModelOperationSettings(),
610             clientContext,
611             operationsStub);
612     this.getModelEvaluationCallable =
613         callableFactory.createUnaryCallable(
614             getModelEvaluationTransportSettings,
615             settings.getModelEvaluationSettings(),
616             clientContext);
617     this.listModelEvaluationsCallable =
618         callableFactory.createUnaryCallable(
619             listModelEvaluationsTransportSettings,
620             settings.listModelEvaluationsSettings(),
621             clientContext);
622     this.listModelEvaluationsPagedCallable =
623         callableFactory.createPagedCallable(
624             listModelEvaluationsTransportSettings,
625             settings.listModelEvaluationsSettings(),
626             clientContext);
627 
628     this.backgroundResources =
629         new BackgroundResourceAggregation(clientContext.getBackgroundResources());
630   }
631 
getOperationsStub()632   public GrpcOperationsStub getOperationsStub() {
633     return operationsStub;
634   }
635 
636   @Override
createDatasetCallable()637   public UnaryCallable<CreateDatasetRequest, Operation> createDatasetCallable() {
638     return createDatasetCallable;
639   }
640 
641   @Override
642   public OperationCallable<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationCallable()643       createDatasetOperationCallable() {
644     return createDatasetOperationCallable;
645   }
646 
647   @Override
getDatasetCallable()648   public UnaryCallable<GetDatasetRequest, Dataset> getDatasetCallable() {
649     return getDatasetCallable;
650   }
651 
652   @Override
listDatasetsCallable()653   public UnaryCallable<ListDatasetsRequest, ListDatasetsResponse> listDatasetsCallable() {
654     return listDatasetsCallable;
655   }
656 
657   @Override
listDatasetsPagedCallable()658   public UnaryCallable<ListDatasetsRequest, ListDatasetsPagedResponse> listDatasetsPagedCallable() {
659     return listDatasetsPagedCallable;
660   }
661 
662   @Override
updateDatasetCallable()663   public UnaryCallable<UpdateDatasetRequest, Dataset> updateDatasetCallable() {
664     return updateDatasetCallable;
665   }
666 
667   @Override
deleteDatasetCallable()668   public UnaryCallable<DeleteDatasetRequest, Operation> deleteDatasetCallable() {
669     return deleteDatasetCallable;
670   }
671 
672   @Override
673   public OperationCallable<DeleteDatasetRequest, Empty, OperationMetadata>
deleteDatasetOperationCallable()674       deleteDatasetOperationCallable() {
675     return deleteDatasetOperationCallable;
676   }
677 
678   @Override
importDataCallable()679   public UnaryCallable<ImportDataRequest, Operation> importDataCallable() {
680     return importDataCallable;
681   }
682 
683   @Override
684   public OperationCallable<ImportDataRequest, Empty, OperationMetadata>
importDataOperationCallable()685       importDataOperationCallable() {
686     return importDataOperationCallable;
687   }
688 
689   @Override
exportDataCallable()690   public UnaryCallable<ExportDataRequest, Operation> exportDataCallable() {
691     return exportDataCallable;
692   }
693 
694   @Override
695   public OperationCallable<ExportDataRequest, Empty, OperationMetadata>
exportDataOperationCallable()696       exportDataOperationCallable() {
697     return exportDataOperationCallable;
698   }
699 
700   @Override
getAnnotationSpecCallable()701   public UnaryCallable<GetAnnotationSpecRequest, AnnotationSpec> getAnnotationSpecCallable() {
702     return getAnnotationSpecCallable;
703   }
704 
705   @Override
createModelCallable()706   public UnaryCallable<CreateModelRequest, Operation> createModelCallable() {
707     return createModelCallable;
708   }
709 
710   @Override
711   public OperationCallable<CreateModelRequest, Model, OperationMetadata>
createModelOperationCallable()712       createModelOperationCallable() {
713     return createModelOperationCallable;
714   }
715 
716   @Override
getModelCallable()717   public UnaryCallable<GetModelRequest, Model> getModelCallable() {
718     return getModelCallable;
719   }
720 
721   @Override
listModelsCallable()722   public UnaryCallable<ListModelsRequest, ListModelsResponse> listModelsCallable() {
723     return listModelsCallable;
724   }
725 
726   @Override
listModelsPagedCallable()727   public UnaryCallable<ListModelsRequest, ListModelsPagedResponse> listModelsPagedCallable() {
728     return listModelsPagedCallable;
729   }
730 
731   @Override
deleteModelCallable()732   public UnaryCallable<DeleteModelRequest, Operation> deleteModelCallable() {
733     return deleteModelCallable;
734   }
735 
736   @Override
737   public OperationCallable<DeleteModelRequest, Empty, OperationMetadata>
deleteModelOperationCallable()738       deleteModelOperationCallable() {
739     return deleteModelOperationCallable;
740   }
741 
742   @Override
updateModelCallable()743   public UnaryCallable<UpdateModelRequest, Model> updateModelCallable() {
744     return updateModelCallable;
745   }
746 
747   @Override
deployModelCallable()748   public UnaryCallable<DeployModelRequest, Operation> deployModelCallable() {
749     return deployModelCallable;
750   }
751 
752   @Override
753   public OperationCallable<DeployModelRequest, Empty, OperationMetadata>
deployModelOperationCallable()754       deployModelOperationCallable() {
755     return deployModelOperationCallable;
756   }
757 
758   @Override
undeployModelCallable()759   public UnaryCallable<UndeployModelRequest, Operation> undeployModelCallable() {
760     return undeployModelCallable;
761   }
762 
763   @Override
764   public OperationCallable<UndeployModelRequest, Empty, OperationMetadata>
undeployModelOperationCallable()765       undeployModelOperationCallable() {
766     return undeployModelOperationCallable;
767   }
768 
769   @Override
exportModelCallable()770   public UnaryCallable<ExportModelRequest, Operation> exportModelCallable() {
771     return exportModelCallable;
772   }
773 
774   @Override
775   public OperationCallable<ExportModelRequest, Empty, OperationMetadata>
exportModelOperationCallable()776       exportModelOperationCallable() {
777     return exportModelOperationCallable;
778   }
779 
780   @Override
getModelEvaluationCallable()781   public UnaryCallable<GetModelEvaluationRequest, ModelEvaluation> getModelEvaluationCallable() {
782     return getModelEvaluationCallable;
783   }
784 
785   @Override
786   public UnaryCallable<ListModelEvaluationsRequest, ListModelEvaluationsResponse>
listModelEvaluationsCallable()787       listModelEvaluationsCallable() {
788     return listModelEvaluationsCallable;
789   }
790 
791   @Override
792   public UnaryCallable<ListModelEvaluationsRequest, ListModelEvaluationsPagedResponse>
listModelEvaluationsPagedCallable()793       listModelEvaluationsPagedCallable() {
794     return listModelEvaluationsPagedCallable;
795   }
796 
797   @Override
close()798   public final void close() {
799     try {
800       backgroundResources.close();
801     } catch (RuntimeException e) {
802       throw e;
803     } catch (Exception e) {
804       throw new IllegalStateException("Failed to close resource", e);
805     }
806   }
807 
808   @Override
shutdown()809   public void shutdown() {
810     backgroundResources.shutdown();
811   }
812 
813   @Override
isShutdown()814   public boolean isShutdown() {
815     return backgroundResources.isShutdown();
816   }
817 
818   @Override
isTerminated()819   public boolean isTerminated() {
820     return backgroundResources.isTerminated();
821   }
822 
823   @Override
shutdownNow()824   public void shutdownNow() {
825     backgroundResources.shutdownNow();
826   }
827 
828   @Override
awaitTermination(long duration, TimeUnit unit)829   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
830     return backgroundResources.awaitTermination(duration, unit);
831   }
832 }
833