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.v2beta2; 18 19 import static com.google.cloud.tasks.v2beta2.CloudTasksClient.ListQueuesPagedResponse; 20 import static com.google.cloud.tasks.v2beta2.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.v2beta2.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 leaseTasks. */ leaseTasksSettings()164 public UnaryCallSettings<LeaseTasksRequest, LeaseTasksResponse> leaseTasksSettings() { 165 return ((CloudTasksStubSettings) getStubSettings()).leaseTasksSettings(); 166 } 167 168 /** Returns the object with the settings used for calls to acknowledgeTask. */ acknowledgeTaskSettings()169 public UnaryCallSettings<AcknowledgeTaskRequest, Empty> acknowledgeTaskSettings() { 170 return ((CloudTasksStubSettings) getStubSettings()).acknowledgeTaskSettings(); 171 } 172 173 /** Returns the object with the settings used for calls to renewLease. */ renewLeaseSettings()174 public UnaryCallSettings<RenewLeaseRequest, Task> renewLeaseSettings() { 175 return ((CloudTasksStubSettings) getStubSettings()).renewLeaseSettings(); 176 } 177 178 /** Returns the object with the settings used for calls to cancelLease. */ cancelLeaseSettings()179 public UnaryCallSettings<CancelLeaseRequest, Task> cancelLeaseSettings() { 180 return ((CloudTasksStubSettings) getStubSettings()).cancelLeaseSettings(); 181 } 182 183 /** Returns the object with the settings used for calls to runTask. */ runTaskSettings()184 public UnaryCallSettings<RunTaskRequest, Task> runTaskSettings() { 185 return ((CloudTasksStubSettings) getStubSettings()).runTaskSettings(); 186 } 187 create(CloudTasksStubSettings stub)188 public static final CloudTasksSettings create(CloudTasksStubSettings stub) throws IOException { 189 return new CloudTasksSettings.Builder(stub.toBuilder()).build(); 190 } 191 192 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()193 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 194 return CloudTasksStubSettings.defaultExecutorProviderBuilder(); 195 } 196 197 /** Returns the default service endpoint. */ getDefaultEndpoint()198 public static String getDefaultEndpoint() { 199 return CloudTasksStubSettings.getDefaultEndpoint(); 200 } 201 202 /** Returns the default service scopes. */ getDefaultServiceScopes()203 public static List<String> getDefaultServiceScopes() { 204 return CloudTasksStubSettings.getDefaultServiceScopes(); 205 } 206 207 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()208 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 209 return CloudTasksStubSettings.defaultCredentialsProviderBuilder(); 210 } 211 212 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()213 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 214 return CloudTasksStubSettings.defaultGrpcTransportProviderBuilder(); 215 } 216 217 /** Returns a builder for the default REST ChannelProvider for this service. */ 218 @BetaApi 219 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()220 defaultHttpJsonTransportProviderBuilder() { 221 return CloudTasksStubSettings.defaultHttpJsonTransportProviderBuilder(); 222 } 223 defaultTransportChannelProvider()224 public static TransportChannelProvider defaultTransportChannelProvider() { 225 return CloudTasksStubSettings.defaultTransportChannelProvider(); 226 } 227 228 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()229 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 230 return CloudTasksStubSettings.defaultApiClientHeaderProviderBuilder(); 231 } 232 233 /** Returns a new gRPC builder for this class. */ newBuilder()234 public static Builder newBuilder() { 235 return Builder.createDefault(); 236 } 237 238 /** Returns a new REST builder for this class. */ 239 @BetaApi newHttpJsonBuilder()240 public static Builder newHttpJsonBuilder() { 241 return Builder.createHttpJsonDefault(); 242 } 243 244 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)245 public static Builder newBuilder(ClientContext clientContext) { 246 return new Builder(clientContext); 247 } 248 249 /** Returns a builder containing all the values of this settings class. */ toBuilder()250 public Builder toBuilder() { 251 return new Builder(this); 252 } 253 CloudTasksSettings(Builder settingsBuilder)254 protected CloudTasksSettings(Builder settingsBuilder) throws IOException { 255 super(settingsBuilder); 256 } 257 258 /** Builder for CloudTasksSettings. */ 259 public static class Builder extends ClientSettings.Builder<CloudTasksSettings, Builder> { 260 Builder()261 protected Builder() throws IOException { 262 this(((ClientContext) null)); 263 } 264 Builder(ClientContext clientContext)265 protected Builder(ClientContext clientContext) { 266 super(CloudTasksStubSettings.newBuilder(clientContext)); 267 } 268 Builder(CloudTasksSettings settings)269 protected Builder(CloudTasksSettings settings) { 270 super(settings.getStubSettings().toBuilder()); 271 } 272 Builder(CloudTasksStubSettings.Builder stubSettings)273 protected Builder(CloudTasksStubSettings.Builder stubSettings) { 274 super(stubSettings); 275 } 276 createDefault()277 private static Builder createDefault() { 278 return new Builder(CloudTasksStubSettings.newBuilder()); 279 } 280 281 @BetaApi createHttpJsonDefault()282 private static Builder createHttpJsonDefault() { 283 return new Builder(CloudTasksStubSettings.newHttpJsonBuilder()); 284 } 285 getStubSettingsBuilder()286 public CloudTasksStubSettings.Builder getStubSettingsBuilder() { 287 return ((CloudTasksStubSettings.Builder) getStubSettings()); 288 } 289 290 /** 291 * Applies the given settings updater function to all of the unary API methods in this service. 292 * 293 * <p>Note: This method does not support applying settings to streaming methods. 294 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)295 public Builder applyToAllUnaryMethods( 296 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 297 super.applyToAllUnaryMethods( 298 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 299 return this; 300 } 301 302 /** Returns the builder for the settings used for calls to listQueues. */ 303 public PagedCallSettings.Builder<ListQueuesRequest, ListQueuesResponse, ListQueuesPagedResponse> listQueuesSettings()304 listQueuesSettings() { 305 return getStubSettingsBuilder().listQueuesSettings(); 306 } 307 308 /** Returns the builder for the settings used for calls to getQueue. */ getQueueSettings()309 public UnaryCallSettings.Builder<GetQueueRequest, Queue> getQueueSettings() { 310 return getStubSettingsBuilder().getQueueSettings(); 311 } 312 313 /** Returns the builder for the settings used for calls to createQueue. */ createQueueSettings()314 public UnaryCallSettings.Builder<CreateQueueRequest, Queue> createQueueSettings() { 315 return getStubSettingsBuilder().createQueueSettings(); 316 } 317 318 /** Returns the builder for the settings used for calls to updateQueue. */ updateQueueSettings()319 public UnaryCallSettings.Builder<UpdateQueueRequest, Queue> updateQueueSettings() { 320 return getStubSettingsBuilder().updateQueueSettings(); 321 } 322 323 /** Returns the builder for the settings used for calls to deleteQueue. */ deleteQueueSettings()324 public UnaryCallSettings.Builder<DeleteQueueRequest, Empty> deleteQueueSettings() { 325 return getStubSettingsBuilder().deleteQueueSettings(); 326 } 327 328 /** Returns the builder for the settings used for calls to purgeQueue. */ purgeQueueSettings()329 public UnaryCallSettings.Builder<PurgeQueueRequest, Queue> purgeQueueSettings() { 330 return getStubSettingsBuilder().purgeQueueSettings(); 331 } 332 333 /** Returns the builder for the settings used for calls to pauseQueue. */ pauseQueueSettings()334 public UnaryCallSettings.Builder<PauseQueueRequest, Queue> pauseQueueSettings() { 335 return getStubSettingsBuilder().pauseQueueSettings(); 336 } 337 338 /** Returns the builder for the settings used for calls to resumeQueue. */ resumeQueueSettings()339 public UnaryCallSettings.Builder<ResumeQueueRequest, Queue> resumeQueueSettings() { 340 return getStubSettingsBuilder().resumeQueueSettings(); 341 } 342 343 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()344 public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() { 345 return getStubSettingsBuilder().getIamPolicySettings(); 346 } 347 348 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()349 public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() { 350 return getStubSettingsBuilder().setIamPolicySettings(); 351 } 352 353 /** Returns the builder for the settings used for calls to testIamPermissions. */ 354 public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()355 testIamPermissionsSettings() { 356 return getStubSettingsBuilder().testIamPermissionsSettings(); 357 } 358 359 /** Returns the builder for the settings used for calls to listTasks. */ 360 public PagedCallSettings.Builder<ListTasksRequest, ListTasksResponse, ListTasksPagedResponse> listTasksSettings()361 listTasksSettings() { 362 return getStubSettingsBuilder().listTasksSettings(); 363 } 364 365 /** Returns the builder for the settings used for calls to getTask. */ getTaskSettings()366 public UnaryCallSettings.Builder<GetTaskRequest, Task> getTaskSettings() { 367 return getStubSettingsBuilder().getTaskSettings(); 368 } 369 370 /** Returns the builder for the settings used for calls to createTask. */ createTaskSettings()371 public UnaryCallSettings.Builder<CreateTaskRequest, Task> createTaskSettings() { 372 return getStubSettingsBuilder().createTaskSettings(); 373 } 374 375 /** Returns the builder for the settings used for calls to deleteTask. */ deleteTaskSettings()376 public UnaryCallSettings.Builder<DeleteTaskRequest, Empty> deleteTaskSettings() { 377 return getStubSettingsBuilder().deleteTaskSettings(); 378 } 379 380 /** Returns the builder for the settings used for calls to leaseTasks. */ leaseTasksSettings()381 public UnaryCallSettings.Builder<LeaseTasksRequest, LeaseTasksResponse> leaseTasksSettings() { 382 return getStubSettingsBuilder().leaseTasksSettings(); 383 } 384 385 /** Returns the builder for the settings used for calls to acknowledgeTask. */ acknowledgeTaskSettings()386 public UnaryCallSettings.Builder<AcknowledgeTaskRequest, Empty> acknowledgeTaskSettings() { 387 return getStubSettingsBuilder().acknowledgeTaskSettings(); 388 } 389 390 /** Returns the builder for the settings used for calls to renewLease. */ renewLeaseSettings()391 public UnaryCallSettings.Builder<RenewLeaseRequest, Task> renewLeaseSettings() { 392 return getStubSettingsBuilder().renewLeaseSettings(); 393 } 394 395 /** Returns the builder for the settings used for calls to cancelLease. */ cancelLeaseSettings()396 public UnaryCallSettings.Builder<CancelLeaseRequest, Task> cancelLeaseSettings() { 397 return getStubSettingsBuilder().cancelLeaseSettings(); 398 } 399 400 /** Returns the builder for the settings used for calls to runTask. */ runTaskSettings()401 public UnaryCallSettings.Builder<RunTaskRequest, Task> runTaskSettings() { 402 return getStubSettingsBuilder().runTaskSettings(); 403 } 404 405 @Override build()406 public CloudTasksSettings build() throws IOException { 407 return new CloudTasksSettings(this); 408 } 409 } 410 } 411