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.scheduler.v1beta1; 18 19 import static com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse; 20 import static com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListLocationsPagedResponse; 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.location.GetLocationRequest; 35 import com.google.cloud.location.ListLocationsRequest; 36 import com.google.cloud.location.ListLocationsResponse; 37 import com.google.cloud.location.Location; 38 import com.google.cloud.scheduler.v1beta1.stub.CloudSchedulerStubSettings; 39 import com.google.protobuf.Empty; 40 import java.io.IOException; 41 import java.util.List; 42 import javax.annotation.Generated; 43 44 // AUTO-GENERATED DOCUMENTATION AND CLASS. 45 /** 46 * Settings class to configure an instance of {@link CloudSchedulerClient}. 47 * 48 * <p>The default instance has everything set to sensible defaults: 49 * 50 * <ul> 51 * <li>The default service address (cloudscheduler.googleapis.com) and default port (443) are 52 * 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 getJob 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 * CloudSchedulerSettings.Builder cloudSchedulerSettingsBuilder = 69 * CloudSchedulerSettings.newBuilder(); 70 * cloudSchedulerSettingsBuilder 71 * .getJobSettings() 72 * .setRetrySettings( 73 * cloudSchedulerSettingsBuilder 74 * .getJobSettings() 75 * .getRetrySettings() 76 * .toBuilder() 77 * .setTotalTimeout(Duration.ofSeconds(30)) 78 * .build()); 79 * CloudSchedulerSettings cloudSchedulerSettings = cloudSchedulerSettingsBuilder.build(); 80 * }</pre> 81 */ 82 @BetaApi 83 @Generated("by gapic-generator-java") 84 public class CloudSchedulerSettings extends ClientSettings<CloudSchedulerSettings> { 85 86 /** Returns the object with the settings used for calls to listJobs. */ 87 public PagedCallSettings<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> listJobsSettings()88 listJobsSettings() { 89 return ((CloudSchedulerStubSettings) getStubSettings()).listJobsSettings(); 90 } 91 92 /** Returns the object with the settings used for calls to getJob. */ getJobSettings()93 public UnaryCallSettings<GetJobRequest, Job> getJobSettings() { 94 return ((CloudSchedulerStubSettings) getStubSettings()).getJobSettings(); 95 } 96 97 /** Returns the object with the settings used for calls to createJob. */ createJobSettings()98 public UnaryCallSettings<CreateJobRequest, Job> createJobSettings() { 99 return ((CloudSchedulerStubSettings) getStubSettings()).createJobSettings(); 100 } 101 102 /** Returns the object with the settings used for calls to updateJob. */ updateJobSettings()103 public UnaryCallSettings<UpdateJobRequest, Job> updateJobSettings() { 104 return ((CloudSchedulerStubSettings) getStubSettings()).updateJobSettings(); 105 } 106 107 /** Returns the object with the settings used for calls to deleteJob. */ deleteJobSettings()108 public UnaryCallSettings<DeleteJobRequest, Empty> deleteJobSettings() { 109 return ((CloudSchedulerStubSettings) getStubSettings()).deleteJobSettings(); 110 } 111 112 /** Returns the object with the settings used for calls to pauseJob. */ pauseJobSettings()113 public UnaryCallSettings<PauseJobRequest, Job> pauseJobSettings() { 114 return ((CloudSchedulerStubSettings) getStubSettings()).pauseJobSettings(); 115 } 116 117 /** Returns the object with the settings used for calls to resumeJob. */ resumeJobSettings()118 public UnaryCallSettings<ResumeJobRequest, Job> resumeJobSettings() { 119 return ((CloudSchedulerStubSettings) getStubSettings()).resumeJobSettings(); 120 } 121 122 /** Returns the object with the settings used for calls to runJob. */ runJobSettings()123 public UnaryCallSettings<RunJobRequest, Job> runJobSettings() { 124 return ((CloudSchedulerStubSettings) getStubSettings()).runJobSettings(); 125 } 126 127 /** Returns the object with the settings used for calls to listLocations. */ 128 public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()129 listLocationsSettings() { 130 return ((CloudSchedulerStubSettings) getStubSettings()).listLocationsSettings(); 131 } 132 133 /** Returns the object with the settings used for calls to getLocation. */ getLocationSettings()134 public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() { 135 return ((CloudSchedulerStubSettings) getStubSettings()).getLocationSettings(); 136 } 137 create(CloudSchedulerStubSettings stub)138 public static final CloudSchedulerSettings create(CloudSchedulerStubSettings stub) 139 throws IOException { 140 return new CloudSchedulerSettings.Builder(stub.toBuilder()).build(); 141 } 142 143 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()144 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 145 return CloudSchedulerStubSettings.defaultExecutorProviderBuilder(); 146 } 147 148 /** Returns the default service endpoint. */ getDefaultEndpoint()149 public static String getDefaultEndpoint() { 150 return CloudSchedulerStubSettings.getDefaultEndpoint(); 151 } 152 153 /** Returns the default service scopes. */ getDefaultServiceScopes()154 public static List<String> getDefaultServiceScopes() { 155 return CloudSchedulerStubSettings.getDefaultServiceScopes(); 156 } 157 158 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()159 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 160 return CloudSchedulerStubSettings.defaultCredentialsProviderBuilder(); 161 } 162 163 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()164 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 165 return CloudSchedulerStubSettings.defaultGrpcTransportProviderBuilder(); 166 } 167 168 /** Returns a builder for the default REST ChannelProvider for this service. */ 169 @BetaApi 170 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()171 defaultHttpJsonTransportProviderBuilder() { 172 return CloudSchedulerStubSettings.defaultHttpJsonTransportProviderBuilder(); 173 } 174 defaultTransportChannelProvider()175 public static TransportChannelProvider defaultTransportChannelProvider() { 176 return CloudSchedulerStubSettings.defaultTransportChannelProvider(); 177 } 178 179 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()180 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 181 return CloudSchedulerStubSettings.defaultApiClientHeaderProviderBuilder(); 182 } 183 184 /** Returns a new gRPC builder for this class. */ newBuilder()185 public static Builder newBuilder() { 186 return Builder.createDefault(); 187 } 188 189 /** Returns a new REST builder for this class. */ 190 @BetaApi newHttpJsonBuilder()191 public static Builder newHttpJsonBuilder() { 192 return Builder.createHttpJsonDefault(); 193 } 194 195 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)196 public static Builder newBuilder(ClientContext clientContext) { 197 return new Builder(clientContext); 198 } 199 200 /** Returns a builder containing all the values of this settings class. */ toBuilder()201 public Builder toBuilder() { 202 return new Builder(this); 203 } 204 CloudSchedulerSettings(Builder settingsBuilder)205 protected CloudSchedulerSettings(Builder settingsBuilder) throws IOException { 206 super(settingsBuilder); 207 } 208 209 /** Builder for CloudSchedulerSettings. */ 210 public static class Builder extends ClientSettings.Builder<CloudSchedulerSettings, Builder> { 211 Builder()212 protected Builder() throws IOException { 213 this(((ClientContext) null)); 214 } 215 Builder(ClientContext clientContext)216 protected Builder(ClientContext clientContext) { 217 super(CloudSchedulerStubSettings.newBuilder(clientContext)); 218 } 219 Builder(CloudSchedulerSettings settings)220 protected Builder(CloudSchedulerSettings settings) { 221 super(settings.getStubSettings().toBuilder()); 222 } 223 Builder(CloudSchedulerStubSettings.Builder stubSettings)224 protected Builder(CloudSchedulerStubSettings.Builder stubSettings) { 225 super(stubSettings); 226 } 227 createDefault()228 private static Builder createDefault() { 229 return new Builder(CloudSchedulerStubSettings.newBuilder()); 230 } 231 232 @BetaApi createHttpJsonDefault()233 private static Builder createHttpJsonDefault() { 234 return new Builder(CloudSchedulerStubSettings.newHttpJsonBuilder()); 235 } 236 getStubSettingsBuilder()237 public CloudSchedulerStubSettings.Builder getStubSettingsBuilder() { 238 return ((CloudSchedulerStubSettings.Builder) getStubSettings()); 239 } 240 241 /** 242 * Applies the given settings updater function to all of the unary API methods in this service. 243 * 244 * <p>Note: This method does not support applying settings to streaming methods. 245 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)246 public Builder applyToAllUnaryMethods( 247 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 248 super.applyToAllUnaryMethods( 249 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 250 return this; 251 } 252 253 /** Returns the builder for the settings used for calls to listJobs. */ 254 public PagedCallSettings.Builder<ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> listJobsSettings()255 listJobsSettings() { 256 return getStubSettingsBuilder().listJobsSettings(); 257 } 258 259 /** Returns the builder for the settings used for calls to getJob. */ getJobSettings()260 public UnaryCallSettings.Builder<GetJobRequest, Job> getJobSettings() { 261 return getStubSettingsBuilder().getJobSettings(); 262 } 263 264 /** Returns the builder for the settings used for calls to createJob. */ createJobSettings()265 public UnaryCallSettings.Builder<CreateJobRequest, Job> createJobSettings() { 266 return getStubSettingsBuilder().createJobSettings(); 267 } 268 269 /** Returns the builder for the settings used for calls to updateJob. */ updateJobSettings()270 public UnaryCallSettings.Builder<UpdateJobRequest, Job> updateJobSettings() { 271 return getStubSettingsBuilder().updateJobSettings(); 272 } 273 274 /** Returns the builder for the settings used for calls to deleteJob. */ deleteJobSettings()275 public UnaryCallSettings.Builder<DeleteJobRequest, Empty> deleteJobSettings() { 276 return getStubSettingsBuilder().deleteJobSettings(); 277 } 278 279 /** Returns the builder for the settings used for calls to pauseJob. */ pauseJobSettings()280 public UnaryCallSettings.Builder<PauseJobRequest, Job> pauseJobSettings() { 281 return getStubSettingsBuilder().pauseJobSettings(); 282 } 283 284 /** Returns the builder for the settings used for calls to resumeJob. */ resumeJobSettings()285 public UnaryCallSettings.Builder<ResumeJobRequest, Job> resumeJobSettings() { 286 return getStubSettingsBuilder().resumeJobSettings(); 287 } 288 289 /** Returns the builder for the settings used for calls to runJob. */ runJobSettings()290 public UnaryCallSettings.Builder<RunJobRequest, Job> runJobSettings() { 291 return getStubSettingsBuilder().runJobSettings(); 292 } 293 294 /** Returns the builder for the settings used for calls to listLocations. */ 295 public PagedCallSettings.Builder< 296 ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()297 listLocationsSettings() { 298 return getStubSettingsBuilder().listLocationsSettings(); 299 } 300 301 /** Returns the builder for the settings used for calls to getLocation. */ getLocationSettings()302 public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { 303 return getStubSettingsBuilder().getLocationSettings(); 304 } 305 306 @Override build()307 public CloudSchedulerSettings build() throws IOException { 308 return new CloudSchedulerSettings(this); 309 } 310 } 311 } 312