• 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.compute.v1.stub;
18 
19 import static com.google.cloud.compute.v1.UrlMapsClient.AggregatedListPagedResponse;
20 import static com.google.cloud.compute.v1.UrlMapsClient.ListPagedResponse;
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.httpjson.GaxHttpJsonProperties;
29 import com.google.api.gax.httpjson.HttpJsonTransportChannel;
30 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
31 import com.google.api.gax.httpjson.ProtoOperationTransformers;
32 import com.google.api.gax.longrunning.OperationSnapshot;
33 import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
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.OperationCallSettings;
39 import com.google.api.gax.rpc.PageContext;
40 import com.google.api.gax.rpc.PagedCallSettings;
41 import com.google.api.gax.rpc.PagedListDescriptor;
42 import com.google.api.gax.rpc.PagedListResponseFactory;
43 import com.google.api.gax.rpc.StatusCode;
44 import com.google.api.gax.rpc.StubSettings;
45 import com.google.api.gax.rpc.TransportChannelProvider;
46 import com.google.api.gax.rpc.UnaryCallSettings;
47 import com.google.api.gax.rpc.UnaryCallable;
48 import com.google.cloud.compute.v1.AggregatedListUrlMapsRequest;
49 import com.google.cloud.compute.v1.DeleteUrlMapRequest;
50 import com.google.cloud.compute.v1.GetUrlMapRequest;
51 import com.google.cloud.compute.v1.InsertUrlMapRequest;
52 import com.google.cloud.compute.v1.InvalidateCacheUrlMapRequest;
53 import com.google.cloud.compute.v1.ListUrlMapsRequest;
54 import com.google.cloud.compute.v1.Operation;
55 import com.google.cloud.compute.v1.PatchUrlMapRequest;
56 import com.google.cloud.compute.v1.UpdateUrlMapRequest;
57 import com.google.cloud.compute.v1.UrlMap;
58 import com.google.cloud.compute.v1.UrlMapList;
59 import com.google.cloud.compute.v1.UrlMapsAggregatedList;
60 import com.google.cloud.compute.v1.UrlMapsScopedList;
61 import com.google.cloud.compute.v1.UrlMapsValidateResponse;
62 import com.google.cloud.compute.v1.ValidateUrlMapRequest;
63 import com.google.common.collect.ImmutableList;
64 import com.google.common.collect.ImmutableMap;
65 import com.google.common.collect.ImmutableSet;
66 import com.google.common.collect.Lists;
67 import java.io.IOException;
68 import java.util.Collections;
69 import java.util.List;
70 import java.util.Map;
71 import javax.annotation.Generated;
72 import org.threeten.bp.Duration;
73 
74 // AUTO-GENERATED DOCUMENTATION AND CLASS.
75 /**
76  * Settings class to configure an instance of {@link UrlMapsStub}.
77  *
78  * <p>The default instance has everything set to sensible defaults:
79  *
80  * <ul>
81  *   <li>The default service address (compute.googleapis.com) and default port (443) are used.
82  *   <li>Credentials are acquired automatically through Application Default Credentials.
83  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
84  * </ul>
85  *
86  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
87  * build() is called, the tree of builders is called to create the complete settings object.
88  *
89  * <p>For example, to set the total timeout of get to 30 seconds:
90  *
91  * <pre>{@code
92  * // This snippet has been automatically generated and should be regarded as a code template only.
93  * // It will require modifications to work:
94  * // - It may require correct/in-range values for request initialization.
95  * // - It may require specifying regional endpoints when creating the service client as shown in
96  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
97  * UrlMapsStubSettings.Builder urlMapsSettingsBuilder = UrlMapsStubSettings.newBuilder();
98  * urlMapsSettingsBuilder
99  *     .getSettings()
100  *     .setRetrySettings(
101  *         urlMapsSettingsBuilder
102  *             .getSettings()
103  *             .getRetrySettings()
104  *             .toBuilder()
105  *             .setTotalTimeout(Duration.ofSeconds(30))
106  *             .build());
107  * UrlMapsStubSettings urlMapsSettings = urlMapsSettingsBuilder.build();
108  * }</pre>
109  */
110 @Generated("by gapic-generator-java")
111 public class UrlMapsStubSettings extends StubSettings<UrlMapsStubSettings> {
112   /** The default scopes of the service. */
113   private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
114       ImmutableList.<String>builder()
115           .add("https://www.googleapis.com/auth/compute")
116           .add("https://www.googleapis.com/auth/cloud-platform")
117           .build();
118 
119   private final PagedCallSettings<
120           AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>
121       aggregatedListSettings;
122   private final UnaryCallSettings<DeleteUrlMapRequest, Operation> deleteSettings;
123   private final OperationCallSettings<DeleteUrlMapRequest, Operation, Operation>
124       deleteOperationSettings;
125   private final UnaryCallSettings<GetUrlMapRequest, UrlMap> getSettings;
126   private final UnaryCallSettings<InsertUrlMapRequest, Operation> insertSettings;
127   private final OperationCallSettings<InsertUrlMapRequest, Operation, Operation>
128       insertOperationSettings;
129   private final UnaryCallSettings<InvalidateCacheUrlMapRequest, Operation> invalidateCacheSettings;
130   private final OperationCallSettings<InvalidateCacheUrlMapRequest, Operation, Operation>
131       invalidateCacheOperationSettings;
132   private final PagedCallSettings<ListUrlMapsRequest, UrlMapList, ListPagedResponse> listSettings;
133   private final UnaryCallSettings<PatchUrlMapRequest, Operation> patchSettings;
134   private final OperationCallSettings<PatchUrlMapRequest, Operation, Operation>
135       patchOperationSettings;
136   private final UnaryCallSettings<UpdateUrlMapRequest, Operation> updateSettings;
137   private final OperationCallSettings<UpdateUrlMapRequest, Operation, Operation>
138       updateOperationSettings;
139   private final UnaryCallSettings<ValidateUrlMapRequest, UrlMapsValidateResponse> validateSettings;
140 
141   private static final PagedListDescriptor<
142           AggregatedListUrlMapsRequest, UrlMapsAggregatedList, Map.Entry<String, UrlMapsScopedList>>
143       AGGREGATED_LIST_PAGE_STR_DESC =
144           new PagedListDescriptor<
145               AggregatedListUrlMapsRequest,
146               UrlMapsAggregatedList,
147               Map.Entry<String, UrlMapsScopedList>>() {
148             @Override
149             public String emptyToken() {
150               return "";
151             }
152 
153             @Override
154             public AggregatedListUrlMapsRequest injectToken(
155                 AggregatedListUrlMapsRequest payload, String token) {
156               return AggregatedListUrlMapsRequest.newBuilder(payload).setPageToken(token).build();
157             }
158 
159             @Override
160             public AggregatedListUrlMapsRequest injectPageSize(
161                 AggregatedListUrlMapsRequest payload, int pageSize) {
162               return AggregatedListUrlMapsRequest.newBuilder(payload)
163                   .setMaxResults(pageSize)
164                   .build();
165             }
166 
167             @Override
168             public Integer extractPageSize(AggregatedListUrlMapsRequest payload) {
169               return payload.getMaxResults();
170             }
171 
172             @Override
173             public String extractNextToken(UrlMapsAggregatedList payload) {
174               return payload.getNextPageToken();
175             }
176 
177             @Override
178             public Iterable<Map.Entry<String, UrlMapsScopedList>> extractResources(
179                 UrlMapsAggregatedList payload) {
180               return payload.getItemsMap() == null
181                   ? Collections.<Map.Entry<String, UrlMapsScopedList>>emptySet()
182                   : payload.getItemsMap().entrySet();
183             }
184           };
185 
186   private static final PagedListDescriptor<ListUrlMapsRequest, UrlMapList, UrlMap>
187       LIST_PAGE_STR_DESC =
188           new PagedListDescriptor<ListUrlMapsRequest, UrlMapList, UrlMap>() {
189             @Override
190             public String emptyToken() {
191               return "";
192             }
193 
194             @Override
195             public ListUrlMapsRequest injectToken(ListUrlMapsRequest payload, String token) {
196               return ListUrlMapsRequest.newBuilder(payload).setPageToken(token).build();
197             }
198 
199             @Override
200             public ListUrlMapsRequest injectPageSize(ListUrlMapsRequest payload, int pageSize) {
201               return ListUrlMapsRequest.newBuilder(payload).setMaxResults(pageSize).build();
202             }
203 
204             @Override
205             public Integer extractPageSize(ListUrlMapsRequest payload) {
206               return payload.getMaxResults();
207             }
208 
209             @Override
210             public String extractNextToken(UrlMapList payload) {
211               return payload.getNextPageToken();
212             }
213 
214             @Override
215             public Iterable<UrlMap> extractResources(UrlMapList payload) {
216               return payload.getItemsList() == null
217                   ? ImmutableList.<UrlMap>of()
218                   : payload.getItemsList();
219             }
220           };
221 
222   private static final PagedListResponseFactory<
223           AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>
224       AGGREGATED_LIST_PAGE_STR_FACT =
225           new PagedListResponseFactory<
226               AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>() {
227             @Override
228             public ApiFuture<AggregatedListPagedResponse> getFuturePagedResponse(
229                 UnaryCallable<AggregatedListUrlMapsRequest, UrlMapsAggregatedList> callable,
230                 AggregatedListUrlMapsRequest request,
231                 ApiCallContext context,
232                 ApiFuture<UrlMapsAggregatedList> futureResponse) {
233               PageContext<
234                       AggregatedListUrlMapsRequest,
235                       UrlMapsAggregatedList,
236                       Map.Entry<String, UrlMapsScopedList>>
237                   pageContext =
238                       PageContext.create(callable, AGGREGATED_LIST_PAGE_STR_DESC, request, context);
239               return AggregatedListPagedResponse.createAsync(pageContext, futureResponse);
240             }
241           };
242 
243   private static final PagedListResponseFactory<ListUrlMapsRequest, UrlMapList, ListPagedResponse>
244       LIST_PAGE_STR_FACT =
245           new PagedListResponseFactory<ListUrlMapsRequest, UrlMapList, ListPagedResponse>() {
246             @Override
247             public ApiFuture<ListPagedResponse> getFuturePagedResponse(
248                 UnaryCallable<ListUrlMapsRequest, UrlMapList> callable,
249                 ListUrlMapsRequest request,
250                 ApiCallContext context,
251                 ApiFuture<UrlMapList> futureResponse) {
252               PageContext<ListUrlMapsRequest, UrlMapList, UrlMap> pageContext =
253                   PageContext.create(callable, LIST_PAGE_STR_DESC, request, context);
254               return ListPagedResponse.createAsync(pageContext, futureResponse);
255             }
256           };
257 
258   /** Returns the object with the settings used for calls to aggregatedList. */
259   public PagedCallSettings<
260           AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>
aggregatedListSettings()261       aggregatedListSettings() {
262     return aggregatedListSettings;
263   }
264 
265   /** Returns the object with the settings used for calls to delete. */
deleteSettings()266   public UnaryCallSettings<DeleteUrlMapRequest, Operation> deleteSettings() {
267     return deleteSettings;
268   }
269 
270   /** Returns the object with the settings used for calls to delete. */
271   public OperationCallSettings<DeleteUrlMapRequest, Operation, Operation>
deleteOperationSettings()272       deleteOperationSettings() {
273     return deleteOperationSettings;
274   }
275 
276   /** Returns the object with the settings used for calls to get. */
getSettings()277   public UnaryCallSettings<GetUrlMapRequest, UrlMap> getSettings() {
278     return getSettings;
279   }
280 
281   /** Returns the object with the settings used for calls to insert. */
insertSettings()282   public UnaryCallSettings<InsertUrlMapRequest, Operation> insertSettings() {
283     return insertSettings;
284   }
285 
286   /** Returns the object with the settings used for calls to insert. */
287   public OperationCallSettings<InsertUrlMapRequest, Operation, Operation>
insertOperationSettings()288       insertOperationSettings() {
289     return insertOperationSettings;
290   }
291 
292   /** Returns the object with the settings used for calls to invalidateCache. */
invalidateCacheSettings()293   public UnaryCallSettings<InvalidateCacheUrlMapRequest, Operation> invalidateCacheSettings() {
294     return invalidateCacheSettings;
295   }
296 
297   /** Returns the object with the settings used for calls to invalidateCache. */
298   public OperationCallSettings<InvalidateCacheUrlMapRequest, Operation, Operation>
invalidateCacheOperationSettings()299       invalidateCacheOperationSettings() {
300     return invalidateCacheOperationSettings;
301   }
302 
303   /** Returns the object with the settings used for calls to list. */
listSettings()304   public PagedCallSettings<ListUrlMapsRequest, UrlMapList, ListPagedResponse> listSettings() {
305     return listSettings;
306   }
307 
308   /** Returns the object with the settings used for calls to patch. */
patchSettings()309   public UnaryCallSettings<PatchUrlMapRequest, Operation> patchSettings() {
310     return patchSettings;
311   }
312 
313   /** Returns the object with the settings used for calls to patch. */
patchOperationSettings()314   public OperationCallSettings<PatchUrlMapRequest, Operation, Operation> patchOperationSettings() {
315     return patchOperationSettings;
316   }
317 
318   /** Returns the object with the settings used for calls to update. */
updateSettings()319   public UnaryCallSettings<UpdateUrlMapRequest, Operation> updateSettings() {
320     return updateSettings;
321   }
322 
323   /** Returns the object with the settings used for calls to update. */
324   public OperationCallSettings<UpdateUrlMapRequest, Operation, Operation>
updateOperationSettings()325       updateOperationSettings() {
326     return updateOperationSettings;
327   }
328 
329   /** Returns the object with the settings used for calls to validate. */
validateSettings()330   public UnaryCallSettings<ValidateUrlMapRequest, UrlMapsValidateResponse> validateSettings() {
331     return validateSettings;
332   }
333 
createStub()334   public UrlMapsStub createStub() throws IOException {
335     if (getTransportChannelProvider()
336         .getTransportName()
337         .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
338       return HttpJsonUrlMapsStub.create(this);
339     }
340     throw new UnsupportedOperationException(
341         String.format(
342             "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
343   }
344 
345   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()346   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
347     return InstantiatingExecutorProvider.newBuilder();
348   }
349 
350   /** Returns the default service endpoint. */
getDefaultEndpoint()351   public static String getDefaultEndpoint() {
352     return "compute.googleapis.com:443";
353   }
354 
355   /** Returns the default mTLS service endpoint. */
getDefaultMtlsEndpoint()356   public static String getDefaultMtlsEndpoint() {
357     return "compute.mtls.googleapis.com:443";
358   }
359 
360   /** Returns the default service scopes. */
getDefaultServiceScopes()361   public static List<String> getDefaultServiceScopes() {
362     return DEFAULT_SERVICE_SCOPES;
363   }
364 
365   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()366   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
367     return GoogleCredentialsProvider.newBuilder()
368         .setScopesToApply(DEFAULT_SERVICE_SCOPES)
369         .setUseJwtAccessWithScope(true);
370   }
371 
372   /** Returns a builder for the default ChannelProvider for this service. */
373   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()374       defaultHttpJsonTransportProviderBuilder() {
375     return InstantiatingHttpJsonChannelProvider.newBuilder();
376   }
377 
defaultTransportChannelProvider()378   public static TransportChannelProvider defaultTransportChannelProvider() {
379     return defaultHttpJsonTransportProviderBuilder().build();
380   }
381 
382   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()383   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
384     return ApiClientHeaderProvider.newBuilder()
385         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(UrlMapsStubSettings.class))
386         .setTransportToken(
387             GaxHttpJsonProperties.getHttpJsonTokenName(),
388             GaxHttpJsonProperties.getHttpJsonVersion());
389   }
390 
391   /** Returns a new builder for this class. */
newBuilder()392   public static Builder newBuilder() {
393     return Builder.createDefault();
394   }
395 
396   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)397   public static Builder newBuilder(ClientContext clientContext) {
398     return new Builder(clientContext);
399   }
400 
401   /** Returns a builder containing all the values of this settings class. */
toBuilder()402   public Builder toBuilder() {
403     return new Builder(this);
404   }
405 
UrlMapsStubSettings(Builder settingsBuilder)406   protected UrlMapsStubSettings(Builder settingsBuilder) throws IOException {
407     super(settingsBuilder);
408 
409     aggregatedListSettings = settingsBuilder.aggregatedListSettings().build();
410     deleteSettings = settingsBuilder.deleteSettings().build();
411     deleteOperationSettings = settingsBuilder.deleteOperationSettings().build();
412     getSettings = settingsBuilder.getSettings().build();
413     insertSettings = settingsBuilder.insertSettings().build();
414     insertOperationSettings = settingsBuilder.insertOperationSettings().build();
415     invalidateCacheSettings = settingsBuilder.invalidateCacheSettings().build();
416     invalidateCacheOperationSettings = settingsBuilder.invalidateCacheOperationSettings().build();
417     listSettings = settingsBuilder.listSettings().build();
418     patchSettings = settingsBuilder.patchSettings().build();
419     patchOperationSettings = settingsBuilder.patchOperationSettings().build();
420     updateSettings = settingsBuilder.updateSettings().build();
421     updateOperationSettings = settingsBuilder.updateOperationSettings().build();
422     validateSettings = settingsBuilder.validateSettings().build();
423   }
424 
425   /** Builder for UrlMapsStubSettings. */
426   public static class Builder extends StubSettings.Builder<UrlMapsStubSettings, Builder> {
427     private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
428     private final PagedCallSettings.Builder<
429             AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>
430         aggregatedListSettings;
431     private final UnaryCallSettings.Builder<DeleteUrlMapRequest, Operation> deleteSettings;
432     private final OperationCallSettings.Builder<DeleteUrlMapRequest, Operation, Operation>
433         deleteOperationSettings;
434     private final UnaryCallSettings.Builder<GetUrlMapRequest, UrlMap> getSettings;
435     private final UnaryCallSettings.Builder<InsertUrlMapRequest, Operation> insertSettings;
436     private final OperationCallSettings.Builder<InsertUrlMapRequest, Operation, Operation>
437         insertOperationSettings;
438     private final UnaryCallSettings.Builder<InvalidateCacheUrlMapRequest, Operation>
439         invalidateCacheSettings;
440     private final OperationCallSettings.Builder<InvalidateCacheUrlMapRequest, Operation, Operation>
441         invalidateCacheOperationSettings;
442     private final PagedCallSettings.Builder<ListUrlMapsRequest, UrlMapList, ListPagedResponse>
443         listSettings;
444     private final UnaryCallSettings.Builder<PatchUrlMapRequest, Operation> patchSettings;
445     private final OperationCallSettings.Builder<PatchUrlMapRequest, Operation, Operation>
446         patchOperationSettings;
447     private final UnaryCallSettings.Builder<UpdateUrlMapRequest, Operation> updateSettings;
448     private final OperationCallSettings.Builder<UpdateUrlMapRequest, Operation, Operation>
449         updateOperationSettings;
450     private final UnaryCallSettings.Builder<ValidateUrlMapRequest, UrlMapsValidateResponse>
451         validateSettings;
452     private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
453         RETRYABLE_CODE_DEFINITIONS;
454 
455     static {
456       ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
457           ImmutableMap.builder();
458       definitions.put(
459           "retry_policy_0_codes",
460           ImmutableSet.copyOf(
461               Lists.<StatusCode.Code>newArrayList(
462                   StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
463       definitions.put(
464           "no_retry_1_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
465       RETRYABLE_CODE_DEFINITIONS = definitions.build();
466     }
467 
468     private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
469 
470     static {
471       ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
472       RetrySettings settings = null;
473       settings =
474           RetrySettings.newBuilder()
475               .setInitialRetryDelay(Duration.ofMillis(100L))
476               .setRetryDelayMultiplier(1.3)
477               .setMaxRetryDelay(Duration.ofMillis(60000L))
478               .setInitialRpcTimeout(Duration.ofMillis(600000L))
479               .setRpcTimeoutMultiplier(1.0)
480               .setMaxRpcTimeout(Duration.ofMillis(600000L))
481               .setTotalTimeout(Duration.ofMillis(600000L))
482               .build();
483       definitions.put("retry_policy_0_params", settings);
484       settings =
485           RetrySettings.newBuilder()
486               .setInitialRpcTimeout(Duration.ofMillis(600000L))
487               .setRpcTimeoutMultiplier(1.0)
488               .setMaxRpcTimeout(Duration.ofMillis(600000L))
489               .setTotalTimeout(Duration.ofMillis(600000L))
490               .build();
491       definitions.put("no_retry_1_params", settings);
492       RETRY_PARAM_DEFINITIONS = definitions.build();
493     }
494 
Builder()495     protected Builder() {
496       this(((ClientContext) null));
497     }
498 
Builder(ClientContext clientContext)499     protected Builder(ClientContext clientContext) {
500       super(clientContext);
501 
502       aggregatedListSettings = PagedCallSettings.newBuilder(AGGREGATED_LIST_PAGE_STR_FACT);
503       deleteSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
504       deleteOperationSettings = OperationCallSettings.newBuilder();
505       getSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
506       insertSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
507       insertOperationSettings = OperationCallSettings.newBuilder();
508       invalidateCacheSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
509       invalidateCacheOperationSettings = OperationCallSettings.newBuilder();
510       listSettings = PagedCallSettings.newBuilder(LIST_PAGE_STR_FACT);
511       patchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
512       patchOperationSettings = OperationCallSettings.newBuilder();
513       updateSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
514       updateOperationSettings = OperationCallSettings.newBuilder();
515       validateSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
516 
517       unaryMethodSettingsBuilders =
518           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
519               aggregatedListSettings,
520               deleteSettings,
521               getSettings,
522               insertSettings,
523               invalidateCacheSettings,
524               listSettings,
525               patchSettings,
526               updateSettings,
527               validateSettings);
528       initDefaults(this);
529     }
530 
Builder(UrlMapsStubSettings settings)531     protected Builder(UrlMapsStubSettings settings) {
532       super(settings);
533 
534       aggregatedListSettings = settings.aggregatedListSettings.toBuilder();
535       deleteSettings = settings.deleteSettings.toBuilder();
536       deleteOperationSettings = settings.deleteOperationSettings.toBuilder();
537       getSettings = settings.getSettings.toBuilder();
538       insertSettings = settings.insertSettings.toBuilder();
539       insertOperationSettings = settings.insertOperationSettings.toBuilder();
540       invalidateCacheSettings = settings.invalidateCacheSettings.toBuilder();
541       invalidateCacheOperationSettings = settings.invalidateCacheOperationSettings.toBuilder();
542       listSettings = settings.listSettings.toBuilder();
543       patchSettings = settings.patchSettings.toBuilder();
544       patchOperationSettings = settings.patchOperationSettings.toBuilder();
545       updateSettings = settings.updateSettings.toBuilder();
546       updateOperationSettings = settings.updateOperationSettings.toBuilder();
547       validateSettings = settings.validateSettings.toBuilder();
548 
549       unaryMethodSettingsBuilders =
550           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
551               aggregatedListSettings,
552               deleteSettings,
553               getSettings,
554               insertSettings,
555               invalidateCacheSettings,
556               listSettings,
557               patchSettings,
558               updateSettings,
559               validateSettings);
560     }
561 
createDefault()562     private static Builder createDefault() {
563       Builder builder = new Builder(((ClientContext) null));
564 
565       builder.setTransportChannelProvider(defaultTransportChannelProvider());
566       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
567       builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
568       builder.setEndpoint(getDefaultEndpoint());
569       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
570       builder.setSwitchToMtlsEndpointAllowed(true);
571 
572       return initDefaults(builder);
573     }
574 
initDefaults(Builder builder)575     private static Builder initDefaults(Builder builder) {
576       builder
577           .aggregatedListSettings()
578           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
579           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
580 
581       builder
582           .deleteSettings()
583           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
584           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
585 
586       builder
587           .getSettings()
588           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
589           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
590 
591       builder
592           .insertSettings()
593           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
594           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
595 
596       builder
597           .invalidateCacheSettings()
598           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
599           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
600 
601       builder
602           .listSettings()
603           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
604           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
605 
606       builder
607           .patchSettings()
608           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
609           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
610 
611       builder
612           .updateSettings()
613           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
614           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
615 
616       builder
617           .validateSettings()
618           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
619           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
620 
621       builder
622           .deleteOperationSettings()
623           .setInitialCallSettings(
624               UnaryCallSettings
625                   .<DeleteUrlMapRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
626                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
627                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
628                   .build())
629           .setResponseTransformer(
630               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
631           .setMetadataTransformer(
632               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
633           .setPollingAlgorithm(
634               OperationTimedPollAlgorithm.create(
635                   RetrySettings.newBuilder()
636                       .setInitialRetryDelay(Duration.ofMillis(500L))
637                       .setRetryDelayMultiplier(1.5)
638                       .setMaxRetryDelay(Duration.ofMillis(20000L))
639                       .setInitialRpcTimeout(Duration.ZERO)
640                       .setRpcTimeoutMultiplier(1.0)
641                       .setMaxRpcTimeout(Duration.ZERO)
642                       .setTotalTimeout(Duration.ofMillis(600000L))
643                       .build()));
644 
645       builder
646           .insertOperationSettings()
647           .setInitialCallSettings(
648               UnaryCallSettings
649                   .<InsertUrlMapRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
650                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
651                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
652                   .build())
653           .setResponseTransformer(
654               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
655           .setMetadataTransformer(
656               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
657           .setPollingAlgorithm(
658               OperationTimedPollAlgorithm.create(
659                   RetrySettings.newBuilder()
660                       .setInitialRetryDelay(Duration.ofMillis(500L))
661                       .setRetryDelayMultiplier(1.5)
662                       .setMaxRetryDelay(Duration.ofMillis(20000L))
663                       .setInitialRpcTimeout(Duration.ZERO)
664                       .setRpcTimeoutMultiplier(1.0)
665                       .setMaxRpcTimeout(Duration.ZERO)
666                       .setTotalTimeout(Duration.ofMillis(600000L))
667                       .build()));
668 
669       builder
670           .invalidateCacheOperationSettings()
671           .setInitialCallSettings(
672               UnaryCallSettings
673                   .<InvalidateCacheUrlMapRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
674                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
675                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
676                   .build())
677           .setResponseTransformer(
678               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
679           .setMetadataTransformer(
680               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
681           .setPollingAlgorithm(
682               OperationTimedPollAlgorithm.create(
683                   RetrySettings.newBuilder()
684                       .setInitialRetryDelay(Duration.ofMillis(500L))
685                       .setRetryDelayMultiplier(1.5)
686                       .setMaxRetryDelay(Duration.ofMillis(20000L))
687                       .setInitialRpcTimeout(Duration.ZERO)
688                       .setRpcTimeoutMultiplier(1.0)
689                       .setMaxRpcTimeout(Duration.ZERO)
690                       .setTotalTimeout(Duration.ofMillis(600000L))
691                       .build()));
692 
693       builder
694           .patchOperationSettings()
695           .setInitialCallSettings(
696               UnaryCallSettings.<PatchUrlMapRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
697                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
698                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
699                   .build())
700           .setResponseTransformer(
701               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
702           .setMetadataTransformer(
703               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
704           .setPollingAlgorithm(
705               OperationTimedPollAlgorithm.create(
706                   RetrySettings.newBuilder()
707                       .setInitialRetryDelay(Duration.ofMillis(500L))
708                       .setRetryDelayMultiplier(1.5)
709                       .setMaxRetryDelay(Duration.ofMillis(20000L))
710                       .setInitialRpcTimeout(Duration.ZERO)
711                       .setRpcTimeoutMultiplier(1.0)
712                       .setMaxRpcTimeout(Duration.ZERO)
713                       .setTotalTimeout(Duration.ofMillis(600000L))
714                       .build()));
715 
716       builder
717           .updateOperationSettings()
718           .setInitialCallSettings(
719               UnaryCallSettings
720                   .<UpdateUrlMapRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
721                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
722                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
723                   .build())
724           .setResponseTransformer(
725               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
726           .setMetadataTransformer(
727               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
728           .setPollingAlgorithm(
729               OperationTimedPollAlgorithm.create(
730                   RetrySettings.newBuilder()
731                       .setInitialRetryDelay(Duration.ofMillis(500L))
732                       .setRetryDelayMultiplier(1.5)
733                       .setMaxRetryDelay(Duration.ofMillis(20000L))
734                       .setInitialRpcTimeout(Duration.ZERO)
735                       .setRpcTimeoutMultiplier(1.0)
736                       .setMaxRpcTimeout(Duration.ZERO)
737                       .setTotalTimeout(Duration.ofMillis(600000L))
738                       .build()));
739 
740       return builder;
741     }
742 
743     /**
744      * Applies the given settings updater function to all of the unary API methods in this service.
745      *
746      * <p>Note: This method does not support applying settings to streaming methods.
747      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)748     public Builder applyToAllUnaryMethods(
749         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
750       super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
751       return this;
752     }
753 
unaryMethodSettingsBuilders()754     public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
755       return unaryMethodSettingsBuilders;
756     }
757 
758     /** Returns the builder for the settings used for calls to aggregatedList. */
759     public PagedCallSettings.Builder<
760             AggregatedListUrlMapsRequest, UrlMapsAggregatedList, AggregatedListPagedResponse>
aggregatedListSettings()761         aggregatedListSettings() {
762       return aggregatedListSettings;
763     }
764 
765     /** Returns the builder for the settings used for calls to delete. */
deleteSettings()766     public UnaryCallSettings.Builder<DeleteUrlMapRequest, Operation> deleteSettings() {
767       return deleteSettings;
768     }
769 
770     /** Returns the builder for the settings used for calls to delete. */
771     @BetaApi(
772         "The surface for use by generated code is not stable yet and may change in the future.")
773     public OperationCallSettings.Builder<DeleteUrlMapRequest, Operation, Operation>
deleteOperationSettings()774         deleteOperationSettings() {
775       return deleteOperationSettings;
776     }
777 
778     /** Returns the builder for the settings used for calls to get. */
getSettings()779     public UnaryCallSettings.Builder<GetUrlMapRequest, UrlMap> getSettings() {
780       return getSettings;
781     }
782 
783     /** Returns the builder for the settings used for calls to insert. */
insertSettings()784     public UnaryCallSettings.Builder<InsertUrlMapRequest, Operation> insertSettings() {
785       return insertSettings;
786     }
787 
788     /** Returns the builder for the settings used for calls to insert. */
789     @BetaApi(
790         "The surface for use by generated code is not stable yet and may change in the future.")
791     public OperationCallSettings.Builder<InsertUrlMapRequest, Operation, Operation>
insertOperationSettings()792         insertOperationSettings() {
793       return insertOperationSettings;
794     }
795 
796     /** Returns the builder for the settings used for calls to invalidateCache. */
797     public UnaryCallSettings.Builder<InvalidateCacheUrlMapRequest, Operation>
invalidateCacheSettings()798         invalidateCacheSettings() {
799       return invalidateCacheSettings;
800     }
801 
802     /** Returns the builder for the settings used for calls to invalidateCache. */
803     @BetaApi(
804         "The surface for use by generated code is not stable yet and may change in the future.")
805     public OperationCallSettings.Builder<InvalidateCacheUrlMapRequest, Operation, Operation>
invalidateCacheOperationSettings()806         invalidateCacheOperationSettings() {
807       return invalidateCacheOperationSettings;
808     }
809 
810     /** Returns the builder for the settings used for calls to list. */
811     public PagedCallSettings.Builder<ListUrlMapsRequest, UrlMapList, ListPagedResponse>
listSettings()812         listSettings() {
813       return listSettings;
814     }
815 
816     /** Returns the builder for the settings used for calls to patch. */
patchSettings()817     public UnaryCallSettings.Builder<PatchUrlMapRequest, Operation> patchSettings() {
818       return patchSettings;
819     }
820 
821     /** Returns the builder for the settings used for calls to patch. */
822     @BetaApi(
823         "The surface for use by generated code is not stable yet and may change in the future.")
824     public OperationCallSettings.Builder<PatchUrlMapRequest, Operation, Operation>
patchOperationSettings()825         patchOperationSettings() {
826       return patchOperationSettings;
827     }
828 
829     /** Returns the builder for the settings used for calls to update. */
updateSettings()830     public UnaryCallSettings.Builder<UpdateUrlMapRequest, Operation> updateSettings() {
831       return updateSettings;
832     }
833 
834     /** Returns the builder for the settings used for calls to update. */
835     @BetaApi(
836         "The surface for use by generated code is not stable yet and may change in the future.")
837     public OperationCallSettings.Builder<UpdateUrlMapRequest, Operation, Operation>
updateOperationSettings()838         updateOperationSettings() {
839       return updateOperationSettings;
840     }
841 
842     /** Returns the builder for the settings used for calls to validate. */
843     public UnaryCallSettings.Builder<ValidateUrlMapRequest, UrlMapsValidateResponse>
validateSettings()844         validateSettings() {
845       return validateSettings;
846     }
847 
848     @Override
build()849     public UrlMapsStubSettings build() throws IOException {
850       return new UrlMapsStubSettings(this);
851     }
852   }
853 }
854