• 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.core.ApiFunction;
24 import com.google.api.core.ApiFuture;
25 import com.google.api.core.BetaApi;
26 import com.google.api.gax.core.GaxProperties;
27 import com.google.api.gax.core.GoogleCredentialsProvider;
28 import com.google.api.gax.core.InstantiatingExecutorProvider;
29 import com.google.api.gax.grpc.GaxGrpcProperties;
30 import com.google.api.gax.grpc.GrpcTransportChannel;
31 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
32 import com.google.api.gax.grpc.ProtoOperationTransformers;
33 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
34 import com.google.api.gax.httpjson.HttpJsonTransportChannel;
35 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
36 import com.google.api.gax.longrunning.OperationSnapshot;
37 import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
38 import com.google.api.gax.retrying.RetrySettings;
39 import com.google.api.gax.rpc.ApiCallContext;
40 import com.google.api.gax.rpc.ApiClientHeaderProvider;
41 import com.google.api.gax.rpc.ClientContext;
42 import com.google.api.gax.rpc.OperationCallSettings;
43 import com.google.api.gax.rpc.PageContext;
44 import com.google.api.gax.rpc.PagedCallSettings;
45 import com.google.api.gax.rpc.PagedListDescriptor;
46 import com.google.api.gax.rpc.PagedListResponseFactory;
47 import com.google.api.gax.rpc.StatusCode;
48 import com.google.api.gax.rpc.StubSettings;
49 import com.google.api.gax.rpc.TransportChannelProvider;
50 import com.google.api.gax.rpc.UnaryCallSettings;
51 import com.google.api.gax.rpc.UnaryCallable;
52 import com.google.cloud.automl.v1.AnnotationSpec;
53 import com.google.cloud.automl.v1.CreateDatasetRequest;
54 import com.google.cloud.automl.v1.CreateModelRequest;
55 import com.google.cloud.automl.v1.Dataset;
56 import com.google.cloud.automl.v1.DeleteDatasetRequest;
57 import com.google.cloud.automl.v1.DeleteModelRequest;
58 import com.google.cloud.automl.v1.DeployModelRequest;
59 import com.google.cloud.automl.v1.ExportDataRequest;
60 import com.google.cloud.automl.v1.ExportModelRequest;
61 import com.google.cloud.automl.v1.GetAnnotationSpecRequest;
62 import com.google.cloud.automl.v1.GetDatasetRequest;
63 import com.google.cloud.automl.v1.GetModelEvaluationRequest;
64 import com.google.cloud.automl.v1.GetModelRequest;
65 import com.google.cloud.automl.v1.ImportDataRequest;
66 import com.google.cloud.automl.v1.ListDatasetsRequest;
67 import com.google.cloud.automl.v1.ListDatasetsResponse;
68 import com.google.cloud.automl.v1.ListModelEvaluationsRequest;
69 import com.google.cloud.automl.v1.ListModelEvaluationsResponse;
70 import com.google.cloud.automl.v1.ListModelsRequest;
71 import com.google.cloud.automl.v1.ListModelsResponse;
72 import com.google.cloud.automl.v1.Model;
73 import com.google.cloud.automl.v1.ModelEvaluation;
74 import com.google.cloud.automl.v1.OperationMetadata;
75 import com.google.cloud.automl.v1.UndeployModelRequest;
76 import com.google.cloud.automl.v1.UpdateDatasetRequest;
77 import com.google.cloud.automl.v1.UpdateModelRequest;
78 import com.google.common.collect.ImmutableList;
79 import com.google.common.collect.ImmutableMap;
80 import com.google.common.collect.ImmutableSet;
81 import com.google.common.collect.Lists;
82 import com.google.longrunning.Operation;
83 import com.google.protobuf.Empty;
84 import java.io.IOException;
85 import java.util.List;
86 import javax.annotation.Generated;
87 import org.threeten.bp.Duration;
88 
89 // AUTO-GENERATED DOCUMENTATION AND CLASS.
90 /**
91  * Settings class to configure an instance of {@link AutoMlStub}.
92  *
93  * <p>The default instance has everything set to sensible defaults:
94  *
95  * <ul>
96  *   <li>The default service address (automl.googleapis.com) and default port (443) are used.
97  *   <li>Credentials are acquired automatically through Application Default Credentials.
98  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
99  * </ul>
100  *
101  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
102  * build() is called, the tree of builders is called to create the complete settings object.
103  *
104  * <p>For example, to set the total timeout of getDataset to 30 seconds:
105  *
106  * <pre>{@code
107  * // This snippet has been automatically generated and should be regarded as a code template only.
108  * // It will require modifications to work:
109  * // - It may require correct/in-range values for request initialization.
110  * // - It may require specifying regional endpoints when creating the service client as shown in
111  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
112  * AutoMlStubSettings.Builder autoMlSettingsBuilder = AutoMlStubSettings.newBuilder();
113  * autoMlSettingsBuilder
114  *     .getDatasetSettings()
115  *     .setRetrySettings(
116  *         autoMlSettingsBuilder
117  *             .getDatasetSettings()
118  *             .getRetrySettings()
119  *             .toBuilder()
120  *             .setTotalTimeout(Duration.ofSeconds(30))
121  *             .build());
122  * AutoMlStubSettings autoMlSettings = autoMlSettingsBuilder.build();
123  * }</pre>
124  */
125 @Generated("by gapic-generator-java")
126 public class AutoMlStubSettings extends StubSettings<AutoMlStubSettings> {
127   /** The default scopes of the service. */
128   private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
129       ImmutableList.<String>builder().add("https://www.googleapis.com/auth/cloud-platform").build();
130 
131   private final UnaryCallSettings<CreateDatasetRequest, Operation> createDatasetSettings;
132   private final OperationCallSettings<CreateDatasetRequest, Dataset, OperationMetadata>
133       createDatasetOperationSettings;
134   private final UnaryCallSettings<GetDatasetRequest, Dataset> getDatasetSettings;
135   private final PagedCallSettings<
136           ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>
137       listDatasetsSettings;
138   private final UnaryCallSettings<UpdateDatasetRequest, Dataset> updateDatasetSettings;
139   private final UnaryCallSettings<DeleteDatasetRequest, Operation> deleteDatasetSettings;
140   private final OperationCallSettings<DeleteDatasetRequest, Empty, OperationMetadata>
141       deleteDatasetOperationSettings;
142   private final UnaryCallSettings<ImportDataRequest, Operation> importDataSettings;
143   private final OperationCallSettings<ImportDataRequest, Empty, OperationMetadata>
144       importDataOperationSettings;
145   private final UnaryCallSettings<ExportDataRequest, Operation> exportDataSettings;
146   private final OperationCallSettings<ExportDataRequest, Empty, OperationMetadata>
147       exportDataOperationSettings;
148   private final UnaryCallSettings<GetAnnotationSpecRequest, AnnotationSpec>
149       getAnnotationSpecSettings;
150   private final UnaryCallSettings<CreateModelRequest, Operation> createModelSettings;
151   private final OperationCallSettings<CreateModelRequest, Model, OperationMetadata>
152       createModelOperationSettings;
153   private final UnaryCallSettings<GetModelRequest, Model> getModelSettings;
154   private final PagedCallSettings<ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>
155       listModelsSettings;
156   private final UnaryCallSettings<DeleteModelRequest, Operation> deleteModelSettings;
157   private final OperationCallSettings<DeleteModelRequest, Empty, OperationMetadata>
158       deleteModelOperationSettings;
159   private final UnaryCallSettings<UpdateModelRequest, Model> updateModelSettings;
160   private final UnaryCallSettings<DeployModelRequest, Operation> deployModelSettings;
161   private final OperationCallSettings<DeployModelRequest, Empty, OperationMetadata>
162       deployModelOperationSettings;
163   private final UnaryCallSettings<UndeployModelRequest, Operation> undeployModelSettings;
164   private final OperationCallSettings<UndeployModelRequest, Empty, OperationMetadata>
165       undeployModelOperationSettings;
166   private final UnaryCallSettings<ExportModelRequest, Operation> exportModelSettings;
167   private final OperationCallSettings<ExportModelRequest, Empty, OperationMetadata>
168       exportModelOperationSettings;
169   private final UnaryCallSettings<GetModelEvaluationRequest, ModelEvaluation>
170       getModelEvaluationSettings;
171   private final PagedCallSettings<
172           ListModelEvaluationsRequest,
173           ListModelEvaluationsResponse,
174           ListModelEvaluationsPagedResponse>
175       listModelEvaluationsSettings;
176 
177   private static final PagedListDescriptor<ListDatasetsRequest, ListDatasetsResponse, Dataset>
178       LIST_DATASETS_PAGE_STR_DESC =
179           new PagedListDescriptor<ListDatasetsRequest, ListDatasetsResponse, Dataset>() {
180             @Override
181             public String emptyToken() {
182               return "";
183             }
184 
185             @Override
186             public ListDatasetsRequest injectToken(ListDatasetsRequest payload, String token) {
187               return ListDatasetsRequest.newBuilder(payload).setPageToken(token).build();
188             }
189 
190             @Override
191             public ListDatasetsRequest injectPageSize(ListDatasetsRequest payload, int pageSize) {
192               return ListDatasetsRequest.newBuilder(payload).setPageSize(pageSize).build();
193             }
194 
195             @Override
196             public Integer extractPageSize(ListDatasetsRequest payload) {
197               return payload.getPageSize();
198             }
199 
200             @Override
201             public String extractNextToken(ListDatasetsResponse payload) {
202               return payload.getNextPageToken();
203             }
204 
205             @Override
206             public Iterable<Dataset> extractResources(ListDatasetsResponse payload) {
207               return payload.getDatasetsList() == null
208                   ? ImmutableList.<Dataset>of()
209                   : payload.getDatasetsList();
210             }
211           };
212 
213   private static final PagedListDescriptor<ListModelsRequest, ListModelsResponse, Model>
214       LIST_MODELS_PAGE_STR_DESC =
215           new PagedListDescriptor<ListModelsRequest, ListModelsResponse, Model>() {
216             @Override
217             public String emptyToken() {
218               return "";
219             }
220 
221             @Override
222             public ListModelsRequest injectToken(ListModelsRequest payload, String token) {
223               return ListModelsRequest.newBuilder(payload).setPageToken(token).build();
224             }
225 
226             @Override
227             public ListModelsRequest injectPageSize(ListModelsRequest payload, int pageSize) {
228               return ListModelsRequest.newBuilder(payload).setPageSize(pageSize).build();
229             }
230 
231             @Override
232             public Integer extractPageSize(ListModelsRequest payload) {
233               return payload.getPageSize();
234             }
235 
236             @Override
237             public String extractNextToken(ListModelsResponse payload) {
238               return payload.getNextPageToken();
239             }
240 
241             @Override
242             public Iterable<Model> extractResources(ListModelsResponse payload) {
243               return payload.getModelList() == null
244                   ? ImmutableList.<Model>of()
245                   : payload.getModelList();
246             }
247           };
248 
249   private static final PagedListDescriptor<
250           ListModelEvaluationsRequest, ListModelEvaluationsResponse, ModelEvaluation>
251       LIST_MODEL_EVALUATIONS_PAGE_STR_DESC =
252           new PagedListDescriptor<
253               ListModelEvaluationsRequest, ListModelEvaluationsResponse, ModelEvaluation>() {
254             @Override
255             public String emptyToken() {
256               return "";
257             }
258 
259             @Override
260             public ListModelEvaluationsRequest injectToken(
261                 ListModelEvaluationsRequest payload, String token) {
262               return ListModelEvaluationsRequest.newBuilder(payload).setPageToken(token).build();
263             }
264 
265             @Override
266             public ListModelEvaluationsRequest injectPageSize(
267                 ListModelEvaluationsRequest payload, int pageSize) {
268               return ListModelEvaluationsRequest.newBuilder(payload).setPageSize(pageSize).build();
269             }
270 
271             @Override
272             public Integer extractPageSize(ListModelEvaluationsRequest payload) {
273               return payload.getPageSize();
274             }
275 
276             @Override
277             public String extractNextToken(ListModelEvaluationsResponse payload) {
278               return payload.getNextPageToken();
279             }
280 
281             @Override
282             public Iterable<ModelEvaluation> extractResources(
283                 ListModelEvaluationsResponse payload) {
284               return payload.getModelEvaluationList() == null
285                   ? ImmutableList.<ModelEvaluation>of()
286                   : payload.getModelEvaluationList();
287             }
288           };
289 
290   private static final PagedListResponseFactory<
291           ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>
292       LIST_DATASETS_PAGE_STR_FACT =
293           new PagedListResponseFactory<
294               ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>() {
295             @Override
296             public ApiFuture<ListDatasetsPagedResponse> getFuturePagedResponse(
297                 UnaryCallable<ListDatasetsRequest, ListDatasetsResponse> callable,
298                 ListDatasetsRequest request,
299                 ApiCallContext context,
300                 ApiFuture<ListDatasetsResponse> futureResponse) {
301               PageContext<ListDatasetsRequest, ListDatasetsResponse, Dataset> pageContext =
302                   PageContext.create(callable, LIST_DATASETS_PAGE_STR_DESC, request, context);
303               return ListDatasetsPagedResponse.createAsync(pageContext, futureResponse);
304             }
305           };
306 
307   private static final PagedListResponseFactory<
308           ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>
309       LIST_MODELS_PAGE_STR_FACT =
310           new PagedListResponseFactory<
311               ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>() {
312             @Override
313             public ApiFuture<ListModelsPagedResponse> getFuturePagedResponse(
314                 UnaryCallable<ListModelsRequest, ListModelsResponse> callable,
315                 ListModelsRequest request,
316                 ApiCallContext context,
317                 ApiFuture<ListModelsResponse> futureResponse) {
318               PageContext<ListModelsRequest, ListModelsResponse, Model> pageContext =
319                   PageContext.create(callable, LIST_MODELS_PAGE_STR_DESC, request, context);
320               return ListModelsPagedResponse.createAsync(pageContext, futureResponse);
321             }
322           };
323 
324   private static final PagedListResponseFactory<
325           ListModelEvaluationsRequest,
326           ListModelEvaluationsResponse,
327           ListModelEvaluationsPagedResponse>
328       LIST_MODEL_EVALUATIONS_PAGE_STR_FACT =
329           new PagedListResponseFactory<
330               ListModelEvaluationsRequest,
331               ListModelEvaluationsResponse,
332               ListModelEvaluationsPagedResponse>() {
333             @Override
334             public ApiFuture<ListModelEvaluationsPagedResponse> getFuturePagedResponse(
335                 UnaryCallable<ListModelEvaluationsRequest, ListModelEvaluationsResponse> callable,
336                 ListModelEvaluationsRequest request,
337                 ApiCallContext context,
338                 ApiFuture<ListModelEvaluationsResponse> futureResponse) {
339               PageContext<
340                       ListModelEvaluationsRequest, ListModelEvaluationsResponse, ModelEvaluation>
341                   pageContext =
342                       PageContext.create(
343                           callable, LIST_MODEL_EVALUATIONS_PAGE_STR_DESC, request, context);
344               return ListModelEvaluationsPagedResponse.createAsync(pageContext, futureResponse);
345             }
346           };
347 
348   /** Returns the object with the settings used for calls to createDataset. */
createDatasetSettings()349   public UnaryCallSettings<CreateDatasetRequest, Operation> createDatasetSettings() {
350     return createDatasetSettings;
351   }
352 
353   /** Returns the object with the settings used for calls to createDataset. */
354   public OperationCallSettings<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings()355       createDatasetOperationSettings() {
356     return createDatasetOperationSettings;
357   }
358 
359   /** Returns the object with the settings used for calls to getDataset. */
getDatasetSettings()360   public UnaryCallSettings<GetDatasetRequest, Dataset> getDatasetSettings() {
361     return getDatasetSettings;
362   }
363 
364   /** Returns the object with the settings used for calls to listDatasets. */
365   public PagedCallSettings<ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>
listDatasetsSettings()366       listDatasetsSettings() {
367     return listDatasetsSettings;
368   }
369 
370   /** Returns the object with the settings used for calls to updateDataset. */
updateDatasetSettings()371   public UnaryCallSettings<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
372     return updateDatasetSettings;
373   }
374 
375   /** Returns the object with the settings used for calls to deleteDataset. */
deleteDatasetSettings()376   public UnaryCallSettings<DeleteDatasetRequest, Operation> deleteDatasetSettings() {
377     return deleteDatasetSettings;
378   }
379 
380   /** Returns the object with the settings used for calls to deleteDataset. */
381   public OperationCallSettings<DeleteDatasetRequest, Empty, OperationMetadata>
deleteDatasetOperationSettings()382       deleteDatasetOperationSettings() {
383     return deleteDatasetOperationSettings;
384   }
385 
386   /** Returns the object with the settings used for calls to importData. */
importDataSettings()387   public UnaryCallSettings<ImportDataRequest, Operation> importDataSettings() {
388     return importDataSettings;
389   }
390 
391   /** Returns the object with the settings used for calls to importData. */
392   public OperationCallSettings<ImportDataRequest, Empty, OperationMetadata>
importDataOperationSettings()393       importDataOperationSettings() {
394     return importDataOperationSettings;
395   }
396 
397   /** Returns the object with the settings used for calls to exportData. */
exportDataSettings()398   public UnaryCallSettings<ExportDataRequest, Operation> exportDataSettings() {
399     return exportDataSettings;
400   }
401 
402   /** Returns the object with the settings used for calls to exportData. */
403   public OperationCallSettings<ExportDataRequest, Empty, OperationMetadata>
exportDataOperationSettings()404       exportDataOperationSettings() {
405     return exportDataOperationSettings;
406   }
407 
408   /** Returns the object with the settings used for calls to getAnnotationSpec. */
getAnnotationSpecSettings()409   public UnaryCallSettings<GetAnnotationSpecRequest, AnnotationSpec> getAnnotationSpecSettings() {
410     return getAnnotationSpecSettings;
411   }
412 
413   /** Returns the object with the settings used for calls to createModel. */
createModelSettings()414   public UnaryCallSettings<CreateModelRequest, Operation> createModelSettings() {
415     return createModelSettings;
416   }
417 
418   /** Returns the object with the settings used for calls to createModel. */
419   public OperationCallSettings<CreateModelRequest, Model, OperationMetadata>
createModelOperationSettings()420       createModelOperationSettings() {
421     return createModelOperationSettings;
422   }
423 
424   /** Returns the object with the settings used for calls to getModel. */
getModelSettings()425   public UnaryCallSettings<GetModelRequest, Model> getModelSettings() {
426     return getModelSettings;
427   }
428 
429   /** Returns the object with the settings used for calls to listModels. */
430   public PagedCallSettings<ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>
listModelsSettings()431       listModelsSettings() {
432     return listModelsSettings;
433   }
434 
435   /** Returns the object with the settings used for calls to deleteModel. */
deleteModelSettings()436   public UnaryCallSettings<DeleteModelRequest, Operation> deleteModelSettings() {
437     return deleteModelSettings;
438   }
439 
440   /** Returns the object with the settings used for calls to deleteModel. */
441   public OperationCallSettings<DeleteModelRequest, Empty, OperationMetadata>
deleteModelOperationSettings()442       deleteModelOperationSettings() {
443     return deleteModelOperationSettings;
444   }
445 
446   /** Returns the object with the settings used for calls to updateModel. */
updateModelSettings()447   public UnaryCallSettings<UpdateModelRequest, Model> updateModelSettings() {
448     return updateModelSettings;
449   }
450 
451   /** Returns the object with the settings used for calls to deployModel. */
deployModelSettings()452   public UnaryCallSettings<DeployModelRequest, Operation> deployModelSettings() {
453     return deployModelSettings;
454   }
455 
456   /** Returns the object with the settings used for calls to deployModel. */
457   public OperationCallSettings<DeployModelRequest, Empty, OperationMetadata>
deployModelOperationSettings()458       deployModelOperationSettings() {
459     return deployModelOperationSettings;
460   }
461 
462   /** Returns the object with the settings used for calls to undeployModel. */
undeployModelSettings()463   public UnaryCallSettings<UndeployModelRequest, Operation> undeployModelSettings() {
464     return undeployModelSettings;
465   }
466 
467   /** Returns the object with the settings used for calls to undeployModel. */
468   public OperationCallSettings<UndeployModelRequest, Empty, OperationMetadata>
undeployModelOperationSettings()469       undeployModelOperationSettings() {
470     return undeployModelOperationSettings;
471   }
472 
473   /** Returns the object with the settings used for calls to exportModel. */
exportModelSettings()474   public UnaryCallSettings<ExportModelRequest, Operation> exportModelSettings() {
475     return exportModelSettings;
476   }
477 
478   /** Returns the object with the settings used for calls to exportModel. */
479   public OperationCallSettings<ExportModelRequest, Empty, OperationMetadata>
exportModelOperationSettings()480       exportModelOperationSettings() {
481     return exportModelOperationSettings;
482   }
483 
484   /** Returns the object with the settings used for calls to getModelEvaluation. */
485   public UnaryCallSettings<GetModelEvaluationRequest, ModelEvaluation>
getModelEvaluationSettings()486       getModelEvaluationSettings() {
487     return getModelEvaluationSettings;
488   }
489 
490   /** Returns the object with the settings used for calls to listModelEvaluations. */
491   public PagedCallSettings<
492           ListModelEvaluationsRequest,
493           ListModelEvaluationsResponse,
494           ListModelEvaluationsPagedResponse>
listModelEvaluationsSettings()495       listModelEvaluationsSettings() {
496     return listModelEvaluationsSettings;
497   }
498 
createStub()499   public AutoMlStub createStub() throws IOException {
500     if (getTransportChannelProvider()
501         .getTransportName()
502         .equals(GrpcTransportChannel.getGrpcTransportName())) {
503       return GrpcAutoMlStub.create(this);
504     }
505     if (getTransportChannelProvider()
506         .getTransportName()
507         .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
508       return HttpJsonAutoMlStub.create(this);
509     }
510     throw new UnsupportedOperationException(
511         String.format(
512             "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
513   }
514 
515   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()516   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
517     return InstantiatingExecutorProvider.newBuilder();
518   }
519 
520   /** Returns the default service endpoint. */
getDefaultEndpoint()521   public static String getDefaultEndpoint() {
522     return "automl.googleapis.com:443";
523   }
524 
525   /** Returns the default mTLS service endpoint. */
getDefaultMtlsEndpoint()526   public static String getDefaultMtlsEndpoint() {
527     return "automl.mtls.googleapis.com:443";
528   }
529 
530   /** Returns the default service scopes. */
getDefaultServiceScopes()531   public static List<String> getDefaultServiceScopes() {
532     return DEFAULT_SERVICE_SCOPES;
533   }
534 
535   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()536   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
537     return GoogleCredentialsProvider.newBuilder()
538         .setScopesToApply(DEFAULT_SERVICE_SCOPES)
539         .setUseJwtAccessWithScope(true);
540   }
541 
542   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()543   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
544     return InstantiatingGrpcChannelProvider.newBuilder()
545         .setMaxInboundMessageSize(Integer.MAX_VALUE);
546   }
547 
548   /** Returns a builder for the default REST ChannelProvider for this service. */
549   @BetaApi
550   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()551       defaultHttpJsonTransportProviderBuilder() {
552     return InstantiatingHttpJsonChannelProvider.newBuilder();
553   }
554 
defaultTransportChannelProvider()555   public static TransportChannelProvider defaultTransportChannelProvider() {
556     return defaultGrpcTransportProviderBuilder().build();
557   }
558 
559   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultGrpcApiClientHeaderProviderBuilder()560   public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
561     return ApiClientHeaderProvider.newBuilder()
562         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AutoMlStubSettings.class))
563         .setTransportToken(
564             GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
565   }
566 
567   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultHttpJsonApiClientHeaderProviderBuilder()568   public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
569     return ApiClientHeaderProvider.newBuilder()
570         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AutoMlStubSettings.class))
571         .setTransportToken(
572             GaxHttpJsonProperties.getHttpJsonTokenName(),
573             GaxHttpJsonProperties.getHttpJsonVersion());
574   }
575 
defaultApiClientHeaderProviderBuilder()576   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
577     return AutoMlStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
578   }
579 
580   /** Returns a new gRPC builder for this class. */
newBuilder()581   public static Builder newBuilder() {
582     return Builder.createDefault();
583   }
584 
585   /** Returns a new REST builder for this class. */
newHttpJsonBuilder()586   public static Builder newHttpJsonBuilder() {
587     return Builder.createHttpJsonDefault();
588   }
589 
590   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)591   public static Builder newBuilder(ClientContext clientContext) {
592     return new Builder(clientContext);
593   }
594 
595   /** Returns a builder containing all the values of this settings class. */
toBuilder()596   public Builder toBuilder() {
597     return new Builder(this);
598   }
599 
AutoMlStubSettings(Builder settingsBuilder)600   protected AutoMlStubSettings(Builder settingsBuilder) throws IOException {
601     super(settingsBuilder);
602 
603     createDatasetSettings = settingsBuilder.createDatasetSettings().build();
604     createDatasetOperationSettings = settingsBuilder.createDatasetOperationSettings().build();
605     getDatasetSettings = settingsBuilder.getDatasetSettings().build();
606     listDatasetsSettings = settingsBuilder.listDatasetsSettings().build();
607     updateDatasetSettings = settingsBuilder.updateDatasetSettings().build();
608     deleteDatasetSettings = settingsBuilder.deleteDatasetSettings().build();
609     deleteDatasetOperationSettings = settingsBuilder.deleteDatasetOperationSettings().build();
610     importDataSettings = settingsBuilder.importDataSettings().build();
611     importDataOperationSettings = settingsBuilder.importDataOperationSettings().build();
612     exportDataSettings = settingsBuilder.exportDataSettings().build();
613     exportDataOperationSettings = settingsBuilder.exportDataOperationSettings().build();
614     getAnnotationSpecSettings = settingsBuilder.getAnnotationSpecSettings().build();
615     createModelSettings = settingsBuilder.createModelSettings().build();
616     createModelOperationSettings = settingsBuilder.createModelOperationSettings().build();
617     getModelSettings = settingsBuilder.getModelSettings().build();
618     listModelsSettings = settingsBuilder.listModelsSettings().build();
619     deleteModelSettings = settingsBuilder.deleteModelSettings().build();
620     deleteModelOperationSettings = settingsBuilder.deleteModelOperationSettings().build();
621     updateModelSettings = settingsBuilder.updateModelSettings().build();
622     deployModelSettings = settingsBuilder.deployModelSettings().build();
623     deployModelOperationSettings = settingsBuilder.deployModelOperationSettings().build();
624     undeployModelSettings = settingsBuilder.undeployModelSettings().build();
625     undeployModelOperationSettings = settingsBuilder.undeployModelOperationSettings().build();
626     exportModelSettings = settingsBuilder.exportModelSettings().build();
627     exportModelOperationSettings = settingsBuilder.exportModelOperationSettings().build();
628     getModelEvaluationSettings = settingsBuilder.getModelEvaluationSettings().build();
629     listModelEvaluationsSettings = settingsBuilder.listModelEvaluationsSettings().build();
630   }
631 
632   /** Builder for AutoMlStubSettings. */
633   public static class Builder extends StubSettings.Builder<AutoMlStubSettings, Builder> {
634     private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
635     private final UnaryCallSettings.Builder<CreateDatasetRequest, Operation> createDatasetSettings;
636     private final OperationCallSettings.Builder<CreateDatasetRequest, Dataset, OperationMetadata>
637         createDatasetOperationSettings;
638     private final UnaryCallSettings.Builder<GetDatasetRequest, Dataset> getDatasetSettings;
639     private final PagedCallSettings.Builder<
640             ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>
641         listDatasetsSettings;
642     private final UnaryCallSettings.Builder<UpdateDatasetRequest, Dataset> updateDatasetSettings;
643     private final UnaryCallSettings.Builder<DeleteDatasetRequest, Operation> deleteDatasetSettings;
644     private final OperationCallSettings.Builder<DeleteDatasetRequest, Empty, OperationMetadata>
645         deleteDatasetOperationSettings;
646     private final UnaryCallSettings.Builder<ImportDataRequest, Operation> importDataSettings;
647     private final OperationCallSettings.Builder<ImportDataRequest, Empty, OperationMetadata>
648         importDataOperationSettings;
649     private final UnaryCallSettings.Builder<ExportDataRequest, Operation> exportDataSettings;
650     private final OperationCallSettings.Builder<ExportDataRequest, Empty, OperationMetadata>
651         exportDataOperationSettings;
652     private final UnaryCallSettings.Builder<GetAnnotationSpecRequest, AnnotationSpec>
653         getAnnotationSpecSettings;
654     private final UnaryCallSettings.Builder<CreateModelRequest, Operation> createModelSettings;
655     private final OperationCallSettings.Builder<CreateModelRequest, Model, OperationMetadata>
656         createModelOperationSettings;
657     private final UnaryCallSettings.Builder<GetModelRequest, Model> getModelSettings;
658     private final PagedCallSettings.Builder<
659             ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>
660         listModelsSettings;
661     private final UnaryCallSettings.Builder<DeleteModelRequest, Operation> deleteModelSettings;
662     private final OperationCallSettings.Builder<DeleteModelRequest, Empty, OperationMetadata>
663         deleteModelOperationSettings;
664     private final UnaryCallSettings.Builder<UpdateModelRequest, Model> updateModelSettings;
665     private final UnaryCallSettings.Builder<DeployModelRequest, Operation> deployModelSettings;
666     private final OperationCallSettings.Builder<DeployModelRequest, Empty, OperationMetadata>
667         deployModelOperationSettings;
668     private final UnaryCallSettings.Builder<UndeployModelRequest, Operation> undeployModelSettings;
669     private final OperationCallSettings.Builder<UndeployModelRequest, Empty, OperationMetadata>
670         undeployModelOperationSettings;
671     private final UnaryCallSettings.Builder<ExportModelRequest, Operation> exportModelSettings;
672     private final OperationCallSettings.Builder<ExportModelRequest, Empty, OperationMetadata>
673         exportModelOperationSettings;
674     private final UnaryCallSettings.Builder<GetModelEvaluationRequest, ModelEvaluation>
675         getModelEvaluationSettings;
676     private final PagedCallSettings.Builder<
677             ListModelEvaluationsRequest,
678             ListModelEvaluationsResponse,
679             ListModelEvaluationsPagedResponse>
680         listModelEvaluationsSettings;
681     private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
682         RETRYABLE_CODE_DEFINITIONS;
683 
684     static {
685       ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
686           ImmutableMap.builder();
687       definitions.put(
688           "no_retry_0_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
689       definitions.put(
690           "retry_policy_1_codes",
691           ImmutableSet.copyOf(
692               Lists.<StatusCode.Code>newArrayList(
693                   StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
694       RETRYABLE_CODE_DEFINITIONS = definitions.build();
695     }
696 
697     private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
698 
699     static {
700       ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
701       RetrySettings settings = null;
702       settings =
703           RetrySettings.newBuilder()
704               .setInitialRpcTimeout(Duration.ofMillis(5000L))
705               .setRpcTimeoutMultiplier(1.0)
706               .setMaxRpcTimeout(Duration.ofMillis(5000L))
707               .setTotalTimeout(Duration.ofMillis(5000L))
708               .build();
709       definitions.put("no_retry_0_params", settings);
710       settings =
711           RetrySettings.newBuilder()
712               .setInitialRetryDelay(Duration.ofMillis(100L))
713               .setRetryDelayMultiplier(1.3)
714               .setMaxRetryDelay(Duration.ofMillis(60000L))
715               .setInitialRpcTimeout(Duration.ofMillis(5000L))
716               .setRpcTimeoutMultiplier(1.0)
717               .setMaxRpcTimeout(Duration.ofMillis(5000L))
718               .setTotalTimeout(Duration.ofMillis(5000L))
719               .build();
720       definitions.put("retry_policy_1_params", settings);
721       RETRY_PARAM_DEFINITIONS = definitions.build();
722     }
723 
Builder()724     protected Builder() {
725       this(((ClientContext) null));
726     }
727 
Builder(ClientContext clientContext)728     protected Builder(ClientContext clientContext) {
729       super(clientContext);
730 
731       createDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
732       createDatasetOperationSettings = OperationCallSettings.newBuilder();
733       getDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
734       listDatasetsSettings = PagedCallSettings.newBuilder(LIST_DATASETS_PAGE_STR_FACT);
735       updateDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
736       deleteDatasetSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
737       deleteDatasetOperationSettings = OperationCallSettings.newBuilder();
738       importDataSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
739       importDataOperationSettings = OperationCallSettings.newBuilder();
740       exportDataSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
741       exportDataOperationSettings = OperationCallSettings.newBuilder();
742       getAnnotationSpecSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
743       createModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
744       createModelOperationSettings = OperationCallSettings.newBuilder();
745       getModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
746       listModelsSettings = PagedCallSettings.newBuilder(LIST_MODELS_PAGE_STR_FACT);
747       deleteModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
748       deleteModelOperationSettings = OperationCallSettings.newBuilder();
749       updateModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
750       deployModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
751       deployModelOperationSettings = OperationCallSettings.newBuilder();
752       undeployModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
753       undeployModelOperationSettings = OperationCallSettings.newBuilder();
754       exportModelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
755       exportModelOperationSettings = OperationCallSettings.newBuilder();
756       getModelEvaluationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
757       listModelEvaluationsSettings =
758           PagedCallSettings.newBuilder(LIST_MODEL_EVALUATIONS_PAGE_STR_FACT);
759 
760       unaryMethodSettingsBuilders =
761           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
762               createDatasetSettings,
763               getDatasetSettings,
764               listDatasetsSettings,
765               updateDatasetSettings,
766               deleteDatasetSettings,
767               importDataSettings,
768               exportDataSettings,
769               getAnnotationSpecSettings,
770               createModelSettings,
771               getModelSettings,
772               listModelsSettings,
773               deleteModelSettings,
774               updateModelSettings,
775               deployModelSettings,
776               undeployModelSettings,
777               exportModelSettings,
778               getModelEvaluationSettings,
779               listModelEvaluationsSettings);
780       initDefaults(this);
781     }
782 
Builder(AutoMlStubSettings settings)783     protected Builder(AutoMlStubSettings settings) {
784       super(settings);
785 
786       createDatasetSettings = settings.createDatasetSettings.toBuilder();
787       createDatasetOperationSettings = settings.createDatasetOperationSettings.toBuilder();
788       getDatasetSettings = settings.getDatasetSettings.toBuilder();
789       listDatasetsSettings = settings.listDatasetsSettings.toBuilder();
790       updateDatasetSettings = settings.updateDatasetSettings.toBuilder();
791       deleteDatasetSettings = settings.deleteDatasetSettings.toBuilder();
792       deleteDatasetOperationSettings = settings.deleteDatasetOperationSettings.toBuilder();
793       importDataSettings = settings.importDataSettings.toBuilder();
794       importDataOperationSettings = settings.importDataOperationSettings.toBuilder();
795       exportDataSettings = settings.exportDataSettings.toBuilder();
796       exportDataOperationSettings = settings.exportDataOperationSettings.toBuilder();
797       getAnnotationSpecSettings = settings.getAnnotationSpecSettings.toBuilder();
798       createModelSettings = settings.createModelSettings.toBuilder();
799       createModelOperationSettings = settings.createModelOperationSettings.toBuilder();
800       getModelSettings = settings.getModelSettings.toBuilder();
801       listModelsSettings = settings.listModelsSettings.toBuilder();
802       deleteModelSettings = settings.deleteModelSettings.toBuilder();
803       deleteModelOperationSettings = settings.deleteModelOperationSettings.toBuilder();
804       updateModelSettings = settings.updateModelSettings.toBuilder();
805       deployModelSettings = settings.deployModelSettings.toBuilder();
806       deployModelOperationSettings = settings.deployModelOperationSettings.toBuilder();
807       undeployModelSettings = settings.undeployModelSettings.toBuilder();
808       undeployModelOperationSettings = settings.undeployModelOperationSettings.toBuilder();
809       exportModelSettings = settings.exportModelSettings.toBuilder();
810       exportModelOperationSettings = settings.exportModelOperationSettings.toBuilder();
811       getModelEvaluationSettings = settings.getModelEvaluationSettings.toBuilder();
812       listModelEvaluationsSettings = settings.listModelEvaluationsSettings.toBuilder();
813 
814       unaryMethodSettingsBuilders =
815           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
816               createDatasetSettings,
817               getDatasetSettings,
818               listDatasetsSettings,
819               updateDatasetSettings,
820               deleteDatasetSettings,
821               importDataSettings,
822               exportDataSettings,
823               getAnnotationSpecSettings,
824               createModelSettings,
825               getModelSettings,
826               listModelsSettings,
827               deleteModelSettings,
828               updateModelSettings,
829               deployModelSettings,
830               undeployModelSettings,
831               exportModelSettings,
832               getModelEvaluationSettings,
833               listModelEvaluationsSettings);
834     }
835 
createDefault()836     private static Builder createDefault() {
837       Builder builder = new Builder(((ClientContext) null));
838 
839       builder.setTransportChannelProvider(defaultTransportChannelProvider());
840       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
841       builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
842       builder.setEndpoint(getDefaultEndpoint());
843       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
844       builder.setSwitchToMtlsEndpointAllowed(true);
845 
846       return initDefaults(builder);
847     }
848 
createHttpJsonDefault()849     private static Builder createHttpJsonDefault() {
850       Builder builder = new Builder(((ClientContext) null));
851 
852       builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
853       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
854       builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
855       builder.setEndpoint(getDefaultEndpoint());
856       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
857       builder.setSwitchToMtlsEndpointAllowed(true);
858 
859       return initDefaults(builder);
860     }
861 
initDefaults(Builder builder)862     private static Builder initDefaults(Builder builder) {
863       builder
864           .createDatasetSettings()
865           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
866           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
867 
868       builder
869           .getDatasetSettings()
870           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
871           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
872 
873       builder
874           .listDatasetsSettings()
875           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
876           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
877 
878       builder
879           .updateDatasetSettings()
880           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
881           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
882 
883       builder
884           .deleteDatasetSettings()
885           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
886           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
887 
888       builder
889           .importDataSettings()
890           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
891           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
892 
893       builder
894           .exportDataSettings()
895           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
896           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
897 
898       builder
899           .getAnnotationSpecSettings()
900           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
901           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
902 
903       builder
904           .createModelSettings()
905           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
906           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
907 
908       builder
909           .getModelSettings()
910           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
911           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
912 
913       builder
914           .listModelsSettings()
915           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
916           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
917 
918       builder
919           .deleteModelSettings()
920           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
921           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
922 
923       builder
924           .updateModelSettings()
925           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
926           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
927 
928       builder
929           .deployModelSettings()
930           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
931           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
932 
933       builder
934           .undeployModelSettings()
935           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
936           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
937 
938       builder
939           .exportModelSettings()
940           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
941           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
942 
943       builder
944           .getModelEvaluationSettings()
945           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
946           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
947 
948       builder
949           .listModelEvaluationsSettings()
950           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
951           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
952 
953       builder
954           .createDatasetOperationSettings()
955           .setInitialCallSettings(
956               UnaryCallSettings
957                   .<CreateDatasetRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
958                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
959                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
960                   .build())
961           .setResponseTransformer(
962               ProtoOperationTransformers.ResponseTransformer.create(Dataset.class))
963           .setMetadataTransformer(
964               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
965           .setPollingAlgorithm(
966               OperationTimedPollAlgorithm.create(
967                   RetrySettings.newBuilder()
968                       .setInitialRetryDelay(Duration.ofMillis(5000L))
969                       .setRetryDelayMultiplier(1.5)
970                       .setMaxRetryDelay(Duration.ofMillis(45000L))
971                       .setInitialRpcTimeout(Duration.ZERO)
972                       .setRpcTimeoutMultiplier(1.0)
973                       .setMaxRpcTimeout(Duration.ZERO)
974                       .setTotalTimeout(Duration.ofMillis(300000L))
975                       .build()));
976 
977       builder
978           .deleteDatasetOperationSettings()
979           .setInitialCallSettings(
980               UnaryCallSettings
981                   .<DeleteDatasetRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
982                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
983                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
984                   .build())
985           .setResponseTransformer(
986               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
987           .setMetadataTransformer(
988               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
989           .setPollingAlgorithm(
990               OperationTimedPollAlgorithm.create(
991                   RetrySettings.newBuilder()
992                       .setInitialRetryDelay(Duration.ofMillis(5000L))
993                       .setRetryDelayMultiplier(1.5)
994                       .setMaxRetryDelay(Duration.ofMillis(45000L))
995                       .setInitialRpcTimeout(Duration.ZERO)
996                       .setRpcTimeoutMultiplier(1.0)
997                       .setMaxRpcTimeout(Duration.ZERO)
998                       .setTotalTimeout(Duration.ofMillis(300000L))
999                       .build()));
1000 
1001       builder
1002           .importDataOperationSettings()
1003           .setInitialCallSettings(
1004               UnaryCallSettings.<ImportDataRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1005                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1006                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1007                   .build())
1008           .setResponseTransformer(
1009               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1010           .setMetadataTransformer(
1011               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1012           .setPollingAlgorithm(
1013               OperationTimedPollAlgorithm.create(
1014                   RetrySettings.newBuilder()
1015                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1016                       .setRetryDelayMultiplier(1.5)
1017                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1018                       .setInitialRpcTimeout(Duration.ZERO)
1019                       .setRpcTimeoutMultiplier(1.0)
1020                       .setMaxRpcTimeout(Duration.ZERO)
1021                       .setTotalTimeout(Duration.ofMillis(300000L))
1022                       .build()));
1023 
1024       builder
1025           .exportDataOperationSettings()
1026           .setInitialCallSettings(
1027               UnaryCallSettings.<ExportDataRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1028                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1029                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1030                   .build())
1031           .setResponseTransformer(
1032               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1033           .setMetadataTransformer(
1034               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1035           .setPollingAlgorithm(
1036               OperationTimedPollAlgorithm.create(
1037                   RetrySettings.newBuilder()
1038                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1039                       .setRetryDelayMultiplier(1.5)
1040                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1041                       .setInitialRpcTimeout(Duration.ZERO)
1042                       .setRpcTimeoutMultiplier(1.0)
1043                       .setMaxRpcTimeout(Duration.ZERO)
1044                       .setTotalTimeout(Duration.ofMillis(300000L))
1045                       .build()));
1046 
1047       builder
1048           .createModelOperationSettings()
1049           .setInitialCallSettings(
1050               UnaryCallSettings.<CreateModelRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1051                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1052                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1053                   .build())
1054           .setResponseTransformer(
1055               ProtoOperationTransformers.ResponseTransformer.create(Model.class))
1056           .setMetadataTransformer(
1057               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1058           .setPollingAlgorithm(
1059               OperationTimedPollAlgorithm.create(
1060                   RetrySettings.newBuilder()
1061                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1062                       .setRetryDelayMultiplier(1.5)
1063                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1064                       .setInitialRpcTimeout(Duration.ZERO)
1065                       .setRpcTimeoutMultiplier(1.0)
1066                       .setMaxRpcTimeout(Duration.ZERO)
1067                       .setTotalTimeout(Duration.ofMillis(300000L))
1068                       .build()));
1069 
1070       builder
1071           .deleteModelOperationSettings()
1072           .setInitialCallSettings(
1073               UnaryCallSettings.<DeleteModelRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1074                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
1075                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
1076                   .build())
1077           .setResponseTransformer(
1078               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1079           .setMetadataTransformer(
1080               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1081           .setPollingAlgorithm(
1082               OperationTimedPollAlgorithm.create(
1083                   RetrySettings.newBuilder()
1084                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1085                       .setRetryDelayMultiplier(1.5)
1086                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1087                       .setInitialRpcTimeout(Duration.ZERO)
1088                       .setRpcTimeoutMultiplier(1.0)
1089                       .setMaxRpcTimeout(Duration.ZERO)
1090                       .setTotalTimeout(Duration.ofMillis(300000L))
1091                       .build()));
1092 
1093       builder
1094           .deployModelOperationSettings()
1095           .setInitialCallSettings(
1096               UnaryCallSettings.<DeployModelRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1097                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1098                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1099                   .build())
1100           .setResponseTransformer(
1101               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1102           .setMetadataTransformer(
1103               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1104           .setPollingAlgorithm(
1105               OperationTimedPollAlgorithm.create(
1106                   RetrySettings.newBuilder()
1107                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1108                       .setRetryDelayMultiplier(1.5)
1109                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1110                       .setInitialRpcTimeout(Duration.ZERO)
1111                       .setRpcTimeoutMultiplier(1.0)
1112                       .setMaxRpcTimeout(Duration.ZERO)
1113                       .setTotalTimeout(Duration.ofMillis(300000L))
1114                       .build()));
1115 
1116       builder
1117           .undeployModelOperationSettings()
1118           .setInitialCallSettings(
1119               UnaryCallSettings
1120                   .<UndeployModelRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1121                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1122                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1123                   .build())
1124           .setResponseTransformer(
1125               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1126           .setMetadataTransformer(
1127               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1128           .setPollingAlgorithm(
1129               OperationTimedPollAlgorithm.create(
1130                   RetrySettings.newBuilder()
1131                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1132                       .setRetryDelayMultiplier(1.5)
1133                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1134                       .setInitialRpcTimeout(Duration.ZERO)
1135                       .setRpcTimeoutMultiplier(1.0)
1136                       .setMaxRpcTimeout(Duration.ZERO)
1137                       .setTotalTimeout(Duration.ofMillis(300000L))
1138                       .build()));
1139 
1140       builder
1141           .exportModelOperationSettings()
1142           .setInitialCallSettings(
1143               UnaryCallSettings.<ExportModelRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
1144                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
1145                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
1146                   .build())
1147           .setResponseTransformer(
1148               ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
1149           .setMetadataTransformer(
1150               ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class))
1151           .setPollingAlgorithm(
1152               OperationTimedPollAlgorithm.create(
1153                   RetrySettings.newBuilder()
1154                       .setInitialRetryDelay(Duration.ofMillis(5000L))
1155                       .setRetryDelayMultiplier(1.5)
1156                       .setMaxRetryDelay(Duration.ofMillis(45000L))
1157                       .setInitialRpcTimeout(Duration.ZERO)
1158                       .setRpcTimeoutMultiplier(1.0)
1159                       .setMaxRpcTimeout(Duration.ZERO)
1160                       .setTotalTimeout(Duration.ofMillis(300000L))
1161                       .build()));
1162 
1163       return builder;
1164     }
1165 
1166     /**
1167      * Applies the given settings updater function to all of the unary API methods in this service.
1168      *
1169      * <p>Note: This method does not support applying settings to streaming methods.
1170      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)1171     public Builder applyToAllUnaryMethods(
1172         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
1173       super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
1174       return this;
1175     }
1176 
unaryMethodSettingsBuilders()1177     public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
1178       return unaryMethodSettingsBuilders;
1179     }
1180 
1181     /** Returns the builder for the settings used for calls to createDataset. */
createDatasetSettings()1182     public UnaryCallSettings.Builder<CreateDatasetRequest, Operation> createDatasetSettings() {
1183       return createDatasetSettings;
1184     }
1185 
1186     /** Returns the builder for the settings used for calls to createDataset. */
1187     @BetaApi(
1188         "The surface for use by generated code is not stable yet and may change in the future.")
1189     public OperationCallSettings.Builder<CreateDatasetRequest, Dataset, OperationMetadata>
createDatasetOperationSettings()1190         createDatasetOperationSettings() {
1191       return createDatasetOperationSettings;
1192     }
1193 
1194     /** Returns the builder for the settings used for calls to getDataset. */
getDatasetSettings()1195     public UnaryCallSettings.Builder<GetDatasetRequest, Dataset> getDatasetSettings() {
1196       return getDatasetSettings;
1197     }
1198 
1199     /** Returns the builder for the settings used for calls to listDatasets. */
1200     public PagedCallSettings.Builder<
1201             ListDatasetsRequest, ListDatasetsResponse, ListDatasetsPagedResponse>
listDatasetsSettings()1202         listDatasetsSettings() {
1203       return listDatasetsSettings;
1204     }
1205 
1206     /** Returns the builder for the settings used for calls to updateDataset. */
updateDatasetSettings()1207     public UnaryCallSettings.Builder<UpdateDatasetRequest, Dataset> updateDatasetSettings() {
1208       return updateDatasetSettings;
1209     }
1210 
1211     /** Returns the builder for the settings used for calls to deleteDataset. */
deleteDatasetSettings()1212     public UnaryCallSettings.Builder<DeleteDatasetRequest, Operation> deleteDatasetSettings() {
1213       return deleteDatasetSettings;
1214     }
1215 
1216     /** Returns the builder for the settings used for calls to deleteDataset. */
1217     @BetaApi(
1218         "The surface for use by generated code is not stable yet and may change in the future.")
1219     public OperationCallSettings.Builder<DeleteDatasetRequest, Empty, OperationMetadata>
deleteDatasetOperationSettings()1220         deleteDatasetOperationSettings() {
1221       return deleteDatasetOperationSettings;
1222     }
1223 
1224     /** Returns the builder for the settings used for calls to importData. */
importDataSettings()1225     public UnaryCallSettings.Builder<ImportDataRequest, Operation> importDataSettings() {
1226       return importDataSettings;
1227     }
1228 
1229     /** Returns the builder for the settings used for calls to importData. */
1230     @BetaApi(
1231         "The surface for use by generated code is not stable yet and may change in the future.")
1232     public OperationCallSettings.Builder<ImportDataRequest, Empty, OperationMetadata>
importDataOperationSettings()1233         importDataOperationSettings() {
1234       return importDataOperationSettings;
1235     }
1236 
1237     /** Returns the builder for the settings used for calls to exportData. */
exportDataSettings()1238     public UnaryCallSettings.Builder<ExportDataRequest, Operation> exportDataSettings() {
1239       return exportDataSettings;
1240     }
1241 
1242     /** Returns the builder for the settings used for calls to exportData. */
1243     @BetaApi(
1244         "The surface for use by generated code is not stable yet and may change in the future.")
1245     public OperationCallSettings.Builder<ExportDataRequest, Empty, OperationMetadata>
exportDataOperationSettings()1246         exportDataOperationSettings() {
1247       return exportDataOperationSettings;
1248     }
1249 
1250     /** Returns the builder for the settings used for calls to getAnnotationSpec. */
1251     public UnaryCallSettings.Builder<GetAnnotationSpecRequest, AnnotationSpec>
getAnnotationSpecSettings()1252         getAnnotationSpecSettings() {
1253       return getAnnotationSpecSettings;
1254     }
1255 
1256     /** Returns the builder for the settings used for calls to createModel. */
createModelSettings()1257     public UnaryCallSettings.Builder<CreateModelRequest, Operation> createModelSettings() {
1258       return createModelSettings;
1259     }
1260 
1261     /** Returns the builder for the settings used for calls to createModel. */
1262     @BetaApi(
1263         "The surface for use by generated code is not stable yet and may change in the future.")
1264     public OperationCallSettings.Builder<CreateModelRequest, Model, OperationMetadata>
createModelOperationSettings()1265         createModelOperationSettings() {
1266       return createModelOperationSettings;
1267     }
1268 
1269     /** Returns the builder for the settings used for calls to getModel. */
getModelSettings()1270     public UnaryCallSettings.Builder<GetModelRequest, Model> getModelSettings() {
1271       return getModelSettings;
1272     }
1273 
1274     /** Returns the builder for the settings used for calls to listModels. */
1275     public PagedCallSettings.Builder<ListModelsRequest, ListModelsResponse, ListModelsPagedResponse>
listModelsSettings()1276         listModelsSettings() {
1277       return listModelsSettings;
1278     }
1279 
1280     /** Returns the builder for the settings used for calls to deleteModel. */
deleteModelSettings()1281     public UnaryCallSettings.Builder<DeleteModelRequest, Operation> deleteModelSettings() {
1282       return deleteModelSettings;
1283     }
1284 
1285     /** Returns the builder for the settings used for calls to deleteModel. */
1286     @BetaApi(
1287         "The surface for use by generated code is not stable yet and may change in the future.")
1288     public OperationCallSettings.Builder<DeleteModelRequest, Empty, OperationMetadata>
deleteModelOperationSettings()1289         deleteModelOperationSettings() {
1290       return deleteModelOperationSettings;
1291     }
1292 
1293     /** Returns the builder for the settings used for calls to updateModel. */
updateModelSettings()1294     public UnaryCallSettings.Builder<UpdateModelRequest, Model> updateModelSettings() {
1295       return updateModelSettings;
1296     }
1297 
1298     /** Returns the builder for the settings used for calls to deployModel. */
deployModelSettings()1299     public UnaryCallSettings.Builder<DeployModelRequest, Operation> deployModelSettings() {
1300       return deployModelSettings;
1301     }
1302 
1303     /** Returns the builder for the settings used for calls to deployModel. */
1304     @BetaApi(
1305         "The surface for use by generated code is not stable yet and may change in the future.")
1306     public OperationCallSettings.Builder<DeployModelRequest, Empty, OperationMetadata>
deployModelOperationSettings()1307         deployModelOperationSettings() {
1308       return deployModelOperationSettings;
1309     }
1310 
1311     /** Returns the builder for the settings used for calls to undeployModel. */
undeployModelSettings()1312     public UnaryCallSettings.Builder<UndeployModelRequest, Operation> undeployModelSettings() {
1313       return undeployModelSettings;
1314     }
1315 
1316     /** Returns the builder for the settings used for calls to undeployModel. */
1317     @BetaApi(
1318         "The surface for use by generated code is not stable yet and may change in the future.")
1319     public OperationCallSettings.Builder<UndeployModelRequest, Empty, OperationMetadata>
undeployModelOperationSettings()1320         undeployModelOperationSettings() {
1321       return undeployModelOperationSettings;
1322     }
1323 
1324     /** Returns the builder for the settings used for calls to exportModel. */
exportModelSettings()1325     public UnaryCallSettings.Builder<ExportModelRequest, Operation> exportModelSettings() {
1326       return exportModelSettings;
1327     }
1328 
1329     /** Returns the builder for the settings used for calls to exportModel. */
1330     @BetaApi(
1331         "The surface for use by generated code is not stable yet and may change in the future.")
1332     public OperationCallSettings.Builder<ExportModelRequest, Empty, OperationMetadata>
exportModelOperationSettings()1333         exportModelOperationSettings() {
1334       return exportModelOperationSettings;
1335     }
1336 
1337     /** Returns the builder for the settings used for calls to getModelEvaluation. */
1338     public UnaryCallSettings.Builder<GetModelEvaluationRequest, ModelEvaluation>
getModelEvaluationSettings()1339         getModelEvaluationSettings() {
1340       return getModelEvaluationSettings;
1341     }
1342 
1343     /** Returns the builder for the settings used for calls to listModelEvaluations. */
1344     public PagedCallSettings.Builder<
1345             ListModelEvaluationsRequest,
1346             ListModelEvaluationsResponse,
1347             ListModelEvaluationsPagedResponse>
listModelEvaluationsSettings()1348         listModelEvaluationsSettings() {
1349       return listModelEvaluationsSettings;
1350     }
1351 
1352     @Override
build()1353     public AutoMlStubSettings build() throws IOException {
1354       return new AutoMlStubSettings(this);
1355     }
1356   }
1357 }
1358