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