• 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.tasks.v2beta3;
18 
19 import static com.google.cloud.tasks.v2beta3.CloudTasksClient.ListQueuesPagedResponse;
20 import static com.google.cloud.tasks.v2beta3.CloudTasksClient.ListTasksPagedResponse;
21 
22 import com.google.api.core.ApiFunction;
23 import com.google.api.core.BetaApi;
24 import com.google.api.gax.core.GoogleCredentialsProvider;
25 import com.google.api.gax.core.InstantiatingExecutorProvider;
26 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
27 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
28 import com.google.api.gax.rpc.ApiClientHeaderProvider;
29 import com.google.api.gax.rpc.ClientContext;
30 import com.google.api.gax.rpc.ClientSettings;
31 import com.google.api.gax.rpc.PagedCallSettings;
32 import com.google.api.gax.rpc.TransportChannelProvider;
33 import com.google.api.gax.rpc.UnaryCallSettings;
34 import com.google.cloud.tasks.v2beta3.stub.CloudTasksStubSettings;
35 import com.google.iam.v1.GetIamPolicyRequest;
36 import com.google.iam.v1.Policy;
37 import com.google.iam.v1.SetIamPolicyRequest;
38 import com.google.iam.v1.TestIamPermissionsRequest;
39 import com.google.iam.v1.TestIamPermissionsResponse;
40 import com.google.protobuf.Empty;
41 import java.io.IOException;
42 import java.util.List;
43 import javax.annotation.Generated;
44 
45 // AUTO-GENERATED DOCUMENTATION AND CLASS.
46 /**
47  * Settings class to configure an instance of {@link CloudTasksClient}.
48  *
49  * <p>The default instance has everything set to sensible defaults:
50  *
51  * <ul>
52  *   <li>The default service address (cloudtasks.googleapis.com) and default port (443) are used.
53  *   <li>Credentials are acquired automatically through Application Default Credentials.
54  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
55  * </ul>
56  *
57  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
58  * build() is called, the tree of builders is called to create the complete settings object.
59  *
60  * <p>For example, to set the total timeout of getQueue to 30 seconds:
61  *
62  * <pre>{@code
63  * // This snippet has been automatically generated and should be regarded as a code template only.
64  * // It will require modifications to work:
65  * // - It may require correct/in-range values for request initialization.
66  * // - It may require specifying regional endpoints when creating the service client as shown in
67  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
68  * CloudTasksSettings.Builder cloudTasksSettingsBuilder = CloudTasksSettings.newBuilder();
69  * cloudTasksSettingsBuilder
70  *     .getQueueSettings()
71  *     .setRetrySettings(
72  *         cloudTasksSettingsBuilder
73  *             .getQueueSettings()
74  *             .getRetrySettings()
75  *             .toBuilder()
76  *             .setTotalTimeout(Duration.ofSeconds(30))
77  *             .build());
78  * CloudTasksSettings cloudTasksSettings = cloudTasksSettingsBuilder.build();
79  * }</pre>
80  */
81 @BetaApi
82 @Generated("by gapic-generator-java")
83 public class CloudTasksSettings extends ClientSettings<CloudTasksSettings> {
84 
85   /** Returns the object with the settings used for calls to listQueues. */
86   public PagedCallSettings<ListQueuesRequest, ListQueuesResponse, ListQueuesPagedResponse>
listQueuesSettings()87       listQueuesSettings() {
88     return ((CloudTasksStubSettings) getStubSettings()).listQueuesSettings();
89   }
90 
91   /** Returns the object with the settings used for calls to getQueue. */
getQueueSettings()92   public UnaryCallSettings<GetQueueRequest, Queue> getQueueSettings() {
93     return ((CloudTasksStubSettings) getStubSettings()).getQueueSettings();
94   }
95 
96   /** Returns the object with the settings used for calls to createQueue. */
createQueueSettings()97   public UnaryCallSettings<CreateQueueRequest, Queue> createQueueSettings() {
98     return ((CloudTasksStubSettings) getStubSettings()).createQueueSettings();
99   }
100 
101   /** Returns the object with the settings used for calls to updateQueue. */
updateQueueSettings()102   public UnaryCallSettings<UpdateQueueRequest, Queue> updateQueueSettings() {
103     return ((CloudTasksStubSettings) getStubSettings()).updateQueueSettings();
104   }
105 
106   /** Returns the object with the settings used for calls to deleteQueue. */
deleteQueueSettings()107   public UnaryCallSettings<DeleteQueueRequest, Empty> deleteQueueSettings() {
108     return ((CloudTasksStubSettings) getStubSettings()).deleteQueueSettings();
109   }
110 
111   /** Returns the object with the settings used for calls to purgeQueue. */
purgeQueueSettings()112   public UnaryCallSettings<PurgeQueueRequest, Queue> purgeQueueSettings() {
113     return ((CloudTasksStubSettings) getStubSettings()).purgeQueueSettings();
114   }
115 
116   /** Returns the object with the settings used for calls to pauseQueue. */
pauseQueueSettings()117   public UnaryCallSettings<PauseQueueRequest, Queue> pauseQueueSettings() {
118     return ((CloudTasksStubSettings) getStubSettings()).pauseQueueSettings();
119   }
120 
121   /** Returns the object with the settings used for calls to resumeQueue. */
resumeQueueSettings()122   public UnaryCallSettings<ResumeQueueRequest, Queue> resumeQueueSettings() {
123     return ((CloudTasksStubSettings) getStubSettings()).resumeQueueSettings();
124   }
125 
126   /** Returns the object with the settings used for calls to getIamPolicy. */
getIamPolicySettings()127   public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() {
128     return ((CloudTasksStubSettings) getStubSettings()).getIamPolicySettings();
129   }
130 
131   /** Returns the object with the settings used for calls to setIamPolicy. */
setIamPolicySettings()132   public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() {
133     return ((CloudTasksStubSettings) getStubSettings()).setIamPolicySettings();
134   }
135 
136   /** Returns the object with the settings used for calls to testIamPermissions. */
137   public UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsSettings()138       testIamPermissionsSettings() {
139     return ((CloudTasksStubSettings) getStubSettings()).testIamPermissionsSettings();
140   }
141 
142   /** Returns the object with the settings used for calls to listTasks. */
143   public PagedCallSettings<ListTasksRequest, ListTasksResponse, ListTasksPagedResponse>
listTasksSettings()144       listTasksSettings() {
145     return ((CloudTasksStubSettings) getStubSettings()).listTasksSettings();
146   }
147 
148   /** Returns the object with the settings used for calls to getTask. */
getTaskSettings()149   public UnaryCallSettings<GetTaskRequest, Task> getTaskSettings() {
150     return ((CloudTasksStubSettings) getStubSettings()).getTaskSettings();
151   }
152 
153   /** Returns the object with the settings used for calls to createTask. */
createTaskSettings()154   public UnaryCallSettings<CreateTaskRequest, Task> createTaskSettings() {
155     return ((CloudTasksStubSettings) getStubSettings()).createTaskSettings();
156   }
157 
158   /** Returns the object with the settings used for calls to deleteTask. */
deleteTaskSettings()159   public UnaryCallSettings<DeleteTaskRequest, Empty> deleteTaskSettings() {
160     return ((CloudTasksStubSettings) getStubSettings()).deleteTaskSettings();
161   }
162 
163   /** Returns the object with the settings used for calls to runTask. */
runTaskSettings()164   public UnaryCallSettings<RunTaskRequest, Task> runTaskSettings() {
165     return ((CloudTasksStubSettings) getStubSettings()).runTaskSettings();
166   }
167 
create(CloudTasksStubSettings stub)168   public static final CloudTasksSettings create(CloudTasksStubSettings stub) throws IOException {
169     return new CloudTasksSettings.Builder(stub.toBuilder()).build();
170   }
171 
172   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()173   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
174     return CloudTasksStubSettings.defaultExecutorProviderBuilder();
175   }
176 
177   /** Returns the default service endpoint. */
getDefaultEndpoint()178   public static String getDefaultEndpoint() {
179     return CloudTasksStubSettings.getDefaultEndpoint();
180   }
181 
182   /** Returns the default service scopes. */
getDefaultServiceScopes()183   public static List<String> getDefaultServiceScopes() {
184     return CloudTasksStubSettings.getDefaultServiceScopes();
185   }
186 
187   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()188   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
189     return CloudTasksStubSettings.defaultCredentialsProviderBuilder();
190   }
191 
192   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()193   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
194     return CloudTasksStubSettings.defaultGrpcTransportProviderBuilder();
195   }
196 
197   /** Returns a builder for the default REST ChannelProvider for this service. */
198   @BetaApi
199   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()200       defaultHttpJsonTransportProviderBuilder() {
201     return CloudTasksStubSettings.defaultHttpJsonTransportProviderBuilder();
202   }
203 
defaultTransportChannelProvider()204   public static TransportChannelProvider defaultTransportChannelProvider() {
205     return CloudTasksStubSettings.defaultTransportChannelProvider();
206   }
207 
208   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()209   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
210     return CloudTasksStubSettings.defaultApiClientHeaderProviderBuilder();
211   }
212 
213   /** Returns a new gRPC builder for this class. */
newBuilder()214   public static Builder newBuilder() {
215     return Builder.createDefault();
216   }
217 
218   /** Returns a new REST builder for this class. */
219   @BetaApi
newHttpJsonBuilder()220   public static Builder newHttpJsonBuilder() {
221     return Builder.createHttpJsonDefault();
222   }
223 
224   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)225   public static Builder newBuilder(ClientContext clientContext) {
226     return new Builder(clientContext);
227   }
228 
229   /** Returns a builder containing all the values of this settings class. */
toBuilder()230   public Builder toBuilder() {
231     return new Builder(this);
232   }
233 
CloudTasksSettings(Builder settingsBuilder)234   protected CloudTasksSettings(Builder settingsBuilder) throws IOException {
235     super(settingsBuilder);
236   }
237 
238   /** Builder for CloudTasksSettings. */
239   public static class Builder extends ClientSettings.Builder<CloudTasksSettings, Builder> {
240 
Builder()241     protected Builder() throws IOException {
242       this(((ClientContext) null));
243     }
244 
Builder(ClientContext clientContext)245     protected Builder(ClientContext clientContext) {
246       super(CloudTasksStubSettings.newBuilder(clientContext));
247     }
248 
Builder(CloudTasksSettings settings)249     protected Builder(CloudTasksSettings settings) {
250       super(settings.getStubSettings().toBuilder());
251     }
252 
Builder(CloudTasksStubSettings.Builder stubSettings)253     protected Builder(CloudTasksStubSettings.Builder stubSettings) {
254       super(stubSettings);
255     }
256 
createDefault()257     private static Builder createDefault() {
258       return new Builder(CloudTasksStubSettings.newBuilder());
259     }
260 
261     @BetaApi
createHttpJsonDefault()262     private static Builder createHttpJsonDefault() {
263       return new Builder(CloudTasksStubSettings.newHttpJsonBuilder());
264     }
265 
getStubSettingsBuilder()266     public CloudTasksStubSettings.Builder getStubSettingsBuilder() {
267       return ((CloudTasksStubSettings.Builder) getStubSettings());
268     }
269 
270     /**
271      * Applies the given settings updater function to all of the unary API methods in this service.
272      *
273      * <p>Note: This method does not support applying settings to streaming methods.
274      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)275     public Builder applyToAllUnaryMethods(
276         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
277       super.applyToAllUnaryMethods(
278           getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
279       return this;
280     }
281 
282     /** Returns the builder for the settings used for calls to listQueues. */
283     public PagedCallSettings.Builder<ListQueuesRequest, ListQueuesResponse, ListQueuesPagedResponse>
listQueuesSettings()284         listQueuesSettings() {
285       return getStubSettingsBuilder().listQueuesSettings();
286     }
287 
288     /** Returns the builder for the settings used for calls to getQueue. */
getQueueSettings()289     public UnaryCallSettings.Builder<GetQueueRequest, Queue> getQueueSettings() {
290       return getStubSettingsBuilder().getQueueSettings();
291     }
292 
293     /** Returns the builder for the settings used for calls to createQueue. */
createQueueSettings()294     public UnaryCallSettings.Builder<CreateQueueRequest, Queue> createQueueSettings() {
295       return getStubSettingsBuilder().createQueueSettings();
296     }
297 
298     /** Returns the builder for the settings used for calls to updateQueue. */
updateQueueSettings()299     public UnaryCallSettings.Builder<UpdateQueueRequest, Queue> updateQueueSettings() {
300       return getStubSettingsBuilder().updateQueueSettings();
301     }
302 
303     /** Returns the builder for the settings used for calls to deleteQueue. */
deleteQueueSettings()304     public UnaryCallSettings.Builder<DeleteQueueRequest, Empty> deleteQueueSettings() {
305       return getStubSettingsBuilder().deleteQueueSettings();
306     }
307 
308     /** Returns the builder for the settings used for calls to purgeQueue. */
purgeQueueSettings()309     public UnaryCallSettings.Builder<PurgeQueueRequest, Queue> purgeQueueSettings() {
310       return getStubSettingsBuilder().purgeQueueSettings();
311     }
312 
313     /** Returns the builder for the settings used for calls to pauseQueue. */
pauseQueueSettings()314     public UnaryCallSettings.Builder<PauseQueueRequest, Queue> pauseQueueSettings() {
315       return getStubSettingsBuilder().pauseQueueSettings();
316     }
317 
318     /** Returns the builder for the settings used for calls to resumeQueue. */
resumeQueueSettings()319     public UnaryCallSettings.Builder<ResumeQueueRequest, Queue> resumeQueueSettings() {
320       return getStubSettingsBuilder().resumeQueueSettings();
321     }
322 
323     /** Returns the builder for the settings used for calls to getIamPolicy. */
getIamPolicySettings()324     public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() {
325       return getStubSettingsBuilder().getIamPolicySettings();
326     }
327 
328     /** Returns the builder for the settings used for calls to setIamPolicy. */
setIamPolicySettings()329     public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() {
330       return getStubSettingsBuilder().setIamPolicySettings();
331     }
332 
333     /** Returns the builder for the settings used for calls to testIamPermissions. */
334     public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsSettings()335         testIamPermissionsSettings() {
336       return getStubSettingsBuilder().testIamPermissionsSettings();
337     }
338 
339     /** Returns the builder for the settings used for calls to listTasks. */
340     public PagedCallSettings.Builder<ListTasksRequest, ListTasksResponse, ListTasksPagedResponse>
listTasksSettings()341         listTasksSettings() {
342       return getStubSettingsBuilder().listTasksSettings();
343     }
344 
345     /** Returns the builder for the settings used for calls to getTask. */
getTaskSettings()346     public UnaryCallSettings.Builder<GetTaskRequest, Task> getTaskSettings() {
347       return getStubSettingsBuilder().getTaskSettings();
348     }
349 
350     /** Returns the builder for the settings used for calls to createTask. */
createTaskSettings()351     public UnaryCallSettings.Builder<CreateTaskRequest, Task> createTaskSettings() {
352       return getStubSettingsBuilder().createTaskSettings();
353     }
354 
355     /** Returns the builder for the settings used for calls to deleteTask. */
deleteTaskSettings()356     public UnaryCallSettings.Builder<DeleteTaskRequest, Empty> deleteTaskSettings() {
357       return getStubSettingsBuilder().deleteTaskSettings();
358     }
359 
360     /** Returns the builder for the settings used for calls to runTask. */
runTaskSettings()361     public UnaryCallSettings.Builder<RunTaskRequest, Task> runTaskSettings() {
362       return getStubSettingsBuilder().runTaskSettings();
363     }
364 
365     @Override
build()366     public CloudTasksSettings build() throws IOException {
367       return new CloudTasksSettings(this);
368     }
369   }
370 }
371