• 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.SnapshotsClient.ListPagedResponse;
20 
21 import com.google.api.core.ApiFunction;
22 import com.google.api.core.ApiFuture;
23 import com.google.api.core.BetaApi;
24 import com.google.api.gax.core.GaxProperties;
25 import com.google.api.gax.core.GoogleCredentialsProvider;
26 import com.google.api.gax.core.InstantiatingExecutorProvider;
27 import com.google.api.gax.httpjson.GaxHttpJsonProperties;
28 import com.google.api.gax.httpjson.HttpJsonTransportChannel;
29 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
30 import com.google.api.gax.httpjson.ProtoOperationTransformers;
31 import com.google.api.gax.longrunning.OperationSnapshot;
32 import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
33 import com.google.api.gax.retrying.RetrySettings;
34 import com.google.api.gax.rpc.ApiCallContext;
35 import com.google.api.gax.rpc.ApiClientHeaderProvider;
36 import com.google.api.gax.rpc.ClientContext;
37 import com.google.api.gax.rpc.OperationCallSettings;
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.compute.v1.DeleteSnapshotRequest;
48 import com.google.cloud.compute.v1.GetIamPolicySnapshotRequest;
49 import com.google.cloud.compute.v1.GetSnapshotRequest;
50 import com.google.cloud.compute.v1.InsertSnapshotRequest;
51 import com.google.cloud.compute.v1.ListSnapshotsRequest;
52 import com.google.cloud.compute.v1.Operation;
53 import com.google.cloud.compute.v1.Policy;
54 import com.google.cloud.compute.v1.SetIamPolicySnapshotRequest;
55 import com.google.cloud.compute.v1.SetLabelsSnapshotRequest;
56 import com.google.cloud.compute.v1.Snapshot;
57 import com.google.cloud.compute.v1.SnapshotList;
58 import com.google.cloud.compute.v1.TestIamPermissionsSnapshotRequest;
59 import com.google.cloud.compute.v1.TestPermissionsResponse;
60 import com.google.common.collect.ImmutableList;
61 import com.google.common.collect.ImmutableMap;
62 import com.google.common.collect.ImmutableSet;
63 import com.google.common.collect.Lists;
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 SnapshotsStub}.
72  *
73  * <p>The default instance has everything set to sensible defaults:
74  *
75  * <ul>
76  *   <li>The default service address (compute.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 get 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  * SnapshotsStubSettings.Builder snapshotsSettingsBuilder = SnapshotsStubSettings.newBuilder();
93  * snapshotsSettingsBuilder
94  *     .getSettings()
95  *     .setRetrySettings(
96  *         snapshotsSettingsBuilder
97  *             .getSettings()
98  *             .getRetrySettings()
99  *             .toBuilder()
100  *             .setTotalTimeout(Duration.ofSeconds(30))
101  *             .build());
102  * SnapshotsStubSettings snapshotsSettings = snapshotsSettingsBuilder.build();
103  * }</pre>
104  */
105 @Generated("by gapic-generator-java")
106 public class SnapshotsStubSettings extends StubSettings<SnapshotsStubSettings> {
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/compute")
111           .add("https://www.googleapis.com/auth/cloud-platform")
112           .build();
113 
114   private final UnaryCallSettings<DeleteSnapshotRequest, Operation> deleteSettings;
115   private final OperationCallSettings<DeleteSnapshotRequest, Operation, Operation>
116       deleteOperationSettings;
117   private final UnaryCallSettings<GetSnapshotRequest, Snapshot> getSettings;
118   private final UnaryCallSettings<GetIamPolicySnapshotRequest, Policy> getIamPolicySettings;
119   private final UnaryCallSettings<InsertSnapshotRequest, Operation> insertSettings;
120   private final OperationCallSettings<InsertSnapshotRequest, Operation, Operation>
121       insertOperationSettings;
122   private final PagedCallSettings<ListSnapshotsRequest, SnapshotList, ListPagedResponse>
123       listSettings;
124   private final UnaryCallSettings<SetIamPolicySnapshotRequest, Policy> setIamPolicySettings;
125   private final UnaryCallSettings<SetLabelsSnapshotRequest, Operation> setLabelsSettings;
126   private final OperationCallSettings<SetLabelsSnapshotRequest, Operation, Operation>
127       setLabelsOperationSettings;
128   private final UnaryCallSettings<TestIamPermissionsSnapshotRequest, TestPermissionsResponse>
129       testIamPermissionsSettings;
130 
131   private static final PagedListDescriptor<ListSnapshotsRequest, SnapshotList, Snapshot>
132       LIST_PAGE_STR_DESC =
133           new PagedListDescriptor<ListSnapshotsRequest, SnapshotList, Snapshot>() {
134             @Override
135             public String emptyToken() {
136               return "";
137             }
138 
139             @Override
140             public ListSnapshotsRequest injectToken(ListSnapshotsRequest payload, String token) {
141               return ListSnapshotsRequest.newBuilder(payload).setPageToken(token).build();
142             }
143 
144             @Override
145             public ListSnapshotsRequest injectPageSize(ListSnapshotsRequest payload, int pageSize) {
146               return ListSnapshotsRequest.newBuilder(payload).setMaxResults(pageSize).build();
147             }
148 
149             @Override
150             public Integer extractPageSize(ListSnapshotsRequest payload) {
151               return payload.getMaxResults();
152             }
153 
154             @Override
155             public String extractNextToken(SnapshotList payload) {
156               return payload.getNextPageToken();
157             }
158 
159             @Override
160             public Iterable<Snapshot> extractResources(SnapshotList payload) {
161               return payload.getItemsList() == null
162                   ? ImmutableList.<Snapshot>of()
163                   : payload.getItemsList();
164             }
165           };
166 
167   private static final PagedListResponseFactory<
168           ListSnapshotsRequest, SnapshotList, ListPagedResponse>
169       LIST_PAGE_STR_FACT =
170           new PagedListResponseFactory<ListSnapshotsRequest, SnapshotList, ListPagedResponse>() {
171             @Override
172             public ApiFuture<ListPagedResponse> getFuturePagedResponse(
173                 UnaryCallable<ListSnapshotsRequest, SnapshotList> callable,
174                 ListSnapshotsRequest request,
175                 ApiCallContext context,
176                 ApiFuture<SnapshotList> futureResponse) {
177               PageContext<ListSnapshotsRequest, SnapshotList, Snapshot> pageContext =
178                   PageContext.create(callable, LIST_PAGE_STR_DESC, request, context);
179               return ListPagedResponse.createAsync(pageContext, futureResponse);
180             }
181           };
182 
183   /** Returns the object with the settings used for calls to delete. */
deleteSettings()184   public UnaryCallSettings<DeleteSnapshotRequest, Operation> deleteSettings() {
185     return deleteSettings;
186   }
187 
188   /** Returns the object with the settings used for calls to delete. */
189   public OperationCallSettings<DeleteSnapshotRequest, Operation, Operation>
deleteOperationSettings()190       deleteOperationSettings() {
191     return deleteOperationSettings;
192   }
193 
194   /** Returns the object with the settings used for calls to get. */
getSettings()195   public UnaryCallSettings<GetSnapshotRequest, Snapshot> getSettings() {
196     return getSettings;
197   }
198 
199   /** Returns the object with the settings used for calls to getIamPolicy. */
getIamPolicySettings()200   public UnaryCallSettings<GetIamPolicySnapshotRequest, Policy> getIamPolicySettings() {
201     return getIamPolicySettings;
202   }
203 
204   /** Returns the object with the settings used for calls to insert. */
insertSettings()205   public UnaryCallSettings<InsertSnapshotRequest, Operation> insertSettings() {
206     return insertSettings;
207   }
208 
209   /** Returns the object with the settings used for calls to insert. */
210   public OperationCallSettings<InsertSnapshotRequest, Operation, Operation>
insertOperationSettings()211       insertOperationSettings() {
212     return insertOperationSettings;
213   }
214 
215   /** Returns the object with the settings used for calls to list. */
listSettings()216   public PagedCallSettings<ListSnapshotsRequest, SnapshotList, ListPagedResponse> listSettings() {
217     return listSettings;
218   }
219 
220   /** Returns the object with the settings used for calls to setIamPolicy. */
setIamPolicySettings()221   public UnaryCallSettings<SetIamPolicySnapshotRequest, Policy> setIamPolicySettings() {
222     return setIamPolicySettings;
223   }
224 
225   /** Returns the object with the settings used for calls to setLabels. */
setLabelsSettings()226   public UnaryCallSettings<SetLabelsSnapshotRequest, Operation> setLabelsSettings() {
227     return setLabelsSettings;
228   }
229 
230   /** Returns the object with the settings used for calls to setLabels. */
231   public OperationCallSettings<SetLabelsSnapshotRequest, Operation, Operation>
setLabelsOperationSettings()232       setLabelsOperationSettings() {
233     return setLabelsOperationSettings;
234   }
235 
236   /** Returns the object with the settings used for calls to testIamPermissions. */
237   public UnaryCallSettings<TestIamPermissionsSnapshotRequest, TestPermissionsResponse>
testIamPermissionsSettings()238       testIamPermissionsSettings() {
239     return testIamPermissionsSettings;
240   }
241 
createStub()242   public SnapshotsStub createStub() throws IOException {
243     if (getTransportChannelProvider()
244         .getTransportName()
245         .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
246       return HttpJsonSnapshotsStub.create(this);
247     }
248     throw new UnsupportedOperationException(
249         String.format(
250             "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
251   }
252 
253   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()254   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
255     return InstantiatingExecutorProvider.newBuilder();
256   }
257 
258   /** Returns the default service endpoint. */
getDefaultEndpoint()259   public static String getDefaultEndpoint() {
260     return "compute.googleapis.com:443";
261   }
262 
263   /** Returns the default mTLS service endpoint. */
getDefaultMtlsEndpoint()264   public static String getDefaultMtlsEndpoint() {
265     return "compute.mtls.googleapis.com:443";
266   }
267 
268   /** Returns the default service scopes. */
getDefaultServiceScopes()269   public static List<String> getDefaultServiceScopes() {
270     return DEFAULT_SERVICE_SCOPES;
271   }
272 
273   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()274   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
275     return GoogleCredentialsProvider.newBuilder()
276         .setScopesToApply(DEFAULT_SERVICE_SCOPES)
277         .setUseJwtAccessWithScope(true);
278   }
279 
280   /** Returns a builder for the default ChannelProvider for this service. */
281   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()282       defaultHttpJsonTransportProviderBuilder() {
283     return InstantiatingHttpJsonChannelProvider.newBuilder();
284   }
285 
defaultTransportChannelProvider()286   public static TransportChannelProvider defaultTransportChannelProvider() {
287     return defaultHttpJsonTransportProviderBuilder().build();
288   }
289 
290   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()291   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
292     return ApiClientHeaderProvider.newBuilder()
293         .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SnapshotsStubSettings.class))
294         .setTransportToken(
295             GaxHttpJsonProperties.getHttpJsonTokenName(),
296             GaxHttpJsonProperties.getHttpJsonVersion());
297   }
298 
299   /** Returns a new builder for this class. */
newBuilder()300   public static Builder newBuilder() {
301     return Builder.createDefault();
302   }
303 
304   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)305   public static Builder newBuilder(ClientContext clientContext) {
306     return new Builder(clientContext);
307   }
308 
309   /** Returns a builder containing all the values of this settings class. */
toBuilder()310   public Builder toBuilder() {
311     return new Builder(this);
312   }
313 
SnapshotsStubSettings(Builder settingsBuilder)314   protected SnapshotsStubSettings(Builder settingsBuilder) throws IOException {
315     super(settingsBuilder);
316 
317     deleteSettings = settingsBuilder.deleteSettings().build();
318     deleteOperationSettings = settingsBuilder.deleteOperationSettings().build();
319     getSettings = settingsBuilder.getSettings().build();
320     getIamPolicySettings = settingsBuilder.getIamPolicySettings().build();
321     insertSettings = settingsBuilder.insertSettings().build();
322     insertOperationSettings = settingsBuilder.insertOperationSettings().build();
323     listSettings = settingsBuilder.listSettings().build();
324     setIamPolicySettings = settingsBuilder.setIamPolicySettings().build();
325     setLabelsSettings = settingsBuilder.setLabelsSettings().build();
326     setLabelsOperationSettings = settingsBuilder.setLabelsOperationSettings().build();
327     testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build();
328   }
329 
330   /** Builder for SnapshotsStubSettings. */
331   public static class Builder extends StubSettings.Builder<SnapshotsStubSettings, Builder> {
332     private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
333     private final UnaryCallSettings.Builder<DeleteSnapshotRequest, Operation> deleteSettings;
334     private final OperationCallSettings.Builder<DeleteSnapshotRequest, Operation, Operation>
335         deleteOperationSettings;
336     private final UnaryCallSettings.Builder<GetSnapshotRequest, Snapshot> getSettings;
337     private final UnaryCallSettings.Builder<GetIamPolicySnapshotRequest, Policy>
338         getIamPolicySettings;
339     private final UnaryCallSettings.Builder<InsertSnapshotRequest, Operation> insertSettings;
340     private final OperationCallSettings.Builder<InsertSnapshotRequest, Operation, Operation>
341         insertOperationSettings;
342     private final PagedCallSettings.Builder<ListSnapshotsRequest, SnapshotList, ListPagedResponse>
343         listSettings;
344     private final UnaryCallSettings.Builder<SetIamPolicySnapshotRequest, Policy>
345         setIamPolicySettings;
346     private final UnaryCallSettings.Builder<SetLabelsSnapshotRequest, Operation> setLabelsSettings;
347     private final OperationCallSettings.Builder<SetLabelsSnapshotRequest, Operation, Operation>
348         setLabelsOperationSettings;
349     private final UnaryCallSettings.Builder<
350             TestIamPermissionsSnapshotRequest, TestPermissionsResponse>
351         testIamPermissionsSettings;
352     private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
353         RETRYABLE_CODE_DEFINITIONS;
354 
355     static {
356       ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
357           ImmutableMap.builder();
358       definitions.put(
359           "no_retry_1_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
360       definitions.put(
361           "retry_policy_0_codes",
362           ImmutableSet.copyOf(
363               Lists.<StatusCode.Code>newArrayList(
364                   StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
365       RETRYABLE_CODE_DEFINITIONS = definitions.build();
366     }
367 
368     private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
369 
370     static {
371       ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
372       RetrySettings settings = null;
373       settings =
374           RetrySettings.newBuilder()
375               .setInitialRpcTimeout(Duration.ofMillis(600000L))
376               .setRpcTimeoutMultiplier(1.0)
377               .setMaxRpcTimeout(Duration.ofMillis(600000L))
378               .setTotalTimeout(Duration.ofMillis(600000L))
379               .build();
380       definitions.put("no_retry_1_params", settings);
381       settings =
382           RetrySettings.newBuilder()
383               .setInitialRetryDelay(Duration.ofMillis(100L))
384               .setRetryDelayMultiplier(1.3)
385               .setMaxRetryDelay(Duration.ofMillis(60000L))
386               .setInitialRpcTimeout(Duration.ofMillis(600000L))
387               .setRpcTimeoutMultiplier(1.0)
388               .setMaxRpcTimeout(Duration.ofMillis(600000L))
389               .setTotalTimeout(Duration.ofMillis(600000L))
390               .build();
391       definitions.put("retry_policy_0_params", settings);
392       RETRY_PARAM_DEFINITIONS = definitions.build();
393     }
394 
Builder()395     protected Builder() {
396       this(((ClientContext) null));
397     }
398 
Builder(ClientContext clientContext)399     protected Builder(ClientContext clientContext) {
400       super(clientContext);
401 
402       deleteSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
403       deleteOperationSettings = OperationCallSettings.newBuilder();
404       getSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
405       getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
406       insertSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
407       insertOperationSettings = OperationCallSettings.newBuilder();
408       listSettings = PagedCallSettings.newBuilder(LIST_PAGE_STR_FACT);
409       setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
410       setLabelsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
411       setLabelsOperationSettings = OperationCallSettings.newBuilder();
412       testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
413 
414       unaryMethodSettingsBuilders =
415           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
416               deleteSettings,
417               getSettings,
418               getIamPolicySettings,
419               insertSettings,
420               listSettings,
421               setIamPolicySettings,
422               setLabelsSettings,
423               testIamPermissionsSettings);
424       initDefaults(this);
425     }
426 
Builder(SnapshotsStubSettings settings)427     protected Builder(SnapshotsStubSettings settings) {
428       super(settings);
429 
430       deleteSettings = settings.deleteSettings.toBuilder();
431       deleteOperationSettings = settings.deleteOperationSettings.toBuilder();
432       getSettings = settings.getSettings.toBuilder();
433       getIamPolicySettings = settings.getIamPolicySettings.toBuilder();
434       insertSettings = settings.insertSettings.toBuilder();
435       insertOperationSettings = settings.insertOperationSettings.toBuilder();
436       listSettings = settings.listSettings.toBuilder();
437       setIamPolicySettings = settings.setIamPolicySettings.toBuilder();
438       setLabelsSettings = settings.setLabelsSettings.toBuilder();
439       setLabelsOperationSettings = settings.setLabelsOperationSettings.toBuilder();
440       testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder();
441 
442       unaryMethodSettingsBuilders =
443           ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
444               deleteSettings,
445               getSettings,
446               getIamPolicySettings,
447               insertSettings,
448               listSettings,
449               setIamPolicySettings,
450               setLabelsSettings,
451               testIamPermissionsSettings);
452     }
453 
createDefault()454     private static Builder createDefault() {
455       Builder builder = new Builder(((ClientContext) null));
456 
457       builder.setTransportChannelProvider(defaultTransportChannelProvider());
458       builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
459       builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
460       builder.setEndpoint(getDefaultEndpoint());
461       builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
462       builder.setSwitchToMtlsEndpointAllowed(true);
463 
464       return initDefaults(builder);
465     }
466 
initDefaults(Builder builder)467     private static Builder initDefaults(Builder builder) {
468       builder
469           .deleteSettings()
470           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
471           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
472 
473       builder
474           .getSettings()
475           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
476           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
477 
478       builder
479           .getIamPolicySettings()
480           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
481           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
482 
483       builder
484           .insertSettings()
485           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
486           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
487 
488       builder
489           .listSettings()
490           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
491           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
492 
493       builder
494           .setIamPolicySettings()
495           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
496           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
497 
498       builder
499           .setLabelsSettings()
500           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
501           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
502 
503       builder
504           .testIamPermissionsSettings()
505           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
506           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
507 
508       builder
509           .deleteOperationSettings()
510           .setInitialCallSettings(
511               UnaryCallSettings
512                   .<DeleteSnapshotRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
513                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
514                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
515                   .build())
516           .setResponseTransformer(
517               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
518           .setMetadataTransformer(
519               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
520           .setPollingAlgorithm(
521               OperationTimedPollAlgorithm.create(
522                   RetrySettings.newBuilder()
523                       .setInitialRetryDelay(Duration.ofMillis(500L))
524                       .setRetryDelayMultiplier(1.5)
525                       .setMaxRetryDelay(Duration.ofMillis(20000L))
526                       .setInitialRpcTimeout(Duration.ZERO)
527                       .setRpcTimeoutMultiplier(1.0)
528                       .setMaxRpcTimeout(Duration.ZERO)
529                       .setTotalTimeout(Duration.ofMillis(600000L))
530                       .build()));
531 
532       builder
533           .insertOperationSettings()
534           .setInitialCallSettings(
535               UnaryCallSettings
536                   .<InsertSnapshotRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
537                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
538                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
539                   .build())
540           .setResponseTransformer(
541               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
542           .setMetadataTransformer(
543               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
544           .setPollingAlgorithm(
545               OperationTimedPollAlgorithm.create(
546                   RetrySettings.newBuilder()
547                       .setInitialRetryDelay(Duration.ofMillis(500L))
548                       .setRetryDelayMultiplier(1.5)
549                       .setMaxRetryDelay(Duration.ofMillis(20000L))
550                       .setInitialRpcTimeout(Duration.ZERO)
551                       .setRpcTimeoutMultiplier(1.0)
552                       .setMaxRpcTimeout(Duration.ZERO)
553                       .setTotalTimeout(Duration.ofMillis(600000L))
554                       .build()));
555 
556       builder
557           .setLabelsOperationSettings()
558           .setInitialCallSettings(
559               UnaryCallSettings
560                   .<SetLabelsSnapshotRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
561                   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
562                   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
563                   .build())
564           .setResponseTransformer(
565               ProtoOperationTransformers.ResponseTransformer.create(Operation.class))
566           .setMetadataTransformer(
567               ProtoOperationTransformers.MetadataTransformer.create(Operation.class))
568           .setPollingAlgorithm(
569               OperationTimedPollAlgorithm.create(
570                   RetrySettings.newBuilder()
571                       .setInitialRetryDelay(Duration.ofMillis(500L))
572                       .setRetryDelayMultiplier(1.5)
573                       .setMaxRetryDelay(Duration.ofMillis(20000L))
574                       .setInitialRpcTimeout(Duration.ZERO)
575                       .setRpcTimeoutMultiplier(1.0)
576                       .setMaxRpcTimeout(Duration.ZERO)
577                       .setTotalTimeout(Duration.ofMillis(600000L))
578                       .build()));
579 
580       return builder;
581     }
582 
583     /**
584      * Applies the given settings updater function to all of the unary API methods in this service.
585      *
586      * <p>Note: This method does not support applying settings to streaming methods.
587      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)588     public Builder applyToAllUnaryMethods(
589         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
590       super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
591       return this;
592     }
593 
unaryMethodSettingsBuilders()594     public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
595       return unaryMethodSettingsBuilders;
596     }
597 
598     /** Returns the builder for the settings used for calls to delete. */
deleteSettings()599     public UnaryCallSettings.Builder<DeleteSnapshotRequest, Operation> deleteSettings() {
600       return deleteSettings;
601     }
602 
603     /** Returns the builder for the settings used for calls to delete. */
604     @BetaApi(
605         "The surface for use by generated code is not stable yet and may change in the future.")
606     public OperationCallSettings.Builder<DeleteSnapshotRequest, Operation, Operation>
deleteOperationSettings()607         deleteOperationSettings() {
608       return deleteOperationSettings;
609     }
610 
611     /** Returns the builder for the settings used for calls to get. */
getSettings()612     public UnaryCallSettings.Builder<GetSnapshotRequest, Snapshot> getSettings() {
613       return getSettings;
614     }
615 
616     /** Returns the builder for the settings used for calls to getIamPolicy. */
getIamPolicySettings()617     public UnaryCallSettings.Builder<GetIamPolicySnapshotRequest, Policy> getIamPolicySettings() {
618       return getIamPolicySettings;
619     }
620 
621     /** Returns the builder for the settings used for calls to insert. */
insertSettings()622     public UnaryCallSettings.Builder<InsertSnapshotRequest, Operation> insertSettings() {
623       return insertSettings;
624     }
625 
626     /** Returns the builder for the settings used for calls to insert. */
627     @BetaApi(
628         "The surface for use by generated code is not stable yet and may change in the future.")
629     public OperationCallSettings.Builder<InsertSnapshotRequest, Operation, Operation>
insertOperationSettings()630         insertOperationSettings() {
631       return insertOperationSettings;
632     }
633 
634     /** Returns the builder for the settings used for calls to list. */
635     public PagedCallSettings.Builder<ListSnapshotsRequest, SnapshotList, ListPagedResponse>
listSettings()636         listSettings() {
637       return listSettings;
638     }
639 
640     /** Returns the builder for the settings used for calls to setIamPolicy. */
setIamPolicySettings()641     public UnaryCallSettings.Builder<SetIamPolicySnapshotRequest, Policy> setIamPolicySettings() {
642       return setIamPolicySettings;
643     }
644 
645     /** Returns the builder for the settings used for calls to setLabels. */
setLabelsSettings()646     public UnaryCallSettings.Builder<SetLabelsSnapshotRequest, Operation> setLabelsSettings() {
647       return setLabelsSettings;
648     }
649 
650     /** Returns the builder for the settings used for calls to setLabels. */
651     @BetaApi(
652         "The surface for use by generated code is not stable yet and may change in the future.")
653     public OperationCallSettings.Builder<SetLabelsSnapshotRequest, Operation, Operation>
setLabelsOperationSettings()654         setLabelsOperationSettings() {
655       return setLabelsOperationSettings;
656     }
657 
658     /** Returns the builder for the settings used for calls to testIamPermissions. */
659     public UnaryCallSettings.Builder<TestIamPermissionsSnapshotRequest, TestPermissionsResponse>
testIamPermissionsSettings()660         testIamPermissionsSettings() {
661       return testIamPermissionsSettings;
662     }
663 
664     @Override
build()665     public SnapshotsStubSettings build() throws IOException {
666       return new SnapshotsStubSettings(this);
667     }
668   }
669 }
670