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.v2; 18 19 import static com.google.cloud.tasks.v2.CloudTasksClient.ListQueuesPagedResponse; 20 import static com.google.cloud.tasks.v2.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.v2.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 @Generated("by gapic-generator-java") 82 public class CloudTasksSettings extends ClientSettings<CloudTasksSettings> { 83 84 /** Returns the object with the settings used for calls to listQueues. */ 85 public PagedCallSettings<ListQueuesRequest, ListQueuesResponse, ListQueuesPagedResponse> listQueuesSettings()86 listQueuesSettings() { 87 return ((CloudTasksStubSettings) getStubSettings()).listQueuesSettings(); 88 } 89 90 /** Returns the object with the settings used for calls to getQueue. */ getQueueSettings()91 public UnaryCallSettings<GetQueueRequest, Queue> getQueueSettings() { 92 return ((CloudTasksStubSettings) getStubSettings()).getQueueSettings(); 93 } 94 95 /** Returns the object with the settings used for calls to createQueue. */ createQueueSettings()96 public UnaryCallSettings<CreateQueueRequest, Queue> createQueueSettings() { 97 return ((CloudTasksStubSettings) getStubSettings()).createQueueSettings(); 98 } 99 100 /** Returns the object with the settings used for calls to updateQueue. */ updateQueueSettings()101 public UnaryCallSettings<UpdateQueueRequest, Queue> updateQueueSettings() { 102 return ((CloudTasksStubSettings) getStubSettings()).updateQueueSettings(); 103 } 104 105 /** Returns the object with the settings used for calls to deleteQueue. */ deleteQueueSettings()106 public UnaryCallSettings<DeleteQueueRequest, Empty> deleteQueueSettings() { 107 return ((CloudTasksStubSettings) getStubSettings()).deleteQueueSettings(); 108 } 109 110 /** Returns the object with the settings used for calls to purgeQueue. */ purgeQueueSettings()111 public UnaryCallSettings<PurgeQueueRequest, Queue> purgeQueueSettings() { 112 return ((CloudTasksStubSettings) getStubSettings()).purgeQueueSettings(); 113 } 114 115 /** Returns the object with the settings used for calls to pauseQueue. */ pauseQueueSettings()116 public UnaryCallSettings<PauseQueueRequest, Queue> pauseQueueSettings() { 117 return ((CloudTasksStubSettings) getStubSettings()).pauseQueueSettings(); 118 } 119 120 /** Returns the object with the settings used for calls to resumeQueue. */ resumeQueueSettings()121 public UnaryCallSettings<ResumeQueueRequest, Queue> resumeQueueSettings() { 122 return ((CloudTasksStubSettings) getStubSettings()).resumeQueueSettings(); 123 } 124 125 /** Returns the object with the settings used for calls to getIamPolicy. */ getIamPolicySettings()126 public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() { 127 return ((CloudTasksStubSettings) getStubSettings()).getIamPolicySettings(); 128 } 129 130 /** Returns the object with the settings used for calls to setIamPolicy. */ setIamPolicySettings()131 public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() { 132 return ((CloudTasksStubSettings) getStubSettings()).setIamPolicySettings(); 133 } 134 135 /** Returns the object with the settings used for calls to testIamPermissions. */ 136 public UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()137 testIamPermissionsSettings() { 138 return ((CloudTasksStubSettings) getStubSettings()).testIamPermissionsSettings(); 139 } 140 141 /** Returns the object with the settings used for calls to listTasks. */ 142 public PagedCallSettings<ListTasksRequest, ListTasksResponse, ListTasksPagedResponse> listTasksSettings()143 listTasksSettings() { 144 return ((CloudTasksStubSettings) getStubSettings()).listTasksSettings(); 145 } 146 147 /** Returns the object with the settings used for calls to getTask. */ getTaskSettings()148 public UnaryCallSettings<GetTaskRequest, Task> getTaskSettings() { 149 return ((CloudTasksStubSettings) getStubSettings()).getTaskSettings(); 150 } 151 152 /** Returns the object with the settings used for calls to createTask. */ createTaskSettings()153 public UnaryCallSettings<CreateTaskRequest, Task> createTaskSettings() { 154 return ((CloudTasksStubSettings) getStubSettings()).createTaskSettings(); 155 } 156 157 /** Returns the object with the settings used for calls to deleteTask. */ deleteTaskSettings()158 public UnaryCallSettings<DeleteTaskRequest, Empty> deleteTaskSettings() { 159 return ((CloudTasksStubSettings) getStubSettings()).deleteTaskSettings(); 160 } 161 162 /** Returns the object with the settings used for calls to runTask. */ runTaskSettings()163 public UnaryCallSettings<RunTaskRequest, Task> runTaskSettings() { 164 return ((CloudTasksStubSettings) getStubSettings()).runTaskSettings(); 165 } 166 create(CloudTasksStubSettings stub)167 public static final CloudTasksSettings create(CloudTasksStubSettings stub) throws IOException { 168 return new CloudTasksSettings.Builder(stub.toBuilder()).build(); 169 } 170 171 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()172 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 173 return CloudTasksStubSettings.defaultExecutorProviderBuilder(); 174 } 175 176 /** Returns the default service endpoint. */ getDefaultEndpoint()177 public static String getDefaultEndpoint() { 178 return CloudTasksStubSettings.getDefaultEndpoint(); 179 } 180 181 /** Returns the default service scopes. */ getDefaultServiceScopes()182 public static List<String> getDefaultServiceScopes() { 183 return CloudTasksStubSettings.getDefaultServiceScopes(); 184 } 185 186 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()187 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 188 return CloudTasksStubSettings.defaultCredentialsProviderBuilder(); 189 } 190 191 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()192 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 193 return CloudTasksStubSettings.defaultGrpcTransportProviderBuilder(); 194 } 195 196 /** Returns a builder for the default REST ChannelProvider for this service. */ 197 @BetaApi 198 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()199 defaultHttpJsonTransportProviderBuilder() { 200 return CloudTasksStubSettings.defaultHttpJsonTransportProviderBuilder(); 201 } 202 defaultTransportChannelProvider()203 public static TransportChannelProvider defaultTransportChannelProvider() { 204 return CloudTasksStubSettings.defaultTransportChannelProvider(); 205 } 206 207 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()208 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 209 return CloudTasksStubSettings.defaultApiClientHeaderProviderBuilder(); 210 } 211 212 /** Returns a new gRPC builder for this class. */ newBuilder()213 public static Builder newBuilder() { 214 return Builder.createDefault(); 215 } 216 217 /** Returns a new REST builder for this class. */ 218 @BetaApi newHttpJsonBuilder()219 public static Builder newHttpJsonBuilder() { 220 return Builder.createHttpJsonDefault(); 221 } 222 223 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)224 public static Builder newBuilder(ClientContext clientContext) { 225 return new Builder(clientContext); 226 } 227 228 /** Returns a builder containing all the values of this settings class. */ toBuilder()229 public Builder toBuilder() { 230 return new Builder(this); 231 } 232 CloudTasksSettings(Builder settingsBuilder)233 protected CloudTasksSettings(Builder settingsBuilder) throws IOException { 234 super(settingsBuilder); 235 } 236 237 /** Builder for CloudTasksSettings. */ 238 public static class Builder extends ClientSettings.Builder<CloudTasksSettings, Builder> { 239 Builder()240 protected Builder() throws IOException { 241 this(((ClientContext) null)); 242 } 243 Builder(ClientContext clientContext)244 protected Builder(ClientContext clientContext) { 245 super(CloudTasksStubSettings.newBuilder(clientContext)); 246 } 247 Builder(CloudTasksSettings settings)248 protected Builder(CloudTasksSettings settings) { 249 super(settings.getStubSettings().toBuilder()); 250 } 251 Builder(CloudTasksStubSettings.Builder stubSettings)252 protected Builder(CloudTasksStubSettings.Builder stubSettings) { 253 super(stubSettings); 254 } 255 createDefault()256 private static Builder createDefault() { 257 return new Builder(CloudTasksStubSettings.newBuilder()); 258 } 259 260 @BetaApi createHttpJsonDefault()261 private static Builder createHttpJsonDefault() { 262 return new Builder(CloudTasksStubSettings.newHttpJsonBuilder()); 263 } 264 getStubSettingsBuilder()265 public CloudTasksStubSettings.Builder getStubSettingsBuilder() { 266 return ((CloudTasksStubSettings.Builder) getStubSettings()); 267 } 268 269 /** 270 * Applies the given settings updater function to all of the unary API methods in this service. 271 * 272 * <p>Note: This method does not support applying settings to streaming methods. 273 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)274 public Builder applyToAllUnaryMethods( 275 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 276 super.applyToAllUnaryMethods( 277 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 278 return this; 279 } 280 281 /** Returns the builder for the settings used for calls to listQueues. */ 282 public PagedCallSettings.Builder<ListQueuesRequest, ListQueuesResponse, ListQueuesPagedResponse> listQueuesSettings()283 listQueuesSettings() { 284 return getStubSettingsBuilder().listQueuesSettings(); 285 } 286 287 /** Returns the builder for the settings used for calls to getQueue. */ getQueueSettings()288 public UnaryCallSettings.Builder<GetQueueRequest, Queue> getQueueSettings() { 289 return getStubSettingsBuilder().getQueueSettings(); 290 } 291 292 /** Returns the builder for the settings used for calls to createQueue. */ createQueueSettings()293 public UnaryCallSettings.Builder<CreateQueueRequest, Queue> createQueueSettings() { 294 return getStubSettingsBuilder().createQueueSettings(); 295 } 296 297 /** Returns the builder for the settings used for calls to updateQueue. */ updateQueueSettings()298 public UnaryCallSettings.Builder<UpdateQueueRequest, Queue> updateQueueSettings() { 299 return getStubSettingsBuilder().updateQueueSettings(); 300 } 301 302 /** Returns the builder for the settings used for calls to deleteQueue. */ deleteQueueSettings()303 public UnaryCallSettings.Builder<DeleteQueueRequest, Empty> deleteQueueSettings() { 304 return getStubSettingsBuilder().deleteQueueSettings(); 305 } 306 307 /** Returns the builder for the settings used for calls to purgeQueue. */ purgeQueueSettings()308 public UnaryCallSettings.Builder<PurgeQueueRequest, Queue> purgeQueueSettings() { 309 return getStubSettingsBuilder().purgeQueueSettings(); 310 } 311 312 /** Returns the builder for the settings used for calls to pauseQueue. */ pauseQueueSettings()313 public UnaryCallSettings.Builder<PauseQueueRequest, Queue> pauseQueueSettings() { 314 return getStubSettingsBuilder().pauseQueueSettings(); 315 } 316 317 /** Returns the builder for the settings used for calls to resumeQueue. */ resumeQueueSettings()318 public UnaryCallSettings.Builder<ResumeQueueRequest, Queue> resumeQueueSettings() { 319 return getStubSettingsBuilder().resumeQueueSettings(); 320 } 321 322 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()323 public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() { 324 return getStubSettingsBuilder().getIamPolicySettings(); 325 } 326 327 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()328 public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() { 329 return getStubSettingsBuilder().setIamPolicySettings(); 330 } 331 332 /** Returns the builder for the settings used for calls to testIamPermissions. */ 333 public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()334 testIamPermissionsSettings() { 335 return getStubSettingsBuilder().testIamPermissionsSettings(); 336 } 337 338 /** Returns the builder for the settings used for calls to listTasks. */ 339 public PagedCallSettings.Builder<ListTasksRequest, ListTasksResponse, ListTasksPagedResponse> listTasksSettings()340 listTasksSettings() { 341 return getStubSettingsBuilder().listTasksSettings(); 342 } 343 344 /** Returns the builder for the settings used for calls to getTask. */ getTaskSettings()345 public UnaryCallSettings.Builder<GetTaskRequest, Task> getTaskSettings() { 346 return getStubSettingsBuilder().getTaskSettings(); 347 } 348 349 /** Returns the builder for the settings used for calls to createTask. */ createTaskSettings()350 public UnaryCallSettings.Builder<CreateTaskRequest, Task> createTaskSettings() { 351 return getStubSettingsBuilder().createTaskSettings(); 352 } 353 354 /** Returns the builder for the settings used for calls to deleteTask. */ deleteTaskSettings()355 public UnaryCallSettings.Builder<DeleteTaskRequest, Empty> deleteTaskSettings() { 356 return getStubSettingsBuilder().deleteTaskSettings(); 357 } 358 359 /** Returns the builder for the settings used for calls to runTask. */ runTaskSettings()360 public UnaryCallSettings.Builder<RunTaskRequest, Task> runTaskSettings() { 361 return getStubSettingsBuilder().runTaskSettings(); 362 } 363 364 @Override build()365 public CloudTasksSettings build() throws IOException { 366 return new CloudTasksSettings(this); 367 } 368 } 369 } 370