• 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.dialogflow.v2.stub;
18 
19 import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse;
20 import static com.google.cloud.dialogflow.v2.ContextsClient.ListLocationsPagedResponse;
21 
22 import com.google.api.core.ApiFunction;
23 import com.google.api.core.ApiFuture;
24 import com.google.api.core.BetaApi;
25 import com.google.api.gax.core.GaxProperties;
26 import com.google.api.gax.core.GoogleCredentialsProvider;
27 import com.google.api.gax.core.InstantiatingExecutorProvider;
28 import com.google.api.gax.grpc.GaxGrpcProperties;
29 import com.google.api.gax.grpc.GrpcTransportChannel;
30 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
31 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
32 import com.google.api.gax.httpjson.HttpJsonTransportChannel;
33 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
34 import com.google.api.gax.retrying.RetrySettings;
35 import com.google.api.gax.rpc.ApiCallContext;
36 import com.google.api.gax.rpc.ApiClientHeaderProvider;
37 import com.google.api.gax.rpc.ClientContext;
38 import com.google.api.gax.rpc.PageContext;
39 import com.google.api.gax.rpc.PagedCallSettings;
40 import com.google.api.gax.rpc.PagedListDescriptor;
41 import com.google.api.gax.rpc.PagedListResponseFactory;
42 import com.google.api.gax.rpc.StatusCode;
43 import com.google.api.gax.rpc.StubSettings;
44 import com.google.api.gax.rpc.TransportChannelProvider;
45 import com.google.api.gax.rpc.UnaryCallSettings;
46 import com.google.api.gax.rpc.UnaryCallable;
47 import com.google.cloud.dialogflow.v2.Context;
48 import com.google.cloud.dialogflow.v2.CreateContextRequest;
49 import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest;
50 import com.google.cloud.dialogflow.v2.DeleteContextRequest;
51 import com.google.cloud.dialogflow.v2.GetContextRequest;
52 import com.google.cloud.dialogflow.v2.ListContextsRequest;
53 import com.google.cloud.dialogflow.v2.ListContextsResponse;
54 import com.google.cloud.dialogflow.v2.UpdateContextRequest;
55 import com.google.cloud.location.GetLocationRequest;
56 import com.google.cloud.location.ListLocationsRequest;
57 import com.google.cloud.location.ListLocationsResponse;
58 import com.google.cloud.location.Location;
59 import com.google.common.collect.ImmutableList;
60 import com.google.common.collect.ImmutableMap;
61 import com.google.common.collect.ImmutableSet;
62 import com.google.common.collect.Lists;
63 import com.google.protobuf.Empty;
64 import java.io.IOException;
65 import java.util.List;
66 import javax.annotation.Generated;
67 import org.threeten.bp.Duration;
68 
69 // AUTO-GENERATED DOCUMENTATION AND CLASS.
70 /**
71  * Settings class to configure an instance of {@link ContextsStub}.
72  *
73  * <p>The default instance has everything set to sensible defaults:
74  *
75  * <ul>
76  *   <li>The default service address (dialogflow.googleapis.com) and default port (443) are used.
77  *   <li>Credentials are acquired automatically through Application Default Credentials.
78  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
79  * </ul>
80  *
81  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
82  * build() is called, the tree of builders is called to create the complete settings object.
83  *
84  * <p>For example, to set the total timeout of getContext to 30 seconds:
85  *
86  * <pre>{@code
87  * // This snippet has been automatically generated and should be regarded as a code template only.
88  * // It will require modifications to work:
89  * // - It may require correct/in-range values for request initialization.
90  * // - It may require specifying regional endpoints when creating the service client as shown in
91  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
92  * ContextsStubSettings.Builder contextsSettingsBuilder = ContextsStubSettings.newBuilder();
93  * contextsSettingsBuilder
94  *     .getContextSettings()
95  *     .setRetrySettings(
96  *         contextsSettingsBuilder
97  *             .getContextSettings()
98  *             .getRetrySettings()
99  *             .toBuilder()
100  *             .setTotalTimeout(Duration.ofSeconds(30))
101  *             .build());
102  * ContextsStubSettings contextsSettings = contextsSettingsBuilder.build();
103  * }</pre>
104  */
105 @Generated("by gapic-generator-java")
106 public class ContextsStubSettings extends StubSettings<ContextsStubSettings> {
107   /** The default scopes of the service. */
108   private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
109       ImmutableList.<String>builder()
110           .add("https://www.googleapis.com/auth/cloud-platform")
111           .add("https://www.googleapis.com/auth/dialogflow")
112           .build();
113 
114   private final PagedCallSettings<
115           ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>
116       listContextsSettings;
117   private final UnaryCallSettings<GetContextRequest, Context> getContextSettings;
118   private final UnaryCallSettings<CreateContextRequest, Context> createContextSettings;
119   private final UnaryCallSettings<UpdateContextRequest, Context> updateContextSettings;
120   private final UnaryCallSettings<DeleteContextRequest, Empty> deleteContextSettings;
121   private final UnaryCallSettings<DeleteAllContextsRequest, Empty> deleteAllContextsSettings;
122   private final PagedCallSettings<
123           ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
124       listLocationsSettings;
125   private final UnaryCallSettings<GetLocationRequest, Location> getLocationSettings;
126 
127   private static final PagedListDescriptor<ListContextsRequest, ListContextsResponse, Context>
128       LIST_CONTEXTS_PAGE_STR_DESC =
129           new PagedListDescriptor<ListContextsRequest, ListContextsResponse, Context>() {
130             @Override
131             public String emptyToken() {
132               return "";
133             }
134 
135             @Override
136             public ListContextsRequest injectToken(ListContextsRequest payload, String token) {
137               return ListContextsRequest.newBuilder(payload).setPageToken(token).build();
138             }
139 
140             @Override
141             public ListContextsRequest injectPageSize(ListContextsRequest payload, int pageSize) {
142               return ListContextsRequest.newBuilder(payload).setPageSize(pageSize).build();
143             }
144 
145             @Override
146             public Integer extractPageSize(ListContextsRequest payload) {
147               return payload.getPageSize();
148             }
149 
150             @Override
151             public String extractNextToken(ListContextsResponse payload) {
152               return payload.getNextPageToken();
153             }
154 
155             @Override
156             public Iterable<Context> extractResources(ListContextsResponse payload) {
157               return payload.getContextsList() == null
158                   ? ImmutableList.<Context>of()
159                   : payload.getContextsList();
160             }
161           };
162 
163   private static final PagedListDescriptor<ListLocationsRequest, ListLocationsResponse, Location>
164       LIST_LOCATIONS_PAGE_STR_DESC =
165           new PagedListDescriptor<ListLocationsRequest, ListLocationsResponse, Location>() {
166             @Override
167             public String emptyToken() {
168               return "";
169             }
170 
171             @Override
172             public ListLocationsRequest injectToken(ListLocationsRequest payload, String token) {
173               return ListLocationsRequest.newBuilder(payload).setPageToken(token).build();
174             }
175 
176             @Override
177             public ListLocationsRequest injectPageSize(ListLocationsRequest payload, int pageSize) {
178               return ListLocationsRequest.newBuilder(payload).setPageSize(pageSize).build();
179             }
180 
181             @Override
182             public Integer extractPageSize(ListLocationsRequest payload) {
183               return payload.getPageSize();
184             }
185 
186             @Override
187             public String extractNextToken(ListLocationsResponse payload) {
188               return payload.getNextPageToken();
189             }
190 
191             @Override
192             public Iterable<Location> extractResources(ListLocationsResponse payload) {
193               return payload.getLocationsList() == null
194                   ? ImmutableList.<Location>of()
195                   : payload.getLocationsList();
196             }
197           };
198 
199   private static final PagedListResponseFactory<
200           ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>
201       LIST_CONTEXTS_PAGE_STR_FACT =
202           new PagedListResponseFactory<
203               ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>() {
204             @Override
205             public ApiFuture<ListContextsPagedResponse> getFuturePagedResponse(
206                 UnaryCallable<ListContextsRequest, ListContextsResponse> callable,
207                 ListContextsRequest request,
208                 ApiCallContext context,
209                 ApiFuture<ListContextsResponse> futureResponse) {
210               PageContext<ListContextsRequest, ListContextsResponse, Context> pageContext =
211                   PageContext.create(callable, LIST_CONTEXTS_PAGE_STR_DESC, request, context);
212               return ListContextsPagedResponse.createAsync(pageContext, futureResponse);
213             }
214           };
215 
216   private static final PagedListResponseFactory<
217           ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
218       LIST_LOCATIONS_PAGE_STR_FACT =
219           new PagedListResponseFactory<
220               ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>() {
221             @Override
222             public ApiFuture<ListLocationsPagedResponse> getFuturePagedResponse(
223                 UnaryCallable<ListLocationsRequest, ListLocationsResponse> callable,
224                 ListLocationsRequest request,
225                 ApiCallContext context,
226                 ApiFuture<ListLocationsResponse> futureResponse) {
227               PageContext<ListLocationsRequest, ListLocationsResponse, Location> pageContext =
228                   PageContext.create(callable, LIST_LOCATIONS_PAGE_STR_DESC, request, context);
229               return ListLocationsPagedResponse.createAsync(pageContext, futureResponse);
230             }
231           };
232 
233   /** Returns the object with the settings used for calls to listContexts. */
234   public PagedCallSettings<ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>
listContextsSettings()235       listContextsSettings() {
236     return listContextsSettings;
237   }
238 
239   /** Returns the object with the settings used for calls to getContext. */
getContextSettings()240   public UnaryCallSettings<GetContextRequest, Context> getContextSettings() {
241     return getContextSettings;
242   }
243 
244   /** Returns the object with the settings used for calls to createContext. */
createContextSettings()245   public UnaryCallSettings<CreateContextRequest, Context> createContextSettings() {
246     return createContextSettings;
247   }
248 
249   /** Returns the object with the settings used for calls to updateContext. */
updateContextSettings()250   public UnaryCallSettings<UpdateContextRequest, Context> updateContextSettings() {
251     return updateContextSettings;
252   }
253 
254   /** Returns the object with the settings used for calls to deleteContext. */
deleteContextSettings()255   public UnaryCallSettings<DeleteContextRequest, Empty> deleteContextSettings() {
256     return deleteContextSettings;
257   }
258 
259   /** Returns the object with the settings used for calls to deleteAllContexts. */
deleteAllContextsSettings()260   public UnaryCallSettings<DeleteAllContextsRequest, Empty> deleteAllContextsSettings() {
261     return deleteAllContextsSettings;
262   }
263 
264   /** Returns the object with the settings used for calls to listLocations. */
265   public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings()266       listLocationsSettings() {
267     return listLocationsSettings;
268   }
269 
270   /** Returns the object with the settings used for calls to getLocation. */
getLocationSettings()271   public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() {
272     return getLocationSettings;
273   }
274 
createStub()275   public ContextsStub createStub() throws IOException {
276     if (getTransportChannelProvider()
277         .getTransportName()
278         .equals(GrpcTransportChannel.getGrpcTransportName())) {
279       return GrpcContextsStub.create(this);
280     }
281     if (getTransportChannelProvider()
282         .getTransportName()
283         .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
284       return HttpJsonContextsStub.create(this);
285     }
286     throw new UnsupportedOperationException(
287         String.format(
288             "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
289   }
290 
291   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()292   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
293     return InstantiatingExecutorProvider.newBuilder();
294   }
295 
296   /** Returns the default service endpoint. */
getDefaultEndpoint()297   public static String getDefaultEndpoint() {
298     return "dialogflow.googleapis.com:443";
299   }
300 
301   /** Returns the default mTLS service endpoint. */
getDefaultMtlsEndpoint()302   public static String getDefaultMtlsEndpoint() {
303     return "dialogflow.mtls.googleapis.com:443";
304   }
305 
306   /** Returns the default service scopes. */
getDefaultServiceScopes()307   public static List<String> getDefaultServiceScopes() {
308     return DEFAULT_SERVICE_SCOPES;
309   }
310 
311   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()312   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
313     return GoogleCredentialsProvider.newBuilder()
314         .setScopesToApply(DEFAULT_SERVICE_SCOPES)
315         .setUseJwtAccessWithScope(true);
316   }
317 
318   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()319   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
320     return InstantiatingGrpcChannelProvider.newBuilder()
321         .setMaxInboundMessageSize(Integer.MAX_VALUE);
322   }
323 
324   /** Returns a builder for the default REST ChannelProvider for this service. */
325   @BetaApi
326   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()327       defaultHttpJsonTransportProviderBuilder() {
328     return InstantiatingHttpJsonChannelProvider.newBuilder();
329   }
330 
defaultTransportChannelProvider()331   public static TransportChannelProvider defaultTransportChannelProvider() {
332     return defaultGrpcTransportProviderBuilder().build();
333   }
334 
335   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultGrpcApiClientHeaderProviderBuilder()336   public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
337     return ApiClientHeaderProvider.newBuilder()
338         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class))
339         .setTransportToken(
340             GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
341   }
342 
343   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultHttpJsonApiClientHeaderProviderBuilder()344   public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
345     return ApiClientHeaderProvider.newBuilder()
346         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class))
347         .setTransportToken(
348             GaxHttpJsonProperties.getHttpJsonTokenName(),
349             GaxHttpJsonProperties.getHttpJsonVersion());
350   }
351 
defaultApiClientHeaderProviderBuilder()352   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
353     return ContextsStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
354   }
355 
356   /** Returns a new gRPC builder for this class. */
newBuilder()357   public static Builder newBuilder() {
358     return Builder.createDefault();
359   }
360 
361   /** Returns a new REST builder for this class. */
newHttpJsonBuilder()362   public static Builder newHttpJsonBuilder() {
363     return Builder.createHttpJsonDefault();
364   }
365 
366   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)367   public static Builder newBuilder(ClientContext clientContext) {
368     return new Builder(clientContext);
369   }
370 
371   /** Returns a builder containing all the values of this settings class. */
toBuilder()372   public Builder toBuilder() {
373     return new Builder(this);
374   }
375 
ContextsStubSettings(Builder settingsBuilder)376   protected ContextsStubSettings(Builder settingsBuilder) throws IOException {
377     super(settingsBuilder);
378 
379     listContextsSettings = settingsBuilder.listContextsSettings().build();
380     getContextSettings = settingsBuilder.getContextSettings().build();
381     createContextSettings = settingsBuilder.createContextSettings().build();
382     updateContextSettings = settingsBuilder.updateContextSettings().build();
383     deleteContextSettings = settingsBuilder.deleteContextSettings().build();
384     deleteAllContextsSettings = settingsBuilder.deleteAllContextsSettings().build();
385     listLocationsSettings = settingsBuilder.listLocationsSettings().build();
386     getLocationSettings = settingsBuilder.getLocationSettings().build();
387   }
388 
389   /** Builder for ContextsStubSettings. */
390   public static class Builder extends StubSettings.Builder<ContextsStubSettings, Builder> {
391     private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
392     private final PagedCallSettings.Builder<
393             ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>
394         listContextsSettings;
395     private final UnaryCallSettings.Builder<GetContextRequest, Context> getContextSettings;
396     private final UnaryCallSettings.Builder<CreateContextRequest, Context> createContextSettings;
397     private final UnaryCallSettings.Builder<UpdateContextRequest, Context> updateContextSettings;
398     private final UnaryCallSettings.Builder<DeleteContextRequest, Empty> deleteContextSettings;
399     private final UnaryCallSettings.Builder<DeleteAllContextsRequest, Empty>
400         deleteAllContextsSettings;
401     private final PagedCallSettings.Builder<
402             ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
403         listLocationsSettings;
404     private final UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings;
405     private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
406         RETRYABLE_CODE_DEFINITIONS;
407 
408     static {
409       ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
410           ImmutableMap.builder();
411       definitions.put(
412           "retry_policy_0_codes",
413           ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
414       RETRYABLE_CODE_DEFINITIONS = definitions.build();
415     }
416 
417     private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
418 
419     static {
420       ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
421       RetrySettings settings = null;
422       settings =
423           RetrySettings.newBuilder()
424               .setInitialRetryDelay(Duration.ofMillis(100L))
425               .setRetryDelayMultiplier(1.3)
426               .setMaxRetryDelay(Duration.ofMillis(60000L))
427               .setInitialRpcTimeout(Duration.ofMillis(60000L))
428               .setRpcTimeoutMultiplier(1.0)
429               .setMaxRpcTimeout(Duration.ofMillis(60000L))
430               .setTotalTimeout(Duration.ofMillis(60000L))
431               .build();
432       definitions.put("retry_policy_0_params", settings);
433       RETRY_PARAM_DEFINITIONS = definitions.build();
434     }
435 
Builder()436     protected Builder() {
437       this(((ClientContext) null));
438     }
439 
Builder(ClientContext clientContext)440     protected Builder(ClientContext clientContext) {
441       super(clientContext);
442 
443       listContextsSettings = PagedCallSettings.newBuilder(LIST_CONTEXTS_PAGE_STR_FACT);
444       getContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
445       createContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
446       updateContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
447       deleteContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
448       deleteAllContextsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
449       listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT);
450       getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
451 
452       unaryMethodSettingsBuilders =
453           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
454               listContextsSettings,
455               getContextSettings,
456               createContextSettings,
457               updateContextSettings,
458               deleteContextSettings,
459               deleteAllContextsSettings,
460               listLocationsSettings,
461               getLocationSettings);
462       initDefaults(this);
463     }
464 
Builder(ContextsStubSettings settings)465     protected Builder(ContextsStubSettings settings) {
466       super(settings);
467 
468       listContextsSettings = settings.listContextsSettings.toBuilder();
469       getContextSettings = settings.getContextSettings.toBuilder();
470       createContextSettings = settings.createContextSettings.toBuilder();
471       updateContextSettings = settings.updateContextSettings.toBuilder();
472       deleteContextSettings = settings.deleteContextSettings.toBuilder();
473       deleteAllContextsSettings = settings.deleteAllContextsSettings.toBuilder();
474       listLocationsSettings = settings.listLocationsSettings.toBuilder();
475       getLocationSettings = settings.getLocationSettings.toBuilder();
476 
477       unaryMethodSettingsBuilders =
478           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
479               listContextsSettings,
480               getContextSettings,
481               createContextSettings,
482               updateContextSettings,
483               deleteContextSettings,
484               deleteAllContextsSettings,
485               listLocationsSettings,
486               getLocationSettings);
487     }
488 
createDefault()489     private static Builder createDefault() {
490       Builder builder = new Builder(((ClientContext) null));
491 
492       builder.setTransportChannelProvider(defaultTransportChannelProvider());
493       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
494       builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
495       builder.setEndpoint(getDefaultEndpoint());
496       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
497       builder.setSwitchToMtlsEndpointAllowed(true);
498 
499       return initDefaults(builder);
500     }
501 
createHttpJsonDefault()502     private static Builder createHttpJsonDefault() {
503       Builder builder = new Builder(((ClientContext) null));
504 
505       builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
506       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
507       builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
508       builder.setEndpoint(getDefaultEndpoint());
509       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
510       builder.setSwitchToMtlsEndpointAllowed(true);
511 
512       return initDefaults(builder);
513     }
514 
initDefaults(Builder builder)515     private static Builder initDefaults(Builder builder) {
516       builder
517           .listContextsSettings()
518           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
519           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
520 
521       builder
522           .getContextSettings()
523           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
524           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
525 
526       builder
527           .createContextSettings()
528           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
529           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
530 
531       builder
532           .updateContextSettings()
533           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
534           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
535 
536       builder
537           .deleteContextSettings()
538           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
539           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
540 
541       builder
542           .deleteAllContextsSettings()
543           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
544           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
545 
546       builder
547           .listLocationsSettings()
548           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
549           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
550 
551       builder
552           .getLocationSettings()
553           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
554           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
555 
556       return builder;
557     }
558 
559     /**
560      * Applies the given settings updater function to all of the unary API methods in this service.
561      *
562      * <p>Note: This method does not support applying settings to streaming methods.
563      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)564     public Builder applyToAllUnaryMethods(
565         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
566       super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
567       return this;
568     }
569 
unaryMethodSettingsBuilders()570     public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
571       return unaryMethodSettingsBuilders;
572     }
573 
574     /** Returns the builder for the settings used for calls to listContexts. */
575     public PagedCallSettings.Builder<
576             ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>
listContextsSettings()577         listContextsSettings() {
578       return listContextsSettings;
579     }
580 
581     /** Returns the builder for the settings used for calls to getContext. */
getContextSettings()582     public UnaryCallSettings.Builder<GetContextRequest, Context> getContextSettings() {
583       return getContextSettings;
584     }
585 
586     /** Returns the builder for the settings used for calls to createContext. */
createContextSettings()587     public UnaryCallSettings.Builder<CreateContextRequest, Context> createContextSettings() {
588       return createContextSettings;
589     }
590 
591     /** Returns the builder for the settings used for calls to updateContext. */
updateContextSettings()592     public UnaryCallSettings.Builder<UpdateContextRequest, Context> updateContextSettings() {
593       return updateContextSettings;
594     }
595 
596     /** Returns the builder for the settings used for calls to deleteContext. */
deleteContextSettings()597     public UnaryCallSettings.Builder<DeleteContextRequest, Empty> deleteContextSettings() {
598       return deleteContextSettings;
599     }
600 
601     /** Returns the builder for the settings used for calls to deleteAllContexts. */
deleteAllContextsSettings()602     public UnaryCallSettings.Builder<DeleteAllContextsRequest, Empty> deleteAllContextsSettings() {
603       return deleteAllContextsSettings;
604     }
605 
606     /** Returns the builder for the settings used for calls to listLocations. */
607     public PagedCallSettings.Builder<
608             ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings()609         listLocationsSettings() {
610       return listLocationsSettings;
611     }
612 
613     /** Returns the builder for the settings used for calls to getLocation. */
getLocationSettings()614     public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() {
615       return getLocationSettings;
616     }
617 
618     @Override
build()619     public ContextsStubSettings build() throws IOException {
620       return new ContextsStubSettings(this);
621     }
622   }
623 }
624